You are not logged in.

#1 2013-02-11 18:07:58

axper
Member
Registered: 2013-01-25
Posts: 115

[Solved] Launch GUI application and detach it from terminal

Hello, I find it convenient launching apps from terminal, but after that I am unable to use the terminal, since it it's "attached" to the process. Some searching revealed 2 methods of doing this, but they both don't work for me

1) add "&" after the command: upon closing the terminal the application closes as well; not what I want
2) press ctrl+z: this just closes the app

So how do I type a command to launch a GUI app and continue using the terminal?
I am using mate-terminal.

Last edited by axper (2013-02-11 19:14:08)

Offline

#2 2013-02-11 18:11:01

oliver
Member
Registered: 2007-12-12
Posts: 448

Re: [Solved] Launch GUI application and detach it from terminal

just a small point, but ctrl-z doesn't close the app, it suspends it.  You can background it with 'bg' but it's the same (I think) as just launching it with an & to begin with

Offline

#3 2013-02-11 18:13:09

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: [Solved] Launch GUI application and detach it from terminal

'nohup' command from coreutils might be what you are looking for. Or in case of zsh, doing it like this:

guiapp &|

There was a thread about this recently, there were more ways to do it.

Last edited by kaszak696 (2013-02-11 18:15:53)


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#4 2013-02-11 18:43:19

axper
Member
Registered: 2013-01-25
Posts: 115

Re: [Solved] Launch GUI application and detach it from terminal

Thanks for answers.

"nohup appname &" worked.. kinda, but it creates "nohup.out" file in my home dir, which is kinda messy smile

Also some programs close when terminal is closed, like pcmanfm

nohup pcmanfm &

And I can't use tab-completion, which isn't good smile

"guiapp &|" didn't work, since I use bash (I think?)

Offline

#5 2013-02-11 18:51:54

kaszak696
Member
Registered: 2009-05-26
Posts: 543

Re: [Solved] Launch GUI application and detach it from terminal


'What can be asserted without evidence can also be dismissed without evidence.' - Christopher Hitchens
'There's no such thing as addiction, there's only things that you enjoy doing more than life.' - Doug Stanhope
GitHub Junkyard

Offline

#6 2013-02-11 19:13:36

axper
Member
Registered: 2013-01-25
Posts: 115

Re: [Solved] Launch GUI application and detach it from terminal

Thanks a lot, this is exactly what I wanted (for Bash):

olive wrote:

You can disown them (man bash). I have put

PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'disown -a -h'

in my ~/.bashrc with the effect that if you launch a program in the background (with &). It will not be stopped when you close the terminal.


For Zsh, put this in your .zshrc

precmd_disown() {
  emulate -L zsh
  setopt extendedglob
  local job match mbegin mend

  jobs | while read job; do
    if [[ $job = \[(#b)([[:digit:]]##)\]*running* ]]; then
      disown %$match[1]
    fi
  done
}
autoload -U add-zsh-hook
add-zsh-hook precmd precmd_disown

(from http://www.zsh.org/mla/users/2010/msg00654.html)

Last edited by axper (2013-06-29 07:47:21)

Offline

Board footer

Powered by FluxBB