thefuck.plugin.zsh 655 Bytes
Newer Older
1
if [[ -z $commands[thefuck] ]]; then
2
3
4
    echo 'thefuck is not installed, you should "pip install thefuck" or "brew install thefuck" first.'
    echo 'See https://github.com/nvbn/thefuck#installation'
    return 1
5
6
fi

7
# Register alias
kyleheyne's avatar
kyleheyne committed
8
eval "$(thefuck --alias)"
9

10
fuck-command-line() {
11
    local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
12
    [[ -z $FUCK ]] && echo -n -e "\a" && return
13
14
15
16
17
    BUFFER=$FUCK
    zle end-of-line
}
zle -N fuck-command-line
# Defined shortcut keys: [Esc] [Esc]
18
19
20
bindkey -M emacs '\e\e' fuck-command-line
bindkey -M vicmd '\e\e' fuck-command-line
bindkey -M viins '\e\e' fuck-command-line