|
1 # This Source Code Form is subject to the terms of the Mozilla Public |
|
2 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 |
|
5 # This file must be used with "source bin/activate.fish" *from fish* |
|
6 # you cannot run it directly |
|
7 |
|
8 # Much of this code is based off of the activate.fish file for the |
|
9 # virtualenv project. http://ur1.ca/ehmd6 |
|
10 |
|
11 function deactivate -d "Exit addon-sdk and return to normal shell environment" |
|
12 if test -n "$_OLD_VIRTUAL_PATH" |
|
13 set -gx PATH $_OLD_VIRTUAL_PATH |
|
14 set -e _OLD_VIRTUAL_PATH |
|
15 end |
|
16 |
|
17 if test -n "$_OLD_PYTHONPATH" |
|
18 set -gx PYTHONPATH $_OLD_PYTHONPATH |
|
19 set -e _OLD_PYTHONPATH |
|
20 end |
|
21 |
|
22 if test -n "$_OLD_FISH_PROMPT_OVERRIDE" |
|
23 functions -e fish_prompt |
|
24 set -e _OLD_FISH_PROMPT_OVERRIDE |
|
25 . ( begin |
|
26 printf "function fish_prompt\n\t#" |
|
27 functions _old_fish_prompt |
|
28 end | psub ) |
|
29 |
|
30 functions -e _old_fish_prompt |
|
31 end |
|
32 |
|
33 set -e CUDDLEFISH_ROOT |
|
34 set -e VIRTUAL_ENV |
|
35 |
|
36 if test "$argv[1]" != "nondestructive" |
|
37 functions -e deactivate |
|
38 end |
|
39 end |
|
40 |
|
41 # unset irrelavent variables |
|
42 deactivate nondestructive |
|
43 |
|
44 set -gx _OLD_PYTHONPATH $PYTHONPATH |
|
45 set -gx _OLD_VIRTUAL_PATH $PATH |
|
46 set -gx _OLD_FISH_PROMPT_OVERRIDE "true" |
|
47 |
|
48 set VIRTUAL_ENV (pwd) |
|
49 |
|
50 set -gx CUDDLEFISH_ROOT $VIRTUAL_ENV |
|
51 set -gx PYTHONPATH "$VIRTUAL_ENV/python-lib" $PYTHONPATH |
|
52 set -gx PATH "$VIRTUAL_ENV/bin" $PATH |
|
53 |
|
54 # save the current fish_prompt function as the function _old_fish_prompt |
|
55 . ( begin |
|
56 printf "function _old_fish_prompt\n\t#" |
|
57 functions fish_prompt |
|
58 end | psub ) |
|
59 |
|
60 # with the original prompt function renamed, we can override with our own. |
|
61 function fish_prompt |
|
62 printf "(%s)%s%s" (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt) |
|
63 return |
|
64 end |
|
65 |
|
66 python -c "from jetpack_sdk_env import welcome; welcome()" |