mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-15 04:41:19 +02:00
Adding plugin nohup
This commit is contained in:
parent
66bae5a5de
commit
c58139218a
2 changed files with 42 additions and 0 deletions
32
plugins/nohup/nohup.plugin.zsh
Normal file
32
plugins/nohup/nohup.plugin.zsh
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue