Guest User

Untitled

a guest
Jan 16th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. # peco
  2. export HISTCONTROL="ignoredups"
  3. peco-history() {
  4. local NUM=$(history | wc -l)
  5. local FIRST=$((-1*(NUM-1)))
  6.  
  7. if [ $FIRST -eq 0 ] ; then
  8. history -d $((HISTCMD-1))
  9. echo "No history" >&2
  10. return
  11. fi
  12.  
  13. 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)
  14.  
  15. if [ -n "$CMD" ] ; then
  16. history -s $CMD
  17.  
  18. if type osascript > /dev/null 2>&1 ; then
  19. (osascript -e 'tell application "System Events" to keystroke (ASCII character 30)' &)
  20. fi
  21. else
  22. history -d $((HISTCMD-1))
  23. fi
  24. }
  25. bind -x '"\C-r":peco-history'
  26.  
  27. # ctrl+fで次の単語に移動
  28. bind '"\C-f": forward-word'
  29. # ctrl+bで前の単語に移動
  30. bind '"\C-b": backward-word'
Add Comment
Please, Sign In to add comment