There is a part in my ~/.bashrc
, which sets $EDITOR to be gvim. It works fine when I am in X window. However, if I ssh to my workstation (from another workstation) gvim starts to complain "cannot open display".
Therefore I wish to put an if
statement in bashrc, that if X window is available then use gvim, otherwise let it be vim.
How could I achieve that?
Best Answer
One way to do this tests the existence of the DISPLAY environment variable:
In some cases, DISPLAY will be set even though your gvim won't be able to contact the X server. In those cases, use the RunningX program: