LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   'Shortcut' for running vim63 (https://www.linuxquestions.org/questions/linux-newbie-8/%27shortcut%27-for-running-vim63-751195/)

xtheunknown0 08-29-2009 10:58 PM

'Shortcut' for running vim63
 
In Windows you can enter in the Run dialog box or in Command prompt stuff like notepad and explorer because they're in system32; how do I add the bin directory of vim63 to some sort of script file so that I can run 'vim' quickly?

kbp 08-29-2009 11:16 PM

Hi xtheunknown0,

You just need to add the directory to your PATH variable,

eg. if you use bash, edit ~/.bash_profile

Change this:
PATH=$PATH:$HOME/bin

to:
PATH=$PATH:$HOME/bin:/path/to/vim63/bin


cheers,

kbp

xtheunknown0 08-30-2009 12:50 AM

Quote:

Originally Posted by kbp (Post 3662506)
Hi xtheunknown0,

You just need to add the directory to your PATH variable,

eg. if you use bash, edit ~/.bash_profile

Change this:
PATH=$PATH:$HOME/bin

to:
PATH=$PATH:$HOME/bin:/path/to/vim63/bin


cheers,

kbp

It seems that I can only run vim by typing:

./vim

while inside the bin directory. Doesn't this mean that 'vim' is not 'registered' as a command? How do I make vim a command?

kbp 08-30-2009 03:02 AM

Did you modify your path as I suggested ? .. once you have, you will be able to run vim from anywhere. BTW.. are you running Linux or Windows ?

xtheunknown0 08-30-2009 05:10 AM

Quote:

Originally Posted by kbp (Post 3662607)
Did you modify your path as I suggested ?

Yes

Quote:

Originally Posted by kbp (Post 3662607)
BTW.. are you running Linux or Windows ?

Linux

colucix 08-30-2009 05:13 AM

Please, post the output from each of the following commands, so we can see where the problem is:
Code:

echo $PATH
which vim
ls -F /path/to/vim63/directory

of course you have to change /path/to/vim63/directory with the actual directory.

xtheunknown0 08-30-2009 05:53 AM

[QUOTE=colucix;3662681]Please, post the output from each of the following commands, so we can see where the problem is:
Code:

# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/games:/opt/bin:.:.


Code:

# which vim
Code:

# ls -F /opt/vim63/bin
eview@ gview@    rgview@ rvim@ vimdiff@
evim@  gvim@    rgvim@  view@ vimtutor*
ex@    gvimdiff@ rview@  vim*  xxd*


colucix 08-30-2009 06:56 AM

As you can see the directory /opt/vim63/bin is not in your PATH environment variable. Just do
Code:

export PATH=/opt/vim63/bin:$PATH
and the trick is done. Just an aside note: take in mind that the shell look for commands through the directory in $PATH in the exact order they appear. This means that if you have two executable with the same name but in different directories, it will be executed that one coming first in $PATH. This is the reason why I prefer to add my own bin directories at the beginning of my PATH.

Another aside note: in your PATH appear . (dot) that is the current working directory, whatever it be. This is not a good thing, due to security reasons. I would advice to remove it from your PATH.

xtheunknown0 08-30-2009 04:36 PM

Quote:

Originally Posted by kbp (Post 3662506)
You just need to add the directory to your PATH variable,

eg. if you use bash, edit ~/.bash_profile

Change this:
PATH=$PATH:$HOME/bin

to:
PATH=$PATH:$HOME/bin:/path/to/vim63/bin

My .bash_profile file doesn't have PATH in it:

#!/bin/bash
export IRCNICK=DSL
SSH=`env | grep SSH_CONNECTION`
RUNLEVEL=`runlevel|cut -f2 -d' '`
if [ -z "$SSH" ]; then
if [ $RUNLEVEL -eq 5 ]; then
startx
fi
fi

Quote:

Originally Posted by colucix (Post 3662731)
Just do

Code:

export PATH=/opt/vim63/bin:$PATH
It works but if I enter that as root it only works when I'm still in root, if I enter that as a normal user it only works when I'm still a normal user. In addition, when I close the xterm that line entered and open another xterm I have to retype it.

Quote:

Originally Posted by colucix (Post 3662731)
Another aside note: in your PATH appear . (dot) that is the current working directory, whatever it be. This is not a good thing, due to security reasons. I would advice to remove it from your PATH.

How do I remove directories from the PATH variable?

colucix 08-30-2009 05:09 PM

Quote:

Originally Posted by xtheunknown0 (Post 3663189)
It works but if I enter that as root it only works when I'm still in root, if I enter that as a normal user it only works when I'm still a normal user. In addition, when I close the xterm that line entered and open another xterm I have to retype it.

Yes, that's the normal behaviour. To make the changes permanent you have to put the export command in some initialization file, like ~/.bashrc (this on a per-user basis).

If you want to apply the change for all users, one of my preferred methods is to add an entry in the /etc/profile.d directory (if your OS supports it). Create a file called /etc/profile.d/vim63.sh containing the statement above:
Code:

export PATH=/opt/vim63/bin:$PATH
and the trick is done: at login every .sh file in /etc/profile.d will be sourced by /etc/profile.

A more simple way is to create a soft link in /usr/local/bin, since this location is usually in the default PATH for both users and root:
Code:

ln -s /opt/vim63/bin/vim /usr/local/bin/vim
Quote:

How do I remove directories from the PATH variable?
Well... you have to find out who (that is which script) adds them and modify the "offending" statement accordingly.

xtheunknown0 08-31-2009 04:40 PM

Problem solved
 
[quote=colucix;3663213]A more simple way is to create a soft link in /usr/local/bin, since this location is usually in the default PATH for both users and root:
Code:

ln -s /opt/vim63/bin/vim /usr/local/bin/vim
This method works and I like it - I'll try to make sure that that's in my re-remaster.


All times are GMT -5. The time now is 10:36 PM.