-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathave.fish
More file actions
42 lines (37 loc) · 1.7 KB
/
Copy pathave.fish
File metadata and controls
42 lines (37 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# ave Activates Virtual Environment
function ave --description "Activate Virtual Environment"
set activate_script bin/activate.fish
set venvs_dir $AVE_HOME
if [ -z "$venvs_dir" ]
set venvs_dir $WORKON_HOME
end
set current_dir $argv[1]
# if ave is called without arguments, then assume current directory
if [ -z "$current_dir" ]
set current_dir (pwd)
end
if [ -e "$current_dir/$activate_script" ]
# if bin/activate exists, source it
source "$current_dir/$activate_script"
# cd to project directory if it's source controled
[ -d "$current_dir/.git" ] || [ -d "$current_dir/.hg" ] || [ -d "$current_dir/.svn" ]; and cd "$current_dir"
else if [ -e "$current_dir/.venv/$activate_script" ]
# check if there is .venv directory under current_dir
# and activate it
source "$current_dir/.venv/$activate_script"
[ -d "$current_dir/.git" ] || [ -d "$current_dir/.hg" ] || [ -d "$current_dir/.svn" ]; and cd "$current_dir"
else if [ -e "$venvs_dir/"(basename "$current_dir")"/$activate_script" ]
# if there is virtual environment inside WORKON_HOME, source it
source "$venvs_dir/"(basename "$current_dir")"/$activate_script"
# cd to project directory if it's source controled
[ -d "$current_dir/.git" ] || [ -d "$current_dir/.hg" ] || [ -d "$current_dir/.svn" ]; and cd "$current_dir"
else
set parent_dir (dirname "$current_dir")
# stop if parent directory is one from what we called ave from
if [ "$parent_dir" = "." ] || [ "$parent_dir" = "$current_dir" ]
return;
end
# call ave for parent directory
ave "$parent_dir"
end
end