~miconoco/woo

woo/cmd/activate -rw-r--r-- 686 bytes
0b1818b1Christoph Polcin build 3 months ago
                                                                                
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
43
44
45
46
47
48
49
50
#!/bin/sh
# activate
#   Prints the woo-activation script to stdout.

_activate() { # {{{
    cat <<"EOF_ACTI"
[ -n "${_WOO_OPATH}" ] && return 0

deactivate() {
    PATH="$_WOO_OPATH"
    export PATH
    unset _WOO_OPATH

    PS1="$_WOO_OPS1"
    export PS1
    unset _WOO_OPS1

    unalias ws

    unset WOOWS

    unset -f deactivate

    hash -r 2>/dev/null || :
}

WOOWS="$(pwd)"
export WOOWS

alias ws='cd "${WOOWS:?export}"'

_WOO_OPATH="$PATH"

PATH="${WOOWS}/bin:${WOOWS}/cat-woo/bin:$PATH"
export PATH

_WOO_OPS1="${PS1:-}"
PS1="[${WOOWS##*/}] ${PS1:-}"
export PS1

hash -r 2>/dev/null || :

cat <<EOF
use 'ws' to cd into your workspace WOOWS=${WOOWS}
EOF

EOF_ACTI

} # }}}