From c58139218aef580d8e1206d52f071ed9fdd1f986 Mon Sep 17 00:00:00 2001 From: Michele Renda Date: Thu, 6 Apr 2017 10:02:28 +0300 Subject: [PATCH] Adding plugin nohup --- plugins/nohup/README.md | 10 ++++++++++ plugins/nohup/nohup.plugin.zsh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 plugins/nohup/README.md create mode 100644 plugins/nohup/nohup.plugin.zsh diff --git a/plugins/nohup/README.md b/plugins/nohup/README.md new file mode 100644 index 00000000..e56b7d6b --- /dev/null +++ b/plugins/nohup/README.md @@ -0,0 +1,10 @@ +## bbedit + +Plugin to prefix the current command with `nohup` using the `Ctrl+H` shortcut + + +### Usage + + * If them corrent termina line is `test 1 2 3` it will be transformed to `nohup test 1 2 3 &> test.out` and vice-versa + + * If no command is existing, the last submitted command will be recalled diff --git a/plugins/nohup/nohup.plugin.zsh b/plugins/nohup/nohup.plugin.zsh new file mode 100644 index 00000000..4cc032bf --- /dev/null +++ b/plugins/nohup/nohup.plugin.zsh @@ -0,0 +1,32 @@ +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# nohup will be inserted before the command and a redirect will be appended +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Michele Renda +# +# ------------------------------------------------------------------------------ + +nohup-command-line() { + [[ -z $BUFFER ]] && zle up-history + if [[ $BUFFER == nohup\ * ]]; then + LBUFFER="${LBUFFER#nohup }" + LBUFFER="${LBUFFER%\ &\>*}" + else + tokens=("${(@s/ /)LBUFFER}") + i=1 + if [[ $tokens[1] == sudo ]]; then + (( i++ )) + fi + + LBUFFER="nohup $LBUFFER &> $tokens[$i].out &" + fi +} +zle -N nohup-command-line +# Defined shortcut keys: [Ctrl] [h] +bindkey "\Ch" nohup-command-line