From b81e79976e56886790806150378f117f19c593e0 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Thu, 9 Sep 2021 16:50:31 -0700 Subject: [PATCH] Add new way of installing and setting fish themes Now defining a theme directory and adding files to that directory --- .../fish/functions/_set_colorscheme.fish | 95 ------------------- assets/default/fish/functions/fish_theme.fish | 24 +++++ assets/default/fish/init.fish | 7 +- assets/default/fish/init/env.fish | 2 +- .../default/fish/themes/solarized_dark.fish | 25 +++++ .../default/fish/themes/solarized_light.fish | 25 +++++ assets/default/fish/themes/wombat.fish | 25 +++++ 7 files changed, 105 insertions(+), 98 deletions(-) delete mode 100644 assets/default/fish/functions/_set_colorscheme.fish create mode 100644 assets/default/fish/functions/fish_theme.fish create mode 100644 assets/default/fish/themes/solarized_dark.fish create mode 100644 assets/default/fish/themes/solarized_light.fish create mode 100644 assets/default/fish/themes/wombat.fish diff --git a/assets/default/fish/functions/_set_colorscheme.fish b/assets/default/fish/functions/_set_colorscheme.fish deleted file mode 100644 index 7a634bd..0000000 --- a/assets/default/fish/functions/_set_colorscheme.fish +++ /dev/null @@ -1,95 +0,0 @@ -function _set_colorscheme --description "Sets the fish colorscheme" - set -l theme "$argv[1]" - switch "$theme" - case "solarized light" - __theme_solarized_light - case "solarized dark" - __theme_solarized_dark - case "wombat" - __theme_wombat - end -end - -function __theme_solarized_light --description "Set fish theme to solarized light" - set -g fish_color_autosuggestion 93a1a1 - set -g fish_color_cancel -r - set -g fish_color_command 586e75 - set -g fish_color_comment 93a1a1 - set -g fish_color_cwd green - set -g fish_color_cwd_root red - set -g fish_color_end 268bd2 - set -g fish_color_error dc322f - set -g fish_color_escape 00a6b2 - set -g fish_color_history_current --bold - set -g fish_color_host normal - set -g fish_color_match --background=brblue - set -g fish_color_normal normal - set -g fish_color_operator 00a6b2 - set -g fish_color_param 657b83 - set -g fish_color_quote 839496 - set -g fish_color_redirection 6c71c4 - set -g fish_color_search_match bryellow --background=white - set -g fish_color_selection white --bold --background=brblack - set -g fish_color_user brgreen - set -g fish_color_valid_path --underline - set -g fish_pager_color_completion green - set -g fish_pager_color_description B3A06D - set -g fish_pager_color_prefix cyan --underline - set -g fish_pager_color_progress brwhite --background=cyan -end - -function __theme_solarized_dark --description "Set fish theme to solarized dark" - set -g fish_color_autosuggestion 586e75 - set -g fish_color_cancel -r - set -g fish_color_command 93a1a1 - set -g fish_color_comment 586e75 - set -g fish_color_cwd green - set -g fish_color_cwd_root red - set -g fish_color_end 268bd2 - set -g fish_color_error dc322f - set -g fish_color_escape 00a6b2 - set -g fish_color_history_current --bold - set -g fish_color_host normal - set -g fish_color_match --background=brblue - set -g fish_color_normal normal - set -g fish_color_operator 00a6b2 - set -g fish_color_param 839496 - set -g fish_color_quote 657b83 - set -g fish_color_redirection 6c71c4 - set -g fish_color_search_match bryellow --background=black - set -g fish_color_selection white --bold --background=brblack - set -g fish_color_user brgreen - set -g fish_color_valid_path --underline - set -g fish_pager_color_completion B3A06D - set -g fish_pager_color_description B3A06D - set -g fish_pager_color_prefix cyan --underline - set -g fish_pager_color_progress brwhite --background=cyan -end - -function __theme_wombat --description "Set fish theme to wombat" - set -g fish_color_autosuggestion black - set -g fish_color_cancel -r - set -g fish_color_command yellow - set -g fish_color_comment normal - set -g fish_color_cwd green - set -g fish_color_cwd_root red - set -g fish_color_end blue - set -g fish_color_error red - set -g fish_color_escape magenta - set -g fish_color_history_current --bold - set -g fish_color_host normal - set -g fish_color_match --background=brblue - set -g fish_color_normal normal - set -g fish_color_operator cyan - set -g fish_color_param green - set -g fish_color_quote brgreen --italics - set -g fish_color_redirection magenta - set -g fish_color_search_match bryellow --background=green - set -g fish_color_selection white --bold --background=green - set -g fish_color_user brgreen - set -g fish_color_valid_path --underline - set -g fish_pager_color_completion blue - set -g fish_pager_color_description blue - set -g fish_pager_color_prefix cyan --underline - set -g fish_pager_color_progress brwhite --background=cyan -end diff --git a/assets/default/fish/functions/fish_theme.fish b/assets/default/fish/functions/fish_theme.fish new file mode 100644 index 0000000..538fa24 --- /dev/null +++ b/assets/default/fish/functions/fish_theme.fish @@ -0,0 +1,24 @@ +function fish_theme --description "Sets fish theme" + set -l theme_name $argv[1] + for p in $fish_themes_path + set -l theme_file "$p/$theme_name.fish" + if test -f "$theme_file" + source "$theme_file" + return + end + end + + echo "Unknown theme $theme_name not in fish_themes_path" + return 1 +end + +function __fish_theme_list --description "List all fish themes found in path" + for p in $fish_themes_path + for theme in $p/*.fish + echo (basename "$theme" | string split -r -m1 .)[1] + end + end +end + +# Add a completion for themes +complete --command fish_theme --arguments '(__fish_theme_list)' --no-files --description "Fish theme" diff --git a/assets/default/fish/init.fish b/assets/default/fish/init.fish index 25ee610..69e5efb 100644 --- a/assets/default/fish/init.fish +++ b/assets/default/fish/init.fish @@ -1,8 +1,11 @@ if not contains -- "$fish_synced_dir/functions" $fish_function_path - set -p fish_function_path "$fish_synced_dir/functions" + set --prepend fish_function_path "$fish_synced_dir/functions" end if not contains -- "$fish_synced_dir/completions" $fish_complete_path - set -p fish_complete_path "$fish_synced_dir/completions" + set --prepend fish_complete_path "$fish_synced_dir/completions" +end +if not contains -- "$fish_synced_dir/themes" $fish_themes_path + set --path --prepend fish_themes_path "$fish_synced_dir/themes" end function _source_synced --description "Sources file from synced dir as well as optional local file" diff --git a/assets/default/fish/init/env.fish b/assets/default/fish/init/env.fish index 6f57868..fb142a3 100644 --- a/assets/default/fish/init/env.fish +++ b/assets/default/fish/init/env.fish @@ -32,6 +32,6 @@ if status --is-interactive eval ($HOME/bin/derive_colors.py --export --fish) # Set fish theme based on newly exported colors if set -q FISH_THEME - _set_colorscheme "$FISH_THEME" + fish_theme "$FISH_THEME" end end diff --git a/assets/default/fish/themes/solarized_dark.fish b/assets/default/fish/themes/solarized_dark.fish new file mode 100644 index 0000000..9162030 --- /dev/null +++ b/assets/default/fish/themes/solarized_dark.fish @@ -0,0 +1,25 @@ +set -g fish_color_autosuggestion 586e75 +set -g fish_color_cancel -r +set -g fish_color_command 93a1a1 +set -g fish_color_comment 586e75 +set -g fish_color_cwd green +set -g fish_color_cwd_root red +set -g fish_color_end 268bd2 +set -g fish_color_error dc322f +set -g fish_color_escape 00a6b2 +set -g fish_color_history_current --bold +set -g fish_color_host normal +set -g fish_color_match --background=brblue +set -g fish_color_normal normal +set -g fish_color_operator 00a6b2 +set -g fish_color_param 839496 +set -g fish_color_quote 657b83 +set -g fish_color_redirection 6c71c4 +set -g fish_color_search_match bryellow --background=black +set -g fish_color_selection white --bold --background=brblack +set -g fish_color_user brgreen +set -g fish_color_valid_path --underline +set -g fish_pager_color_completion B3A06D +set -g fish_pager_color_description B3A06D +set -g fish_pager_color_prefix cyan --underline +set -g fish_pager_color_progress brwhite --background=cyan diff --git a/assets/default/fish/themes/solarized_light.fish b/assets/default/fish/themes/solarized_light.fish new file mode 100644 index 0000000..6006429 --- /dev/null +++ b/assets/default/fish/themes/solarized_light.fish @@ -0,0 +1,25 @@ +set -g fish_color_autosuggestion 93a1a1 +set -g fish_color_cancel -r +set -g fish_color_command 586e75 +set -g fish_color_comment 93a1a1 +set -g fish_color_cwd green +set -g fish_color_cwd_root red +set -g fish_color_end 268bd2 +set -g fish_color_error dc322f +set -g fish_color_escape 00a6b2 +set -g fish_color_history_current --bold +set -g fish_color_host normal +set -g fish_color_match --background=brblue +set -g fish_color_normal normal +set -g fish_color_operator 00a6b2 +set -g fish_color_param 657b83 +set -g fish_color_quote 839496 +set -g fish_color_redirection 6c71c4 +set -g fish_color_search_match bryellow --background=white +set -g fish_color_selection white --bold --background=brblack +set -g fish_color_user brgreen +set -g fish_color_valid_path --underline +set -g fish_pager_color_completion green +set -g fish_pager_color_description B3A06D +set -g fish_pager_color_prefix cyan --underline +set -g fish_pager_color_progress brwhite --background=cyan diff --git a/assets/default/fish/themes/wombat.fish b/assets/default/fish/themes/wombat.fish new file mode 100644 index 0000000..71ede38 --- /dev/null +++ b/assets/default/fish/themes/wombat.fish @@ -0,0 +1,25 @@ +set -g fish_color_autosuggestion black +set -g fish_color_cancel -r +set -g fish_color_command yellow +set -g fish_color_comment normal +set -g fish_color_cwd green +set -g fish_color_cwd_root red +set -g fish_color_end blue +set -g fish_color_error red +set -g fish_color_escape magenta +set -g fish_color_history_current --bold +set -g fish_color_host normal +set -g fish_color_match --background=brblue +set -g fish_color_normal normal +set -g fish_color_operator cyan +set -g fish_color_param green +set -g fish_color_quote brgreen --italics +set -g fish_color_redirection magenta +set -g fish_color_search_match bryellow --background=green +set -g fish_color_selection white --bold --background=green +set -g fish_color_user brgreen +set -g fish_color_valid_path --underline +set -g fish_pager_color_completion blue +set -g fish_pager_color_description blue +set -g fish_pager_color_prefix cyan --underline +set -g fish_pager_color_progress brwhite --background=cyan