Skip to content

Commit bf73750

Browse files
committed
add ayu_load_theme method so we don't need to exec
1 parent a94bae9 commit bf73750

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
Declare the variant you want as a universal variable, _e.g._:
1212

13-
set --universal ayu_variant light
14-
exec fish
13+
set --universal ayu_variant light && ayu_load_theme
1514

1615
## Variants
1716

conf.d/ayu.fish

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
set --query ayu_path || set --local ayu_path $__fish_config_dir
2-
switch $ayu_variant
3-
case light
4-
source $ayu_path/conf.d/ayu-light.fish && enable_ayu_theme_light
5-
case dark
6-
source $ayu_path/conf.d/ayu-dark.fish && enable_ayu_theme_dark
7-
case mirage
8-
source $ayu_path/conf.d/ayu-mirage.fish && enable_ayu_theme_mirage
1+
function ayu_load_theme
2+
set --query ayu_path || set --local ayu_path $__fish_config_dir
3+
4+
switch $ayu_variant
5+
case light
6+
source $ayu_path/conf.d/ayu-light.fish && enable_ayu_theme_light
7+
and colorize "Ayu %s light %s enabled!\n"
8+
case dark
9+
source $ayu_path/conf.d/ayu-dark.fish && enable_ayu_theme_dark
10+
and colorize "Ayu %s dark %s enabled!\n"
11+
case mirage
12+
source $ayu_path/conf.d/ayu-mirage.fish && enable_ayu_theme_mirage
13+
and colorize "Ayu %s mirage %s enabled!\n"
14+
case '*'
15+
echo '⚠️ Invalid variant, choose among: light, dark or mirage'
16+
end
17+
end
18+
19+
function colorize \
20+
--argument-names text
21+
printf $text (set_color $fish_color_quote --reverse) (set_color normal)
922
end
1023

1124
function _ayu_save_current_theme
12-
set --query ayu_path || set --local ayu_path $__fish_config_dir
1325
set --local previous_theme_file $__fish_config_dir/functions/_ayu_restore_previous_theme.fish
1426

1527
test -e $previous_theme_file && command rm -f $previous_theme_file
@@ -25,8 +37,8 @@ function _ayu_save_current_theme
2537
end
2638

2739
function _ayu_install --on-event ayu_install
28-
echo '_ayu_save_current_theme'
2940
_ayu_save_current_theme
41+
and echo 'Previous theme saved! 🎉'
3042
end
3143

3244
function _ayu_uninstall --on-event ayu_uninstall
@@ -40,3 +52,12 @@ function _ayu_uninstall --on-event ayu_uninstall
4052
functions --erase _ayu_restore_previous_theme
4153
set --erase ayu_variant
4254
end
55+
56+
function ayu_display_colorscheme
57+
set color_vars (set --names | grep fish_color)
58+
for color_var in $color_vars
59+
printf "%-30s %s\n" \
60+
$color_var \
61+
(set_color $$color_var --reverse)"$$color_var"(set_color normal)
62+
end
63+
end

0 commit comments

Comments
 (0)