How do I get Bash to automatically bg graphical programs without the &?
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How do I get Bash to automatically bg graphical programs without the &?
This isn't precisely a Linux question more a Bash question. I've searched around on the internet and looked at Bash guides etc but nothing seems to have the info I need. So if someone can help please do.
I've noticed that on some distros (and other Unix's) when you run a program from an xterm, which will open in separate window, Bash will automatically background the process. For example if I run 'gvim' then it will open gvim (in using it's gui) but the command prompt (in the xterm) will still come back to the prompt for the next command. And it does this for all graphical programs. So I could just type 'gvim' instead of 'gvim &' or just 'netscape' etc etc.
Basically I'm lazy so I'm wondering if there is a way so that I don't have to type the '&' after everything. I know I can put in my bashrc a function for each program like:
function programname { command programname "$@" & }
but that requires me to do it for every single program that might launch a new window. Isn't there a way so that if a new window is launched then it automatically will background the process in the term?
>> I've modified this to make it easier to understand if anyone was getting confused.
Last edited by kindredstar; 10-07-2004 at 09:37 AM.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
I may be wrong here (Gurus please correct) but I think this is a programmed feature of the applications you run, i.e. these contain in their sources a fork() statement or some such which detaches the executable automatically from the starting process.
Well it's not just that I'm lazy.. perhaps forgetful also.. so if I run a program and forget to put the & then it can cause problems. Some programs don't let you input into them if you background them after they've started via a ctrl-z. I just know that when I was at uni we never had to type the & on Solaris. And my friend said that he thinks that he never has to also on his Fedora machine. So there must be a setting somewhere.. perhaps a list of programs in a config file or something. Or it could just be as JZL240I-U said and it has been compiled into some programs to do that.
If someone else could try out running programs without the & and telling me what the results are with different programs on different distros then we might be able to work this out
Last edited by kindredstar; 10-07-2004 at 11:07 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.