From 744df552df2218541797cff2406144f1d6745f44 Mon Sep 17 00:00:00 2001 From: Frank Terbeck Date: Wed, 3 Mar 2010 13:58:48 +0100 Subject: [PATCH] Make our C-z shortcut smarter --- etc/zsh/zshrc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index f07fb67..4178304 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -912,8 +912,19 @@ zle -N insert-last-typed-word; #k# Insert last typed word bindkey "\em" insert-last-typed-word -#k# Shortcut for \kbd{fg} -bindkey -s '^z' "fg\n" +function grml-zsh-fg() { + if (( ${#jobstates} )); then + zle .push-input + [[ -o hist_ignore_space ]] && BUFFER=' ' || BUFFER='' + BUFFER="${BUFFER}fg" + zle .accept-line + else + zle -M 'No background jobs. Doing nothing.' + fi +} +zle -N grml-zsh-fg +#k# A smart shortcut for \kbd{fg} +bindkey '^z' grml-zsh-fg # run command line as user root via sudo: sudo-command-line() { -- 2.1.4