I want run the following command to set an alias to use gvim when running an Openbox session and vim when on the console.
if which gvim > /dev/null ; then alias vi='gvim' ; else alias vi='vim' ; fi
If I add this to ~/.bashrc its fine but will set gvim as the the default all the time regardless of running X/Openbox, which is no good.
I tried adding it to ~/.xinitrc and ~/.config/openbox/autostart.sh but the alias does not get applied. I also tried:
x-terminal-emulator -e "if which gvim > /dev/null ; then alias vi='gvim' ; else alias vi='vim' ; fi"
Which doesn't work either.
How can I apply this alias when only running and openbox/X session?