LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Openbox autostart.sh and setting alias on openbox start (https://www.linuxquestions.org/questions/linux-desktop-74/openbox-autostart-sh-and-setting-alias-on-openbox-start-889630/)

Jelloir 07-03-2011 03:31 AM

Openbox autostart.sh and setting alias on openbox start
 
I want run the following command to set an alias to use gvim when running an Openbox session and vim when on the console.

Code:

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:

Code:

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?

Jelloir 07-03-2011 03:56 AM

Edit: The below previous post doesn't work OK as my tty was just set to /dev/pts/1..... any suggestions appreciated.

I ended up using the following in ~/.bashrc

Code:

if [[ "$(tty)" = "/dev/pts/0" ]] && [[ $(which gvim) ]] ; then
    alias vi='gvim'
else
    alias vi='vim'
fi

This seems to be working ok.


All times are GMT -5. The time now is 05:13 PM.