Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to improve my "switching projects" workflow.

Right now it works like this (I'm on OS X 10.6.7)

Open terminal.

I have this alias:

alias work='cd /Volumes/blah/Projects/'

So i type: "work" -> "cd ProjectName"

Then i Open VIM.

Inside i VIM, i always open :NERDTree plugin.

I'm wondering if there is a way to do this in one command like:

workon ProjectName

(similar to what virtualenv has for python, where you use a "hook" to cd into a specified directory)

share|improve this question
up vote 1 down vote accepted

In your ~/.vimrc add

autocmd VimEnter * NERDTree

This will automatically execute the vim command (starting the NERDTree plugin). Here's a short script that will achieve what you're after.

$ cat workon

cd /Volumes/blah/Projects/$1
share|improve this answer
I ended up running this in the script: vim --cmd "autocmd VimEnter * NERDTree". Thanks for the help – Daniel Apr 5 '11 at 12:06
This can be written as a function (defined in .bashrc) instead of a separate script file: workon() { cd /Volumes/blah/Project/"$1" && vim --cmd "..."; } – glenn jackman Apr 5 '11 at 14:35
@Daniel, that was exactly what I was looking for. Thanks for posting! – Brian Wigginton Jul 1 '11 at 19:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .