michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # This file must be used with "source bin/activate.fish" *from fish* michael@0: # you cannot run it directly michael@0: michael@0: # Much of this code is based off of the activate.fish file for the michael@0: # virtualenv project. http://ur1.ca/ehmd6 michael@0: michael@0: function deactivate -d "Exit addon-sdk and return to normal shell environment" michael@0: if test -n "$_OLD_VIRTUAL_PATH" michael@0: set -gx PATH $_OLD_VIRTUAL_PATH michael@0: set -e _OLD_VIRTUAL_PATH michael@0: end michael@0: michael@0: if test -n "$_OLD_PYTHONPATH" michael@0: set -gx PYTHONPATH $_OLD_PYTHONPATH michael@0: set -e _OLD_PYTHONPATH michael@0: end michael@0: michael@0: if test -n "$_OLD_FISH_PROMPT_OVERRIDE" michael@0: functions -e fish_prompt michael@0: set -e _OLD_FISH_PROMPT_OVERRIDE michael@0: . ( begin michael@0: printf "function fish_prompt\n\t#" michael@0: functions _old_fish_prompt michael@0: end | psub ) michael@0: michael@0: functions -e _old_fish_prompt michael@0: end michael@0: michael@0: set -e CUDDLEFISH_ROOT michael@0: set -e VIRTUAL_ENV michael@0: michael@0: if test "$argv[1]" != "nondestructive" michael@0: functions -e deactivate michael@0: end michael@0: end michael@0: michael@0: # unset irrelavent variables michael@0: deactivate nondestructive michael@0: michael@0: set -gx _OLD_PYTHONPATH $PYTHONPATH michael@0: set -gx _OLD_VIRTUAL_PATH $PATH michael@0: set -gx _OLD_FISH_PROMPT_OVERRIDE "true" michael@0: michael@0: set VIRTUAL_ENV (pwd) michael@0: michael@0: set -gx CUDDLEFISH_ROOT $VIRTUAL_ENV michael@0: set -gx PYTHONPATH "$VIRTUAL_ENV/python-lib" $PYTHONPATH michael@0: set -gx PATH "$VIRTUAL_ENV/bin" $PATH michael@0: michael@0: # save the current fish_prompt function as the function _old_fish_prompt michael@0: . ( begin michael@0: printf "function _old_fish_prompt\n\t#" michael@0: functions fish_prompt michael@0: end | psub ) michael@0: michael@0: # with the original prompt function renamed, we can override with our own. michael@0: function fish_prompt michael@0: printf "(%s)%s%s" (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt) michael@0: return michael@0: end michael@0: michael@0: python -c "from jetpack_sdk_env import welcome; welcome()"