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)

link|improve this question
feedback

1 Answer

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
#!/bin/bash

cd /Volumes/blah/Projects/$1
vim
link|improve this answer
1  
I ended up running this in the script: vim --cmd "autocmd VimEnter * NERDTree". Thanks for the help – Daniel Apr 5 '11 at 12:06
1  
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
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.