[zsh] Dear lazyweb
February 3, 2010
I’ve recently been looking for a simple way to launch a program from the CLI in such a way that it is totally detached from the shell, i.e. it is launched in the background and is not connected to the shell’s console. Currently, I’m using the following zsh alias:
alias -g "\&"="&>/dev/null&|"
Now I can launch apps totally detached by writing:
inkscape picture.svg \&
The advantage is that the extra syntax is quite short, and that I can add it after having typed in the whole command (which is a clear convience plus compared to, for instance, prepending “kdeinit4_wrapper”). Still, it has some problems, like that omitting the space before the “\&” won’t work. (zsh will think that I’m looking for the executable “inkscape&”.) Also, bash does not know global aliases AFAIK. Do you know an easier way for me to do what I want?
[b]Update:[/b] Exchanged the trailing “&” for “&|” which, as MathStuf noted in the comments, disowns the process, thereby working around the annoying “You have stopped jobs.” message that appears when you ^D the shell for the first time. Thanks for the hint!
February 3, 2010 at 14:58
I use the following alias:
alias -g SAD=’&> /dev/null &|’
SAD stands for “shut up and die” or, more accurately, “shut up and disown”. &| is shorthand for “background and disown”. It does most of the magic work, the redirect is just to keep it quiet.
February 3, 2010 at 15:40
Does it have to be a zsh alias? If not, have a look at the daemon(8) app, which was written for just this purpose.
February 3, 2010 at 22:16
I use kshell4.
kshell4 program
February 3, 2010 at 22:22
do to a complete job should be standard input redirected too?
/bin/ls &>/dev/null </dev/null &|
February 4, 2010 at 15:01
The “&” (or “&|”, respectively) will already detach the process from the shell’s stdin.
February 3, 2010 at 23:08
You should look at the nohup command.
February 4, 2010 at 09:38
have you heard about ‘screen’ ?
February 4, 2010 at 15:02
Yes, but it’s too tedious IMO to start a new screen session just for some GUI process. I want to keep my “screen -ls” clean because I’m regularly using screen e.g. for my mplayer instance.
February 4, 2010 at 12:36
I was missing this from time to time. And am using zsh, so thanks.