db145388533ba635f8b5bf8727a69434a6a8734f

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4315 from mbologna/fancy-ctrl-z

Added Fancy-ctrl-z plugin

Diff

 1diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md
 2new file mode 100644
 3index 0000000000000000000000000000000000000000..a7670fa2c2d9a21ea1c5aeeeb06ed07c6ece2988
 4--- /dev/null
 5+++ b/plugins/fancy-ctrl-z/README.md
 6@@ -0,0 +1,14 @@
 7+# Use Ctrl-Z to switch back to Vim
 8+
 9+I frequently need to execute random command in my shell. To achieve it I pause 
10+Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
11+The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back 
12+to Vim. I could not find a solution, so I developed one on my own that 
13+works wonderfully with ZSH
14+
15+Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
16+
17+Credits: 
18+- original idea by @sheerun
19+- added to OMZ by @mbologna
20+
21diff --git a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
22new file mode 100644
23index 0000000000000000000000000000000000000000..8ab2979133efda46a4ce1990f4d159da69d603e6
24--- /dev/null
25+++ b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
26@@ -0,0 +1,12 @@
27+fancy-ctrl-z () {
28+  if [[ $#BUFFER -eq 0 ]]; then
29+    BUFFER="fg"
30+    zle accept-line
31+  else
32+    zle push-input
33+    zle clear-screen
34+  fi
35+}
36+zle -N fancy-ctrl-z
37+bindkey '^Z' fancy-ctrl-z
38+