forked from micrenda/zsh-nohup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nohup.plugin.zsh
31 lines (29 loc) · 886 Bytes
/
nohup.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# ------------------------------------------------------------------------------
# Description
# -----------
#
# nohup will be inserted before the command and a redirect will be appended
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Michele Renda <[email protected]>
#
# ------------------------------------------------------------------------------
nohup-command-line() {
[[ -z $BUFFER ]] && zle up-history
if [[ $BUFFER == nohup\ * ]]; then
BUFFER="${BUFFER#nohup }"
BUFFER="${BUFFER%\ &\>*}"
else
base="${BUFFER#sudo }"
tokens_slash=("${(@s|/|)base}")
tokens_space=("${(@s/ /)tokens_slash[-1]}")
command=("$tokens_space[1]")
BUFFER="nohup $BUFFER > /dev/null 2>&1 &!"
fi
}
zle -N nohup-command-line
# Defined shortcut keys: [Ctrl] [h]
bindkey "\Ch" nohup-command-line