forked from chriskempson/base16-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile_helper.fish
executable file
·37 lines (31 loc) · 1.07 KB
/
profile_helper.fish
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
#!/usr/bin/env fish
# [what] provides aliases for base16 themes and sets ~/.base16_theme
#
# [usage] can be added to ~/.config/fish/config.fish like so:
#
# if status --is-interactive
# source $HOME/.config/base16-shell/profile_helper.fish
# end
#
# TODO: maybe port to $HOME/.config/fish/functions ?
set SCRIPT_DIR (realpath (dirname (status -f)))
# load currently active theme...
if test -e ~/.base16_theme
set -l SCRIPT_NAME (basename (realpath ~/.base16_theme) .sh)
set -gx BASE16_THEME (string match 'base16-*' $BASE16_THEME | string sub -s (string length 'base16-*'))
eval sh '"'(realpath ~/.base16_theme)'"'
end
# set aliases, like base16_*...
for SCRIPT in $SCRIPT_DIR/scripts/*.sh
set THEME (basename $SCRIPT .sh)
function $THEME -V SCRIPT -V THEME
sh $SCRIPT
ln -sf $SCRIPT ~/.base16_theme
set -gx BASE16_THEME (string split -m 1 '-' $THEME)[2]
if test (count $BASE16_SHELL_HOOKS) -eq 1; and test -d "$BASE16_SHELL_HOOKS"
for hook in $BASE16_SHELL_HOOKS/*
test -f "$hook"; and test -x "$hook"; and "$hook"
end
end
end
end