-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample
53 lines (44 loc) · 1.47 KB
/
example
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
51
52
53
# This file must be sourced from bash
# You cannot run it directly
#
# This simple example adds /sbin to the user's path
deactivate_example () {
# reset old environment variables
if [ -n "${_OLD_EXAMPLE_PATH+set}" ] ; then
export PATH="$_OLD_EXAMPLE_PATH"
unset _OLD_EXAMPLE_PATH
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
if [ -n "$_OLD_EXAMPLE_PS1" ] ; then
export PS1="$_OLD_EXAMPLE_PS1"
unset _OLD_EXAMPLE_PS1
fi
unset EXAMPLE_ENV
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f deactivate_example
fi
}
# unset irrelavent variables
deactivate_example nondestructive
export EXAMPLE_ENV="example"
_OLD_EXAMPLE_PATH="$PATH"
export PATH="/sbin:$PATH"
if [ -z "$EXAMPLE_ENV_DISABLE_PROMPT" ] &&
[ -z "$PATHIFY_DISABLE_PROMPT" ] ; then
_OLD_EXAMPLE_PS1="$PS1"
# Add env name before first non-whitespace PS1 char
PS1=$(echo "$PS1" | sed -e '0,/\S/s//[example] &/')
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi