I was trying to add the mvim shell script to /usr/local/bin form bash as per this question and everything seemed to work; however, I am still getting “command not found” whenever I try to execute the script.
From the directory where my mvim file is (Downloads), I typed:
sudo cp -v mvim /usr/local/bin
and I get output:
mvim -> /usr/local/bin
and then it doesn’t work whether I type mvim or mvim -v
I’ve never added something to my $PATH before, but even after looking up a number of tutorials on how it is done, I can’t seem to get mvim to work as a terminal command.
EDIT:
echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
and
ls -l mvim
-rwxr-xr-x ...
and
ls -l /usr/local/bin
-rwxr-xr-x ...
Does /usr/local/bin exists?
If you run
sudo cp -v mvim /usr/local/binand the/usr/local/binfolder does not exist, cp will copymvimto the/usr/local/folder and name itbin.You need to first create the folder with
sudo mkdir -p /usr/local/bin. Then, you can copymvimwith the previouscpcommand.Is mvim executable?
Have you made sure that
/usr/local/bin/mvimhas the executable flag set? Tryls -l /usr/local/bin/mvimand if the result starts with-rw-r--r--, then mvim is not executable.You then need to run
sudo chmod +x /usr/local/bin/mvim. If you now run the previouslscommand again, the result should start with-rwxr-xr-x. Thexmeans that the file is now executable by its owner, members of its group, and all other users too.Is /usr/local/bin in your PATH?
Have you made sure that
/usr/local/binis part of yourPATHvariable?Try
echo $PATHand if the output does not contain/usr/local/bin, then the shell will not look for commands there. You then need to runexport PATH=$PATH:/usr/local/bin