Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created July 29, 2010 19:59
Show Gist options
  • Save bcardarella/499070 to your computer and use it in GitHub Desktop.
Save bcardarella/499070 to your computer and use it in GitHub Desktop.
function cdgems() {
/usr/bin/osascript -e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down"
/usr/bin/osascript -e "tell application \"Terminal\" to do script with command \"cd $GEM_HOME/gems\" in window 1"
/usr/bin/osascript -e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"k\" using command down"
return 0
}
alias cdgems=cdgems
@bcardarella
Copy link
Author

This will alias the command 'cdgems' to open a new terminal tab in the gems directory relative to RVM

Just add to your .bash_profile

@jasonnoble
Copy link

Wouldn't it be better to alias cdgems to 'pushd $GEM_HOME/gems'? That way you could do what you need to, then run "popd" to get back to what you were doing.

Alternatively, you could hit Command-T and then cdgems. The osascript seems a little over the top.

@bcardarella
Copy link
Author

@jasonnoble with RVM I have custom gemsets for my different projects. Sometimes I want to jump into them so this will create that new tab and set the pwd to my project's top-level gemset directory. That being said, I fully admit I suck at any/all Bash scripting so there might be a much better way to do this. Someone else has already mentioned rb-applescript

@yas375
Copy link

yas375 commented Jul 30, 2010

I use it
cd rvm gemdir

@betarelease
Copy link

bundle open GEM

will open the bundled gem with default editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment