thefuck.plugin.zsh 562 B

123456789101112131415161718
  1. if [[ -z $commands[thefuck] ]]; then
  2. echo 'thefuck is not installed, you should "pip install thefuck" or "brew install thefuck" first.'
  3. echo 'See https://github.com/nvbn/thefuck#installation'
  4. return 1
  5. fi
  6. # Register alias
  7. eval "$(thefuck --alias)"
  8. fuck-command-line() {
  9. local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
  10. [[ -z $FUCK ]] && echo -n -e "\a" && return
  11. BUFFER=$FUCK
  12. zle end-of-line
  13. }
  14. zle -N fuck-command-line
  15. # Defined shortcut keys: [Esc] [Esc]
  16. bindkey "\e\e" fuck-command-line