#9: peco, Go, ghq をインストール

今日やったこと(Done)

インクリメンタル候補選択ツール(?)の peco をインストールしました。

$ brew info peco
$ brew install peco

fish の設定ファイル config.fish を作成して、エイリアス等を設定しました。

$ cd ~/.config/fish
$ touch config.fish
$ code .
# alias
alias ls "ls -aG"
alias rm "rm -i"
alias cp "cp -i"
alias mv "mv -i"
alias mkdir "mkdir -p"

## alias for git
alias gst "git status"

# user defined functions
function cd
  builtin cd $argv
  ls
end

Go をインストールしました。

$ brew install go
$ go version
go version go1.14.5 darwin/amd64

$GOPATH はデフォルトだと ~/go になり、その下に src, pkg, bin が置かれることになります。

今回は ghq を入れて Go 以外のコードも全て同じスタイルで管理したいので、$GOPATH および ghq.root~ にしましょう。

config.fish に PATH の設定を記載します。

set -x GOPATH $HOME
set -x PATH $GOPATH/bin $PATH

ghq をインストールします。

$ brew install ghq

ghq の設定は .gitconfig に記載します。

[ghq]
    root = ~/src
## peco with option
function peco
  command peco --layout=bottom-up $argv
end

## peco でコマンド履歴を検索する
function peco_select_history
    if test (count $argv) = 0
        set peco_flags --layout=bottom-up
    else
        set peco_flags --layout=bottom-up --query "$argv"
    end
    history | peco $peco_flags | read foo
    if [ $foo ]
        commandline $foo
    else
        commandline ''
    end
end

## peco で ghq で管理するリポジトリを検索する
function peco_ghq_repository
  set selected_repository (ghq list -p | peco --query "$LBUFFER")
  if [ -n "$selected_repository" ]
    cd $selected_repository
    echo " $selected_repository "
    commandline -f repaint
  end
end


# key bindings
function fish_user_key_bindings
  # C-r でコマンド履歴を peco 検索
  bind \cr peco_select_history
  # C-o で ghq で入れたリポジトリを検索して cd
  bind \co peco_ghq_repository
end

Progate

  • JavaScript (ES5) 1 を完了した。
  • Go 1 を完了した。

わかったこと(Fact)

参考文献(References)

その他