summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2015-08-30 09:12:07 -0700
committerRobby Russell <robby@planetargon.com>2015-08-30 09:12:07 -0700
commita7aed69d02e204f4b724c73f1dfbce41edd9ea5d (patch)
treeaabd1192873ee5360329c8d4bfa337afd38c1a4e
parentb1d57fad0da8f6029f0e4e512a61a9f4213941df (diff)
parentfb8c446ea4317c391321a29dc97677bc6fdeb0cf (diff)
downloadzsh-a7aed69d02e204f4b724c73f1dfbce41edd9ea5d.tar.gz
zsh-a7aed69d02e204f4b724c73f1dfbce41edd9ea5d.tar.bz2
zsh-a7aed69d02e204f4b724c73f1dfbce41edd9ea5d.zip
Merge pull request #4170 from black-roland/master
The Fuck plugin (https://github.com/nvbn/thefuck)
-rw-r--r--plugins/thefuck/README.md9
-rw-r--r--plugins/thefuck/thefuck.plugin.zsh17
2 files changed, 26 insertions, 0 deletions
diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
new file mode 100644
index 000000000..a9b7550d7
--- /dev/null
+++ b/plugins/thefuck/README.md
@@ -0,0 +1,9 @@
+# The Fuck
+
+[The Fuck](https://github.com/nvbn/thefuck) plugin — magnificent app which corrects your previous console command.
+
+## Usage
+Press `ESC` twice to correct previous console command.
+
+## Notes
+`Esc`-`Esc` key binding conflicts with [sudo](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/sudo) plugin.
diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
new file mode 100644
index 000000000..8b1746e85
--- /dev/null
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -0,0 +1,17 @@
+if [[ -z $commands[thefuck] ]]; then
+ echo 'thefuck is not installed, you should "pip install thefuck" first'
+ return -1
+fi
+
+# Register alias
+eval "$(thefuck-alias)"
+
+fuck-command-line() {
+ local FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
+ [[ -z $FUCK ]] && echo -n -e "\a" && return
+ BUFFER=$FUCK
+ zle end-of-line
+}
+zle -N fuck-command-line
+# Defined shortcut keys: [Esc] [Esc]
+bindkey "\e\e" fuck-command-line