Adding plugin nohup

This commit is contained in:
Michele Renda 2017-04-06 10:02:28 +03:00
parent 66bae5a5de
commit c58139218a
2 changed files with 42 additions and 0 deletions

10
plugins/nohup/README.md Normal file
View File

@ -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

View File

@ -0,0 +1,32 @@
# ------------------------------------------------------------------------------
# Description
# -----------
#
# nohup will be inserted before the command and a redirect will be appended
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Michele Renda <michele.renda@gmail.com>
#
# ------------------------------------------------------------------------------
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