3

When I gedit files from the command line, it's always locking the terminal, and I'm tired of explicitly commanding a detached process for it.

I tried to alias gedit as something like gedit $* & disown, but either that's not the right syntax or you're not allowed to overload executable binary commands with aliases (tried using that in a .bash_aliases function,

alias gedit=editorz

function editorz()
{
  gedit $* & disown
}

), but it doesn't take.

So how do I make the command gedit test.txt not lock the originating terminal window?

  • 1
    Depending on your shell, "function" may not be supported. The POSIX-compatible way to define a function is without it. func_name() {...; } – Shawn J. Goff Jan 18 '11 at 20:47
  • Already using some functions that way (for non-trivial aliases). – Kzqai Jan 18 '11 at 20:58
6

That should work: are you sure your .bash_aliases is read? (It's not a standard file, but it might be sourced by your ~/.bashrc. If you're confused about .bashrc and .bash_profile, see Difference between .bashrc and .bash_profile.)

There's a bug in your function: it should be

editorz () {
  gedit "$@" & disown
}

Your version doesn't work on file names containing spaces or shell wildcards. The function keyword is optional.

You can call the function gedit (and dispense with the alias altogether), but then you need to tell the shell that the call inside the function is to the command and not to the function:

gedit () {
  command gedit "$@" & disown
}

Note that if you've accidentally started gedit in the foreground (i.e. locking your terminal), you can put it in the background by pressing Ctrl+Z in the terminal, and entering the command bg.

1

Make sure, that the function editorz() is defined before the alias.

I've tried your approach and it worked without a problem.

  • Hmm, will try that. – Kzqai Jan 18 '11 at 20:59
1

Opening gedit from the Utilities folder (instead of a terminal) solves the problem for me

-2

just add the following alias:

alias gedit='gedit -b'

the -b option means run in the background

  • 1
    Unknown option -b, and I'm on a very GNOMish system, meaning it shouldn't lack too many features of a GNOME app like gedit... – John WH Smith Apr 3 '15 at 10:10
  • Same here, -b option doesn't exist for me. – Kzqai Apr 3 '15 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.