[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!

Advertisements

9 Responses to “[zsh] Dear lazyweb”

  1. MathStuf Says:

    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.

  2. Freddie Says:

    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.

  3. David Says:

    I use kshell4.

    kshell4 program

  4. Francesco R. Says:

    do to a complete job should be standard input redirected too?
    /bin/ls &>/dev/null </dev/null &|

    • Stefan Majewsky Says:

      The “&” (or “&|”, respectively) will already detach the process from the shell’s stdin.

  5. Stefan Says:

    You should look at the nohup command.

  6. Tom smart Says:

    have you heard about ‘screen’ ?

    • Stefan Majewsky Says:

      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.

  7. Sönke Says:

    I was missing this from time to time. And am using zsh, so thanks.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s