thefuck.plugin.zsh 655 B

1234567891011121314151617181920
  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 -M emacs '\e\e' fuck-command-line
  17. bindkey -M vicmd '\e\e' fuck-command-line
  18. bindkey -M viins '\e\e' fuck-command-line