LoginSignup
3
3

More than 5 years have passed since last update.

私のpecoコマンド履歴検索

Posted at

zshで動きます。

#-----------------------------------------#
# hs: inc search in command history
#-----------------------------------------#
function peco-history-selection() {
    print -z `\history -n 1 | tail -r | peco --prompt "[hs]"`
    CURSOR=$#BUFFER
}
alias hs="peco-history-selection"

こだわっている点

キーをトリガーにしない

ネットではC-rとかのキーをトリガーにしているものがありますが、キーバインドの枯渇やmnemonicを考慮してhsのエイリアスコマンドにしている。

そのまま実行しない

過去のコマンドの一部を変更して実行するのはよくあることなので、pecoで選択したときに実行せずに入力部分に表示した状態にする。

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