From 7a13a407e92dc6780355f67018bb03da81a73b8f Mon Sep 17 00:00:00 2001
From: Roland Chernov <mail@9241406380.org>
Date: Sat, 18 Jul 2015 21:10:56 +0900
Subject: [PATCH 1/9] Added thefuck plugin https://github.com/nvbn/thefuck

---
 plugins/thefuck/thefuck.plugin.zsh | 9 +++++++++
 1 file changed, 9 insertions(+)
 create mode 100644 plugins/thefuck/thefuck.plugin.zsh

diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
new file mode 100644
index 000000000..81461d48e
--- /dev/null
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -0,0 +1,9 @@
+fuck-command-line() {
+    FUCK=$(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

From cd2213a0304e7f0b8fdfbb02be96f57042e2744a Mon Sep 17 00:00:00 2001
From: Roland Chernov <mail@9241406380.org>
Date: Sat, 18 Jul 2015 21:17:51 +0900
Subject: [PATCH 2/9] Thefuck plugin README

---
 plugins/thefuck/README.md | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 plugins/thefuck/README.md

diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
new file mode 100644
index 000000000..981b5513e
--- /dev/null
+++ b/plugins/thefuck/README.md
@@ -0,0 +1,6 @@
+# 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.

From e38455bf4f9b247d3e51298d39d18a90a7294438 Mon Sep 17 00:00:00 2001
From: Roland Chernov <mail@9241406380.org>
Date: Sun, 19 Jul 2015 12:57:50 +0900
Subject: [PATCH 3/9] Added conflict note (thefuck plugin)

---
 plugins/thefuck/README.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/plugins/thefuck/README.md b/plugins/thefuck/README.md
index 981b5513e..a9b7550d7 100644
--- a/plugins/thefuck/README.md
+++ b/plugins/thefuck/README.md
@@ -4,3 +4,6 @@
 
 ## 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.

From 0da9a4be25d0feb968b21645a0654ea499f0cc9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cristian=20M=C4=83gheru=C8=99an-Stanciu?=
 <cristian.magherusan-stanciu@here.com>
Date: Wed, 6 May 2015 18:40:03 +0200
Subject: [PATCH 4/9] fuck: added a basic plugin for
 https://github.com/nvbn/thefuck

---
 plugins/fuck/fuck.plugin.zsh | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 plugins/fuck/fuck.plugin.zsh

diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh
new file mode 100644
index 000000000..1a3b474fc
--- /dev/null
+++ b/plugins/fuck/fuck.plugin.zsh
@@ -0,0 +1,6 @@
+if [ $commands[thefuck] ]; then
+  alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R'
+  alias FUCK='fuck'
+else
+  echo 'thefuck is not installed, you should "pip install thefuck" first'
+fi

From 803e5dbb8464088a8d84509077bf6dce9ac26688 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cristian=20M=C4=83gheru=C8=99an-Stanciu?=
 <cristian.magherusan-stanciu@here.com>
Date: Thu, 9 Jul 2015 17:41:43 +0200
Subject: [PATCH 5/9] improved the check for availability

---
 plugins/fuck/fuck.plugin.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh
index 1a3b474fc..cbf8c09ce 100644
--- a/plugins/fuck/fuck.plugin.zsh
+++ b/plugins/fuck/fuck.plugin.zsh
@@ -1,4 +1,4 @@
-if [ $commands[thefuck] ]; then
+if [[ -n $commands[thefuck] ]]; then
   alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R'
   alias FUCK='fuck'
 else

From 8e8a13398e71b969dc39189c0fedcc4733a911df Mon Sep 17 00:00:00 2001
From: Black Roland <black-roland@github.com>
Date: Wed, 22 Jul 2015 17:20:52 +0900
Subject: [PATCH 6/9] Thefuck: combined with @cristim plugin. Code formating

---
 plugins/fuck/fuck.plugin.zsh       |  6 ------
 plugins/thefuck/thefuck.plugin.zsh | 12 ++++++++++--
 2 files changed, 10 insertions(+), 8 deletions(-)
 delete mode 100644 plugins/fuck/fuck.plugin.zsh

diff --git a/plugins/fuck/fuck.plugin.zsh b/plugins/fuck/fuck.plugin.zsh
deleted file mode 100644
index cbf8c09ce..000000000
--- a/plugins/fuck/fuck.plugin.zsh
+++ /dev/null
@@ -1,6 +0,0 @@
-if [[ -n $commands[thefuck] ]]; then
-  alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R'
-  alias FUCK='fuck'
-else
-  echo 'thefuck is not installed, you should "pip install thefuck" first'
-fi
diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
index 81461d48e..86ec9901b 100644
--- a/plugins/thefuck/thefuck.plugin.zsh
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -1,6 +1,14 @@
+if [[ -z $commands[thefuck] ]]; then
+    echo 'thefuck is not installed, you should "pip install thefuck" first'
+    return -1
+fi
+
+alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R'
+alias FUCK='fuck'
+
 fuck-command-line() {
-    FUCK=$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)
-    [ -z $FUCK ] && echo -n -e "\a" && return
+    FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
+    [[ -z $FUCK ]] && echo -n -e "\a" && return
     BUFFER=$FUCK
     zle end-of-line
 }

From 54e27406dcc2fea55432595f9ec01502da8e4468 Mon Sep 17 00:00:00 2001
From: Roland Chernov <mail@9241406380.org>
Date: Thu, 23 Jul 2015 20:10:31 +0900
Subject: [PATCH 7/9] Thefuck: replaced static alias with `eval
 "$(thefuck-alias)"`

---
 plugins/thefuck/thefuck.plugin.zsh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
index 86ec9901b..10467d337 100644
--- a/plugins/thefuck/thefuck.plugin.zsh
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -3,8 +3,8 @@ if [[ -z $commands[thefuck] ]]; then
     return -1
 fi
 
-alias fuck='eval $(thefuck $(fc -ln -1 | tail -n 1)); fc -R'
-alias FUCK='fuck'
+# Register alias
+eval "$(thefuck-alias)"
 
 fuck-command-line() {
     FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"

From f534b4b321d5db4b3d42d3e2cf1f2b2af5bd3c64 Mon Sep 17 00:00:00 2001
From: Roland Chernov <mail@9241406380.org>
Date: Thu, 23 Jul 2015 20:54:51 +0900
Subject: [PATCH 8/9] Thefuck: fixed compability with latest version

---
 plugins/thefuck/thefuck.plugin.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
index 10467d337..739bb0b9a 100644
--- a/plugins/thefuck/thefuck.plugin.zsh
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -7,7 +7,7 @@ fi
 eval "$(thefuck-alias)"
 
 fuck-command-line() {
-    FUCK="$(thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
+    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

From fb8c446ea4317c391321a29dc97677bc6fdeb0cf Mon Sep 17 00:00:00 2001
From: Roland Chernov <mail@9241406380.org>
Date: Thu, 30 Jul 2015 21:04:58 +0900
Subject: [PATCH 9/9] Thefuck: fix global variable assignment

---
 plugins/thefuck/thefuck.plugin.zsh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/plugins/thefuck/thefuck.plugin.zsh b/plugins/thefuck/thefuck.plugin.zsh
index 739bb0b9a..8b1746e85 100644
--- a/plugins/thefuck/thefuck.plugin.zsh
+++ b/plugins/thefuck/thefuck.plugin.zsh
@@ -7,7 +7,7 @@ fi
 eval "$(thefuck-alias)"
 
 fuck-command-line() {
-    FUCK="$(THEFUCK_REQUIRE_CONFIRMATION=0 thefuck $(fc -ln -1 | tail -n 1) 2> /dev/null)"
+    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