fancy-ctrl-z.plugin.zsh 651 B

123456789101112131415161718192021
  1. # Use Ctrl-Z to switch back to Vim
  2. # I frequently need to execute random command in my shell. To achieve it I pause
  3. # Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
  4. # The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back
  5. # to Vim. I could not find a solution, so I developed one on my own that
  6. # works wonderfully with ZSH
  7. #
  8. # Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
  9. fancy-ctrl-z () {
  10. if [[ $#BUFFER -eq 0 ]]; then
  11. BUFFER="fg"
  12. zle accept-line
  13. else
  14. zle push-input
  15. zle clear-screen
  16. fi
  17. }
  18. zle -N fancy-ctrl-z
  19. bindkey '^Z' fancy-ctrl-z