Skip to content

Instantly share code, notes, and snippets.

@airtonix
Created August 21, 2013 06:39
Show Gist options
  • Save airtonix/6291018 to your computer and use it in GitHub Desktop.
Save airtonix/6291018 to your computer and use it in GitHub Desktop.
RVM Gemset integration with VirtualEnvWrapper
#!/bin/bash
#
# ~/.virtualenvs/postactivate
#
# This hook is run after this virtualenv is activated.
source ~/.rvm/scripts/rvm
# use a specific version of Ruby
rvm use 1.9.3
# cache a list of existing gemsets
gemsets=`rvm gemset list`
# get the directory name of the python virtual environment
# method 1
# project_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}')
# method 2
project_name=$(basename $VIRTUAL_ENV)
# Create a new gemset for $project_name if it doesn't exist
if [[ ! $gemsets == *"$project_name" ]]; then
rvm gemset create $project_name
fi
# use the $project_name gemset
rvm gemset use $project_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment