🍭
(今さらながら)pecoを使って効率化
$ brew install peco
履歴から検索してコマンド実行
~/.zshrc
function h() {
local selected_command=$(fc -l -n 1 | tail -300 | awk '!seen[$0]++' | tac | peco --prompt "HISTORY>")
if [ -n "$selected_command" ]; then
print -s "$selected_command"
echo "Executing: $selected_command"
eval "$selected_command"
fi
}
※ tacコマンドが使えない場合にはbrew install coreutils
を実行。
履歴から検索してディレクトリ移動
~/.zshrc
function c() {
local dir=$(dirs -v | awk '!seen[$2]++' | peco | awk '{print $2}')
if [ -n "$dir" ]; then
dir=${dir/#\~/$HOME}
cd "$dir"
fi
}
DIRSTACKSIZE=100
setopt AUTO_PUSHD
setopt PUSHD_IGNORE_DUPS
Discussion