Skip to content

Instantly share code, notes, and snippets.

@azatoth
Created May 11, 2011 09:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azatoth/966205 to your computer and use it in GitHub Desktop.
Save azatoth/966205 to your computer and use it in GitHub Desktop.
Open gvim in same window when on same "desktop"
#!/bin/bash
this=$(basename $0); # vim|gvim|rvim etc...
desktop=desktop_$(xprop -root -notype _NET_CURRENT_DESKTOP | perl -pe 's/.*?= (\d+)/$1/')
number_desktop=$(xprop -root -notype _NET_NUMBER_OF_DESKTOPS | perl -pe 's/.*?= (\d+)/$1/')
viewport=viewport_$(xprop -root -notype _NET_DESKTOP_VIEWPORT | perl -pe 's/.*?= (\d+), (\d+)/$1x$2/')
if [ $number_desktop = 1 ]; then
desktop=$viewport;
fi
if [ $# != 0 ]; then
exec /usr/bin/$this --servername $desktop --remote-tab-silent "$@"
elif ! vim --serverlist | grep -iq $desktop; then
exec /usr/bin/$this --servername $desktop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment