Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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
share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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