a7aed69d02e204f4b724c73f1dfbce41edd9ea5d
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #4170 from black-roland/master
The Fuck plugin (https://github.com/nvbn/thefuck)
Diff
1diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..a9b7550d7f3e88dfc6ac2b6acb2b2febb21a9350
4--- /dev/null
5+++ b/plugins/thefuck/README.md
6@@ -0,0 +1,9 @@
7+# The Fuck
8+
9+[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
10+
11+## Usage
12+Press `ESC` twice to correct previous console command.
13+
14+## Notes
15+`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin.
16diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
17new file mode 100644
18index 0000000000000000000000000000000000000000..8b1746e85494bea866b21aca4dd12539e8e23e23
19--- /dev/null
20+++ b/plugins/thefuck/thefuck.plugin.zsh
21@@ -0,0 +1,17 @@
22+if [[ -z $commands[thefuck] ]]; then
23+ echo 'thefuck is not installed, you should "pip install thefuck" first'
24+ return -1
25+fi
26+
27+# Register alias
28+eval "$(thefuck-alias)"
29+
30+fuck-command-line() {
31+ local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
32+ [[ -z $FUCK ]] && echo -n -e "\a" && return
33+ BUFFER=$FUCK
34+ zle end-of-line
35+}
36+zle -N fuck-command-line
37+# Defined shortcut keys: [Esc] [Esc]
38+bindkey "\e\e" fuck-command-line