]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/thefuck/thefuck.plugin.zsh
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / thefuck / thefuck.plugin.zsh
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
7 # Register alias
8 [[ ! -a $ZSH_CACHE_DIR/thefuck ]] && thefuck --alias > $ZSH_CACHE_DIR/thefuck
9 source $ZSH_CACHE_DIR/thefuck
10
11 fuck-command-line() {
12     local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
13     [[ -z $FUCK ]] && echo -n -e "\a" && return
14     BUFFER=$FUCK
15     zle end-of-line
16 }
17 zle -N fuck-command-line
18 # Defined shortcut keys: [Esc] [Esc]
19 bindkey -M emacs '\e\e' fuck-command-line
20 bindkey -M vicmd '\e\e' fuck-command-line
21 bindkey -M viins '\e\e' fuck-command-line