macでpeco
mac peco導入
bashを使っています。
# 環境
mac os Mojave 10.14.5
brew install peco
sudo vi ~/.bash_profile
sudo vi ~/.bashrc
~/.bash_profile
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
~/.bashrc
peco-select-history() {
declare l=$(HISTTIMEFORMAT= history | sort -k1,1nr | perl -ne 'BEGIN { my @lines = (); } s/^\s*\d+\s*//; $in=$_; if (!(grep {$in eq $_} @lines)) { push(@lines, $in); print $in; }' | peco --query "$READLINE_LINE")
READLINE_LINE="$l"
READLINE_POINT=${#l}
}
bind -x '"\C-r": peco-select-history'
上ではうまく貼り付かないので
ここを参照
https://qiita.com/omega999/items/8717c1b9d8bc10596d67
###peco
export HISTCONTROL="ignoredups"
peco-history() {
local NUM=$(history | wc -l)
local FIRST=$*1
echo "No history" >&2
return
fi
local CMD=$(fc -l $FIRST | sort -k 2 -k 1nr | uniq -f 1 | sort -nr | sed -E 's/^[0-9]+:blank:+//' | peco | head -n 1)
if [ -n "$CMD" ] ; then
history -s $CMD
if type osascript > /dev/null 2>&1 ; then
(osascript -e 'tell application "System Events" to keystroke (ASCII character 30)' &)
fi
else
history -d $*2
fi
}
bind -x '"\C-r":peco-history'