50
51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pecoをインストールして、zshのhistoryを軽快に検索

Last updated at Posted at 2014-07-02

Goのインストール

何も考えずに、homebrewからインストール

% brew install go

.zshenvにでも、GOPATHとPATHを設定しておく。

.zshenv
# go path
export GOPATH=~/go
export PATH=$PATH:$GOPATH/bin

~/goとか突然出てきて何者?って思うかも知れないですが、次のpecoのインストール時に必要になりますので、おまじないだと思って書いておいて下さい。
変更内容を読み込んでおいて下さい。

% source .zshenv

pecoのインストール

% go get github.com/lestrrat/peco/cmd/peco/

これで、pecoのインストールは完了

pecoでhistory検索してくれるように

以下の様に、.zshrcに追加

.zshrc
function peco-select-history() {
    local tac
    if which tac > /dev/null; then
        tac="tac"
    else
        tac="tail -r"
    fi
    BUFFER=$(\history -n 1 | \
        eval $tac | \
        peco --query "$LBUFFER")
    CURSOR=$#BUFFER
    zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history

読込直す

% source .zshrc

historyの検索

Ctrl+rで検索出来る様になってる!

sample

50
51
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
50
51

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?