Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
meishi125478
ohmyzsh
提交
ef4e2aa2
O
ohmyzsh
项目概览
meishi125478
/
ohmyzsh
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
ohmyzsh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ef4e2aa2
编写于
12月 02, 2012
作者:
R
Robby Russell
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1293 from cenkalti/master
Look virtualenvwrapper plugin in PATH
上级
fdf3a399
d5e5b7ee
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
41 deletion
+35
-41
plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
+35
-41
未找到文件。
plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh
浏览文件 @
ef4e2aa2
WRAPPER_FOUND
=
0
for
wrapsource
in
"/usr/bin/virtualenvwrapper.sh"
"/usr/local/bin/virtualenvwrapper.sh"
"/etc/bash_completion.d/virtualenvwrapper"
;
do
if
[[
-e
$wrapsource
]]
;
then
WRAPPER_FOUND
=
1
source
$wrapsource
wrapsource
=
`
which virtualenvwrapper.sh
`
if
[[
!
$DISABLE_VENV_CD
-eq
1
]]
;
then
# Automatically activate Git projects' virtual environments based on the
# directory name of the project. Virtual environment name can be overridden
# by placing a .venv file in the project root with a virtualenv name in it
function
workon_cwd
{
# Check that this is a Git repo
PROJECT_ROOT
=
`
git rev-parse
--show-toplevel
2> /dev/null
`
if
((
$?
==
0
))
;
then
# Check for virtualenv name override
ENV_NAME
=
`
basename
"
$PROJECT_ROOT
"
`
if
[[
-f
"
$PROJECT_ROOT
/.venv"
]]
;
then
ENV_NAME
=
`
cat
"
$PROJECT_ROOT
/.venv"
`
fi
# Activate the environment only if it is not already active
if
[[
"
$VIRTUAL_ENV
"
!=
"
$WORKON_HOME
/
$ENV_NAME
"
]]
;
then
if
[[
-e
"
$WORKON_HOME
/
$ENV_NAME
/bin/activate"
]]
;
then
workon
"
$ENV_NAME
"
&&
export
CD_VIRTUAL_ENV
=
"
$ENV_NAME
"
fi
fi
elif
[
$CD_VIRTUAL_ENV
]
;
then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate
&&
unset
CD_VIRTUAL_ENV
fi
unset
PROJECT_ROOT
}
if
[[
-f
"
$wrapsource
"
]]
;
then
source
$wrapsource
# New cd function that does the virtualenv magic
function
cd
{
builtin cd
"
$@
"
&&
workon_cwd
}
fi
if
[[
!
$DISABLE_VENV_CD
-eq
1
]]
;
then
# Automatically activate Git projects' virtual environments based on the
# directory name of the project. Virtual environment name can be overridden
# by placing a .venv file in the project root with a virtualenv name in it
function
workon_cwd
{
# Check that this is a Git repo
PROJECT_ROOT
=
`
git rev-parse
--show-toplevel
2> /dev/null
`
if
((
$?
==
0
))
;
then
# Check for virtualenv name override
ENV_NAME
=
`
basename
"
$PROJECT_ROOT
"
`
if
[[
-f
"
$PROJECT_ROOT
/.venv"
]]
;
then
ENV_NAME
=
`
cat
"
$PROJECT_ROOT
/.venv"
`
fi
# Activate the environment only if it is not already active
if
[[
"
$VIRTUAL_ENV
"
!=
"
$WORKON_HOME
/
$ENV_NAME
"
]]
;
then
if
[[
-e
"
$WORKON_HOME
/
$ENV_NAME
/bin/activate"
]]
;
then
workon
"
$ENV_NAME
"
&&
export
CD_VIRTUAL_ENV
=
"
$ENV_NAME
"
fi
fi
elif
[
$CD_VIRTUAL_ENV
]
;
then
# We've just left the repo, deactivate the environment
# Note: this only happens if the virtualenv was activated automatically
deactivate
&&
unset
CD_VIRTUAL_ENV
fi
unset
PROJECT_ROOT
}
break
# New cd function that does the virtualenv magic
function
cd
{
builtin cd
"
$@
"
&&
workon_cwd
}
fi
done
if
[
$WRAPPER_FOUND
-eq
0
]
;
then
print
"zsh virtualenvwrapper plugin: Couldn't activate virtualenvwrapper. Please run
\`
pip install virtualenvwrapper
\`
."
else
print
"zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh. Please install with
\`
pip install virtualenvwrapper
\`
."
fi
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录