From 606ea84e60b842d61aa19df16cf8552b12c19af6 Mon Sep 17 00:00:00 2001 From: Michele Renda Date: Thu, 6 Apr 2017 10:44:07 +0300 Subject: [PATCH] Adding special case when the command launched is in another directory --- plugins/nohup/nohup.plugin.zsh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/nohup/nohup.plugin.zsh b/plugins/nohup/nohup.plugin.zsh index 4cc032bf..8a4d25bf 100644 --- a/plugins/nohup/nohup.plugin.zsh +++ b/plugins/nohup/nohup.plugin.zsh @@ -15,16 +15,17 @@ nohup-command-line() { [[ -z $BUFFER ]] && zle up-history if [[ $BUFFER == nohup\ * ]]; then - LBUFFER="${LBUFFER#nohup }" - LBUFFER="${LBUFFER%\ &\>*}" + BUFFER="${BUFFER#nohup }" + BUFFER="${BUFFER%\ &\>*}" else - tokens=("${(@s/ /)LBUFFER}") + tokens_slash=("${(@s|/|)BUFFER}") + tokens_space=("${(@s/ /)tokens_slash[-1]}") i=1 - if [[ $tokens[1] == sudo ]]; then + if [[ $tokens_slash[1] == sudo ]]; then (( i++ )) fi - LBUFFER="nohup $LBUFFER &> $tokens[$i].out &" + BUFFER="nohup $BUFFER &> $tokens_space[$i].out &" fi } zle -N nohup-command-line