Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Background any command, and then exit, using bash
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Sun Jun 20, 2010 9:08 pm    Post subject: Background any command, and then exit, using bash Reply with quote

Hi there

Is there a way to get bash to automatically put every command issued to it in the background, and then get bash to exit?

e.g. I want to type "gftp", have gftp open, and then have bash (and xterm) exit, leaving gftp running.

Specifically I am trying to create a "Run" dialogue using bash and xterm. I have a small xterm window with no prompt text. I want to simply type a command in there, have it run and stay running, while the xterm window closes.

Appending every command with "& exit" does exactly what I want. Perhaps the easiest way to achieve what I want would be to find some mechanism for that to happen automatically - although I wouldn't want to ruin bash's history, as that's a big part of why I wanted to create a new "Run" dialogue in the first place.

Thanks
Luke
Back to top
View user's profile Send private message
marens
Apprentice
Apprentice


Joined: 05 Aug 2004
Posts: 173

PostPosted: Sun Jun 20, 2010 9:43 pm    Post subject: Reply with quote

Code:
HISTIGNORE=spanwAndExit*

function spawnAndExit() {
  nohup $@ >> /dev/null &
  exit
}

spawnAndExit gedit /home/l_bratch/file


check gmrun or dmenu for really simple application launchers
_________________
If English was good enough for Jesus, then it's good enough for you!
Back to top
View user's profile Send private message
joshuar
n00b
n00b


Joined: 17 Dec 2008
Posts: 3

PostPosted: Sun Jun 20, 2010 9:59 pm    Post subject: Reply with quote

You can use a sub-shell:

Code:
(/some/command/to/run &); exit


See also:

http://tldp.org/LDP/abs/html/subshells.html
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Sun Jun 20, 2010 11:28 pm    Post subject: Reply with quote

Thank you both. dmenu looks so fantastic that after a couple of hours playing, I'm very happy with it for my purposes.
Back to top
View user's profile Send private message
Yamakuzure
Advocate
Advocate


Joined: 21 Jun 2006
Posts: 2284
Location: Adendorf, Germany

PostPosted: Tue Jun 22, 2010 1:20 pm    Post subject: Reply with quote

Or maybe you want to take a look at app-misc/screen ;)
_________________
Important German:
  1. "Aha" - German reaction to pretend that you are really interested while giving no f*ck.
  2. "Tja" - German reaction to the apocalypse, nuclear war, an alien invasion or no bread in the house.
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Tue Jun 22, 2010 2:46 pm    Post subject: Reply with quote

dmenu is perfect, however, if only for the sake of learning (and since it's related to your original question) you might want to take a look at this thread:

https://forums.gentoo.org/viewtopic-t-510774-highlight-urxvt+launcher.html
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum