I recently switched to fish shell and I wanted to be able to start
gvim from command line, but it should behave just like
gedit (just one instance). Then I polished the function a bit. The basic functionality that I had in mind was:
If gvim is not running
Start a new gvim instance.
Start a new gvim instance and open
If gvim is already running
Bring the running instance to the front.
file in a new tab inside the running instance and bring gvim to the front.
Here is what I ended up with, ready to past in your
function gvim if [ (count $argv) -gt "0" ] command gvim --remote-tab-silent $argv xdotool search --name gvim windowactivate else ps -A | grep -q gvim if [ "$status" -eq "0" ]; xdotool search --name gvim windowactivate else command gvim $argv end end end