Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created March 2, 2012 01:52
Show Gist options
  • Save lxneng/1954877 to your computer and use it in GitHub Desktop.
Save lxneng/1954877 to your computer and use it in GitHub Desktop.
has_virtualenv() {
if [ -e .venv ]; then
workon `cat .venv`
fi
}
venv_cd () {
cd "$@" && has_virtualenv
}
alias cd="venv_cd"
# 这是一段shell脚本, 用来`cd`到某个项目中自动激活该项目所属的虚拟环境.
# 在项目的根目录中新建一个`.venv`的文件, 里面的内容就是该项目所属virtualenv的名字。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment