addon-sdk/source/bin/activate.fish

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/bin/activate.fish	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.7 +
     1.8 +# This file must be used with "source bin/activate.fish" *from fish*
     1.9 +# you cannot run it directly
    1.10 +
    1.11 +# Much of this code is based off of the activate.fish file for the
    1.12 +# virtualenv project. http://ur1.ca/ehmd6
    1.13 +
    1.14 +function deactivate -d "Exit addon-sdk and return to normal shell environment"
    1.15 +    if test -n "$_OLD_VIRTUAL_PATH"
    1.16 +        set -gx PATH $_OLD_VIRTUAL_PATH
    1.17 +        set -e _OLD_VIRTUAL_PATH
    1.18 +    end
    1.19 +
    1.20 +    if test -n "$_OLD_PYTHONPATH"
    1.21 +        set -gx PYTHONPATH $_OLD_PYTHONPATH
    1.22 +        set -e _OLD_PYTHONPATH
    1.23 +    end
    1.24 +
    1.25 +    if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
    1.26 +        functions -e fish_prompt
    1.27 +        set -e _OLD_FISH_PROMPT_OVERRIDE
    1.28 +        . ( begin
    1.29 +                printf "function fish_prompt\n\t#"
    1.30 +                functions _old_fish_prompt
    1.31 +            end | psub )
    1.32 +
    1.33 +        functions -e _old_fish_prompt
    1.34 +    end
    1.35 +
    1.36 +    set -e CUDDLEFISH_ROOT
    1.37 +    set -e VIRTUAL_ENV
    1.38 +
    1.39 +    if test "$argv[1]" != "nondestructive"
    1.40 +        functions -e deactivate
    1.41 +    end
    1.42 +end
    1.43 +
    1.44 +# unset irrelavent variables
    1.45 +deactivate nondestructive
    1.46 +
    1.47 +set -gx _OLD_PYTHONPATH $PYTHONPATH
    1.48 +set -gx _OLD_VIRTUAL_PATH $PATH
    1.49 +set -gx _OLD_FISH_PROMPT_OVERRIDE "true"
    1.50 +
    1.51 +set VIRTUAL_ENV (pwd)
    1.52 +
    1.53 +set -gx CUDDLEFISH_ROOT $VIRTUAL_ENV
    1.54 +set -gx PYTHONPATH "$VIRTUAL_ENV/python-lib" $PYTHONPATH
    1.55 +set -gx PATH "$VIRTUAL_ENV/bin" $PATH
    1.56 +
    1.57 +# save the current fish_prompt function as the function _old_fish_prompt
    1.58 +. ( begin
    1.59 +        printf "function _old_fish_prompt\n\t#"
    1.60 +        functions fish_prompt
    1.61 +    end | psub )
    1.62 +
    1.63 +# with the original prompt function renamed, we can override with our own.
    1.64 +function fish_prompt
    1.65 +    printf "(%s)%s%s" (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt)
    1.66 +    return
    1.67 +end 
    1.68 +
    1.69 +python -c "from jetpack_sdk_env import welcome; welcome()"

mercurial