Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have added the function gvim(){ /usr/bin/gvim -f "$@" & true; } to my .bashrc file. but I still have a problem. I open file 111 with gvim and close it and a warning like [10]+ ... /usr/bin/gvim -f $*"? is displayed in my terminal. How do I remove it ?

share|improve this question

2 Answers 2

You have backgrounded the program by using the ampersand (&) and also it is probably best to name your function mygvim so you can still run gvim with its default settings when you want to.

cd to your home folder and edit your .bashrc with your favourite text editor:

nano -cw .bashrc

Your function should look like this:

mygvim() { /usr/bin/gvim -f "$@"; }

(If you wish your files to each open in tabs you could add the -p option.) Then save your file after you have finished editing it.

Now you must source your .bashrc so it is read (or restart the terminal):

. .bashrc

You can call your function by whatever its name is and place two text files in the gvim buffers with

mygvim my.txt second.txt
share|improve this answer

I'm not sure why you're running true after calling gvim. Its effect would be to surpress the exit status of gvim, yet I can't think of any reason why you'd want to do that except on a case by case basis. Anyway,I think the simplest thing is to use an alias:

alias gvim='gvim -f'

You could also use the function:

gvim() {
  command gvim -f "$@"
}

These two ways are equivalent.

As to the name of your function or alias, I don't quite agree with Mik. If you plan to normally call gvim in the way you mentioned, I see no harm in doing what you're doing. If you ever need the default behavior, you can easily use the command prefix. In fact, I've written a few wrapper scripts that are placed earlier on the path and completely override the system program. It's only a problem if you find yourself having to frequently override your customizations.

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.