forked from chriskempson/base16-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile_helper.sh
executable file
·42 lines (36 loc) · 1.01 KB
/
profile_helper.sh
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
#!/usr/bin/env bash
if [ -z "$BASE16_SHELL" ]; then
if [ -n "$BASH" ]; then
BASE16_SHELL=${BASH_SOURCE[0]}
elif [ -n "$ZSH_NAME" ]; then
BASE16_SHELL=${(%):-%x}
fi
BASE16_SHELL=${BASE16_SHELL%/*}
fi
_base16()
{
local script=$1
local theme=$2
[ -f $script ] && . $script
ln -fs $script ~/.base16_theme
if [ -n ${BASE16_SHELL_HOOKS:+s} ] && [ -d "${BASE16_SHELL_HOOKS}" ]; then
for hook in $BASE16_SHELL_HOOKS/*; do
[ -f "$hook" ] && [ -x "$hook" ] && "$hook"
done
fi
}
if [ -n "$BASE16_DEFAULT_THEME" -a ! -f ~/.base16_theme ]; then
ln -s "$BASE16_SHELL/scripts/base16-$BASE16_DEFAULT_THEME.sh" \
"$HOME/.base16_theme"
fi
if [ -f ~/.base16_theme ]; then
. ~/.base16_theme
fi
for script in "$BASE16_SHELL"/scripts/base16*.sh; do
script_name=${script##*/}
script_name=${script_name%.sh}
theme=${script_name#*-}
func_name="base16_${theme}"
alias $func_name="_base16 \"${script}\" ${theme}"
done;
alias reset="command reset && [ -f ~/.base16_theme ] && . ~/.base16_theme"