1
1

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.

コマンドヒストリーの検索を手軽にしたい

Last updated at Posted at 2019-07-19

自分の環境構築用メモ。

$ histry

してからの
ctrl+r
でもいいんだけど
ctrl+r
だけで検索したいなっていうあれ。

pecoをinstall

macでbrewはいってる前提です。

$ brew install peco

.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

して反映。

ctrl+r

でコマンドヒストリー検索だ!

1
1
0

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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?