Adding special case when the command launched is in another directory

This commit is contained in:
Michele Renda 2017-04-06 10:44:07 +03:00
parent 626e54825c
commit 606ea84e60

View File

@ -15,16 +15,17 @@
nohup-command-line() { nohup-command-line() {
[[ -z $BUFFER ]] && zle up-history [[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == nohup\ * ]]; then if [[ $BUFFER == nohup\ * ]]; then
LBUFFER="${LBUFFER#nohup }" BUFFER="${BUFFER#nohup }"
LBUFFER="${LBUFFER%\ &\>*}" BUFFER="${BUFFER%\ &\>*}"
else else
tokens=("${(@s/ /)LBUFFER}") tokens_slash=("${(@s|/|)BUFFER}")
tokens_space=("${(@s/ /)tokens_slash[-1]}")
i=1 i=1
if [[ $tokens[1] == sudo ]]; then if [[ $tokens_slash[1] == sudo ]]; then
(( i++ )) (( i++ ))
fi fi
LBUFFER="nohup $LBUFFER &> $tokens[$i].out &" BUFFER="nohup $BUFFER &> $tokens_space[$i].out &"
fi fi
} }
zle -N nohup-command-line zle -N nohup-command-line