Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to use the following scenario for my favorite applications under Linux (Ubuntu 10.10) in order to save grabbing the mouse and clicking them:

  1. Open a terminal (Ctrl-Alt-D)
  2. Type my alias for the application (eg: ff for firefox)
  3. Have the application start and the terminal killed immediately, not when I close the application.
  4. Define the dimensions and position of the application using the --geometry parameter from gnome-terminal

For now, I have created the following alias, but it does not behave as described:

alias ff="gnome-terminal --geometry 100x100-0+0 -e 'firefox'; exit"

Instead, it opens a new terminal, kills the first one, and kills the second one upon exiting firefox.

If I try the following instead:

alias ff2="firefox &; exit"

I get the error message:

bash: syntax error near unexpected token `;'

In fact, all these attempts fail:

alias ff="gnome-terminal --geometry 100x100-0+0 -e 'firefox'; exit"
alias ff2="firefox &; exit"
alias ff3="nohup firefox & ; exit"
alias ff4="nohup firefox; exit

How can I obtain the desired behavior?

share|improve this question

migrated from stackoverflow.com Feb 26 '11 at 17:31

This question came from our site for professional and enthusiast programmers.

2  
Are you aware of the & operator and the nohup command? Have you looked at them yet? – S.Lott Feb 24 '11 at 20:18
    
Hi S.Lott. Yes, I know about it. But I did not succeed in obtaining the desired behavior (specifically, killing the terminal) using the '&' operator either. Could it be done that way? – Morlock Feb 24 '11 at 20:22

Actually, this is it:

nohup firefox & 2> /dev/null; exit;

If you want to use an alias, simply do:

alias ff='nohup firefox & 2> /dev/null; exit;'

and watch the magic happen when you execute ff

share|improve this answer
2  
The combination with the redirection of the output/error channels is key here. +1 – 0xC0000022L Feb 24 '11 at 20:55
    
Yes, I would never have thought to use the redirection in that case... Thanks karl! – Morlock Feb 24 '11 at 20:59

It's a SuperUser answer, but are you aware of the Alt-F2 shortcut?

share|improve this answer
    
Are you sure an alias can't execute multiple commands? Try my answer. – karlphillip Feb 24 '11 at 20:59
    
Thanks Tobu, I learn something valuable. – Morlock Feb 24 '11 at 21:00
    
Whoops, I should have been quicker to fact-check. – Tobu Feb 24 '11 at 21:00

nohup command arguments & ; exit

Perhaps you might find it more productive to define keyboard shortcuts in your window manager to simply open the various programs of interest?

share|improve this answer
    
alias ff3="nohup firefox & ; exit" gives me the same error as for my ff2 attempt. Removing the & does not work either... sorry. – Morlock Feb 24 '11 at 20:44
1  
My answer is not a usage of the alias command, which is what introduces that problem. – Chris Stratton Feb 24 '11 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .