mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-08 04:34:00 +02:00
Adding plugin nohup
This commit is contained in:
parent
66bae5a5de
commit
c58139218a
2 changed files with 42 additions and 0 deletions
10
plugins/nohup/README.md
Normal file
10
plugins/nohup/README.md
Normal 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
|
||||||
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