VIM_APP_DIR environment variable on Mac OS X Lion - terminal

I am looking to enable my terminal with the MacVim/mvim command so that I can access macvim through the terminal.
Following directions, I have downloaded and unzipped the MacVim files.
To be able to access MacVim through the terminal, one requires to set the VIM_APP_DIR environment variable with the value being the location of mvim script or the MacVim path.
By attempting the following command:
export VIM_APP_DIR = "the filepath"
I carried out printenv and VIM_APP_DIR does not exist in the set of environment variables.
Now that sounds more like a problem within a problem. The problem is I am unable to find a way to enable my Mac OS X Lion to be Vim powered and the above was the recommended route towards glory, however leave glory, the actor wasn't even there (VIM_APP_DIR).

First, you may not have to set the VIM_APP_DIR environment variable if you put the MacVim.app bundle in one of the “usual” locations:
~/Applications/ (the Applications folder in your home directory)
/Applications/ (the main Applications folder on the computer)
/Applications/Utilities/
It actually checks a few more locations, too: some relative to the location of the mvim script, and in a vim/ directory under the described directories.
In most cases, you should only need to set VIM_APP_DIR if mvim complains like this:
Sorry, cannot find MacVim.app. Try setting the VIM_APP_DIR enviro
nment variable to the directory containing MacVim.app.
Second, if you have to set VIM_APP_DIR (because you keep MacVim.app in an “unusual” location), the value of the environment variable should be the directory that contains MacVim.app, not the location of MacVim.app or mvim itself.
For example: If, you moved MacVim.app to /MyFavoriteApps/MacVim.app and have mvim available somewhere in your PATH, then you would need to set VIM_APP_DIR to /MyFavoriteApps (not /MyFavoriteApps/MacVim.app).
Third, in bash (the shell you are probably using), parameter assignments must not have spaces around the equal sign. It should look like this:
export VIM_APP_DIR=/MyFavoriteApps
If the pathname has spaces or special characters, then you may need to quote it. Single quotes are a good choice because they represent a literal string (you can include any character except a single quote itself).
export VIM_APP_DIR='/My Favorite Apps'
Last, you will probably want to put this “assignment and export” in your shell’s initialization file to make sure the value is set in all your future shell instances. A good choice is usually ~/.bashrc.

I don't know where you're getting this from. All that is required is to put the mvim script in your path, e.g., /usr/local/bin, and MacVim.app in a "normal" location such as /Applications or ~/Applications. Full list here: https://github.com/b4winckler/macvim/blob/master/src/MacVim/mvim (line 20).

Related

OSX differentiate applications with same name in PATH

In OSX, I have added a new path to /etc/paths. It is a path to a medical image viewer application known as rview.
It seems to clash with vim and on typing rview in bash it starts up vim.
But my question is more general, how do you differentiate applications with the same names included in PATH?
The path is evaluated in order; the first matching executable is run.
To edit this, you should change your user profile, not the system-wide configuration. You may have a line similar to this in your ~/.bash_profile file:
export PATH=/usr/local/sbin:/usr/local/bin:$PATH
Just add the path to your application before $PATH and it should work fine. If the line isn't there, create it.
And, if you really want to edit the system paths, just add yours at the top of /etc/paths instead of the bottom.

iverilog environment set up on macbook

I tried to make iverilog command s.t I can run verilog program on my Macbook Air.
After few steps for installing the files, the tutorial told me to type:
export PATH=~/bin:/usr/local/iverilog/bin
It worked in terms of iverilog command, i.e, I can compile .v file. However, normal command like ls, man,etc.
I guess it is the problem of the PATH of the command sets, which means those normal unix command is not located.
Can someone tell me how to fix it and I dont need to export the PATH everytime?
You didn't add your paths to the current paths established by the OS. Instead, you replaced it with your paths. This is what you need to do in order to add paths to your PATH variable:
export PATH=$PATH:~/bin:/usr/local/iverilog/bin
The $PATH part is your current PATH value, which is added (concatenated actually) to the list of new paths you want to add. This is turn is assigned to PATH variable.
To make this additions permanent, you may want to add the above line to the end of your .profile file, or .bash_profile (whatever you have in OS X)
You can also do as this:
http://architectryan.com/2012/10/02/add-to-the-path-on-mac-os-x-mountain-lion/
Which says that you can edit the file /etc/paths and add whatever paths you want to add, one per line, then save that file and your added paths are available. In this case, just remember to use absolute paths. That is, paths starting with / . The first one you use: ~/bin is not an aboslute path. You need to convert it to an absolute path. To do this, remember that ~ is a shortcut to your HOME directory: something like /Users/myloginname. Type echo $HOME to find it out.

exectuable path pointing to the wrong location, how do I update

I recently updated a nodejs executable using npm and now the executable is pointing to the wrong location. when I run the which command in terminal it is pointing to the old non-existant location. How do I update the executable path or shortcut. I'm not a unix person so not sure where that is set.
I don't necessarily need to update the path for all my apps in the environment, just curious to know why that path for the old executable is still hanging around and pointing to the wrong location.
bash caches the paths to executables you've run. You can reset the cache with "hash -r" (or start a new bash session or terminal).
I don't think which ever returns something that doesn't exist. It shows you which version of the executable is being found, based on the search order in your $PATH environment variable.
This $PATH variable is set in your shell. Type $PATH in the terminal to see what your path variable is set to. (Probably something like /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin)
See this question for some instructions to change your shell path variable: Set environment variables on Mac OS X Lion
Can you give more specific examples of where this stuff is, and what files you are looking at, because I don't think your description makes sense (with regard to "pointing to the old non-existant location")?

