pecoを使おう2. 自己紹介
名前: 三宅 英明
Twitter: @mollifier
はてなID: mollifier
神戸のプログラマ
34. pecoで使う関数を作る
一応これでもできる
function peco-execute-history() {
local item
item=$(builtin history -n -r 1 | peco)
if [[ -z "$item" ]]; then
return 1
fi
eval "$item"
}
alias eh=peco-execute-history
36. pecoで使う関数を作る
Ctrl+x Ctrl+rで実行する例
何かのキーバインドで関数を呼び出す
ときはこう書く
function peco-execute-history() {
# この中に処理を書く
}
zle -N peco-execute-history
bindkey '^x^r' peco-execute-history
37. pecoで使う関数を作る
Ctrl+x Ctrl+rで実行する例
function peco-execute-history() {
local item
item=$(builtin history -n -r 1 | peco)
if [[ -z "$item" ]]; then
return 1
fi
BUFFER="$item"
zle accept-line
}
zle -N peco-execute-history
bindkey '^x^r' peco-execute-history
43. pecoで使う関数を作る
さっきと同じだけど、コマンドラインに
代入するだけの例
function peco-put-history() {
local item
item=$(builtin history -n -r 1 | peco)
if [[ -z "$item" ]]; then
return 1
fi
BUFFER="$item"
CURSOR=$#BUFFER
}
zle -N peco-put-history
bindkey '^x^p' peco-put-history