I recently installed 12.04.
When I try to edit a file with gedit, I can't use the terminal until I close the editing file or I have to open a new terminal. But I think I didn't have this problem with 11.04, however I'm not sure.
Is there anyway to avoid this and to use same terminal while editing files.
Short Answer
In the unresponsive terminal:
bg
and enter.disown
and enter.Long Answer
In the unresponsive terminal, hit Ctrl+Z, this will "pause" the process (or "job") and return the console control to you. However, you'll notice that
gedit
becomes unresponsive and you can't use it.To make the job successfully run in the background (i.e. to make
gedit
responsive again), execute the commandbg
(meaning background). You'll now be able to usegedit
, and at the same time have the prompt to yourself.You can overcome all of this from the very beginning. When you're launching
gedit
from the terminal, add an&
to the end of the command, so something like thisgedit /path/to/file &
. This will launchgedit
in the background from the first place (you might need to hit Enter a couple of times to get the console control back).Once you get used to this system, you might notice that if you close the terminal, gedit will also terminate, without even a confirmation dialog. To prevent this from happening, run
disown
, which will detach the gedit process from the terminal, removing it from the list returned byjobs
.Just type:
gedit <filename-to-edit> &
This will immediately return the command prompt to you.
You could use the
nohup
to prevent the GUI to be attached to a terminal:This will allow you to close the terminal you are launching from, without the program being closed.
You should also notice, that the nohup command will create a file with the
stdout
andstderr
of the command you run. If you want to prevent that, add&>/dev/null
before the&
.You can also use
disown
command. It is particularly useful when you've already started the process you no longer want attached to the terminal.The basic procedure if I remember correctly, is something like this:
Note that disown is
bash
specific.This blog post explains both methods pretty well.
Man page for disown
From
man gedit
:So, if you run
gedit
with-b
option, it will start in background:Moreover, next you can create an alias for
gedit -b
(see here how to create a permanent alias):From now, in the future you can use
gedit [FILE-NAME]
as normal and it will start in background.Just type:
Ending a command with
&
in bash runs that command in the background. However, that process is still attached to the terminal.WithoutTurns out I was wrong, this is not the case for bash, but it is the case for zsh. You still need to rundisown
, if you close the terminal, gedit will close, without even prompting you to save an edited file.disown
detaches the background process from the current terminal, so that if you close the terminal, gedit will continue to run as normal.detach
after doing ctrl-z andbg
, though, even in bash.You can find out more about the built-ins
jobs
,disown
and the&
metacharacter in the manpage for thebash
command , especially the section labelled "job control".This is probably because you opened gedit via terminal. When you do this, you see the command line output that is normally hidden if started via the GUI. The best way to fix this is to open a new terminal window. The other will become available after gedit closes. You can also use the switch the above user suggested.