Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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

3 Answers 3

up vote 5 down vote accepted

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.

share|improve this answer
    
Great, thank you. –  Kzqai Jan 18 '11 at 21:23

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

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

share|improve this answer
    
Hmm, will try that. –  Kzqai Jan 18 '11 at 20:59

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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