Ubuntu: How to remove anomalous warning after closing gvim


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 ?


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  


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.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »