From: Frank Terbeck Date: Wed, 3 Mar 2010 12:58:48 +0000 (+0100) Subject: Make our C-z shortcut smarter X-Git-Tag: v0.3.80~4 X-Git-Url: https://git.grml.org/?a=commitdiff_plain;h=744df552df2218541797cff2406144f1d6745f44;hp=ba50de94fa8728459333e95a5019d1cfbf23dd78;p=grml-etc-core.git Make our C-z shortcut smarter --- 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() {