mac os x terminal problem faced

oh my god...i faced a big problem...i was created a .bash_profile in ~ folder and then set paths there...bust the big problem is after restarting my bash i see that none of my commands work like LS and RM and etc...
now i dont know how to fix it...some one help me...i need my terminal as soon as possible...
Make sure you are appending to the existing $PATH.
PATH=$PATH:/Users/mthalman/bin
To prevent this happening in the future:
When I edit my environment files (including bashrc, profile, login, and others), I always try starting another shell before quitting my editing environment. This protects me from the possibility of breaking my environment so that I can't log in.
Make sure your PATH includes the usual bin directories: /bin and /usr/bin.
First I would rename ~/.bash_profile to ~/old.bash_profile.
Then open that up in TextEdit (as a plain text document) and verify how you have set your path.
If you would prefer to use vim/emacs/nano/whatever, the act of renaming the file will allow new terminal sessions to use default paths, so from the command line you should be mostly fine.
Then verify you haven't clobbered $PATH as suggested by #Mark Thalman, above.
If you are in a Terminal Window, simply add in the /bin and /usr/bin back in your PATH.
$ PATH="/bin:/usr/bin:$PATH"
That should allow all the basic Unix command to work once more. Or, you can use the full path name for commands:
$ PATH="" #Can't find nothin'
$ ls
bash: ls: command not found.
$ /bin/ls -a #This will work!
. .. .bash_profile foo bar
Don't Reset PATH in your .profile!
As you discovered, you should never reset PATH in your `.bash_profile. Instead, you should always append and prepend to it:
PATH="/usr/local/bin:$PATH"
PATH="$PATH:$HOME/bin"
The first line will prepend /usr/local/bin to PATH which means if a command is in /usr/local/bin and /usr/bin, the /usr/local/bin version will be executed. Many system admins will put alternative base system commands in /usr/local/bin. For example, on Solaris, they might put VIM in /usr/local/bin/vi, so when you edit a file, you're using the improved VIM and not the base VI.
The second line appends your $HOME/bin to the end of $PATH. That means if there's a /bin/ls and you have ~/bin/ls, the /bin/ls will be executed first.
Never set PATH from scratch because each Unix system might have commands that you to access elsewhere in the system. For example, your site might require you to use X11, so you want /usr/X11/bin in your PATH, or you have GIT installed under the /opt/git directory, and you'll need /opt/git/bin in your path.
Sometimes, base utilities like ls might be replaced with upgraded versions of these utilities. On Solaris, you have the base vi and ls command, Most users like the GNU ls command because it uses color and prefer VIM to plain VI. I would included these utilities in /usr/local/bin and prepend that to my PATH.
And now a Word from a Sponsor
As you probably discovered, Finder doesn't list hidden files. That's why you can't see .bash_profile in Finder. You can use some hacks to change this, but it requires you to type them into the terminal window.
I use a Finder replacement called Path Finder. It contains a lot of neat Power User things such as allowing you to see hidden files, treat Packages such as apps as directories, and be able to view protected directories if you have Administrator access. There's a built in terminal and GUI Subversion client.
It's not cheap ($40), but you can download for free and try it out for 30 days.
BTW, I have absolutely no relationship to Cocoatech except as a customer, and I make no money from people buying Path Finder. It's just a tool I use.

Where do I put mxmlc so that I could just type 'mxmlc' in the terminal to compile a swf file?

I'm on a Mac and I'm trying to make a Vim plugin for compiling/running actionscript files.
First, I need to run mxmlc on the command line, but to do that I have to keep on typing the path to it. Where do I place it so that I don't have to retype the path?
You need to modify your "$PATH" environment variable, so that the tool is in that directory. However, if you want to make this very easy... you can download my macosx-environment-setup.tar.bz2 program. If you execute the "install.sh" script using "sudo ./install.sh", it will setup your environment in such a way that if you use "/Library/Flex4SDK" as the location for the Flex4SDK, it will automatically find it, define FLEX_HOME to point to that location, and it will also ensure that the binaries from the Flex4SDK are in your PATH.
Side Note: This is up on the web, because I use it in my Development Environment Setup How-To Guides. If you aren't too keen about running "sudo ./install.sh", you need to choose a location (I am going to assume "/Library/Flex4SDK", so that the tools are located in "/Library/Flex4SDK/bin"), and then you would simply need to edit your "~/.profile" file (using "nano ~/.profile"), adding the following to the very end:
export FLEX_HOME=/Library/Flex4SDK
export PATH="$PATH":"$FLEX_HOME/bin"
Note that these changes occur in your shell... they will not affect programs that are launched by double-clicking them in Finder. In order to affect those programs, you will need to place the environment variables in a file named ~/.MacOSX/environment.plist. See Automatically build ~/.MacOSX/environment.plist for a script that will automatically generate such a file using the current environment variables defined in your shell.
There are a few ways to answer this:
In one of your directories searched
by PATH (see the list with echo
$PATH)
Add a new directory to PATH
(e.g. in your ~/.bashrc
export PATH=$PATH:/path/to/bindir)
Add an
alias to your program (e.g. in your
~/.bashrc alias
mxmic=/path/to/mxmic)
(I'm assuming you're using bash shell, which is usually the case you can check with echo $SHELL)

Resources