Function: fish_load_theme

- Better way to load themes
- Load themes in a running session
This commit is contained in:
Candifloss 2026-07-17 09:57:17 +05:30
parent 55b74b9567
commit fd4bb034d8
2 changed files with 27 additions and 10 deletions

View File

@ -1,14 +1,6 @@
# Prompt theme # Prompt theme
# Change "default" to preferred theme name # Set the theme name. Default: "default"
set -g FISH_PROMPT_THEME default set -g FISH_PROMPT_THEME default
#set -g FISH_PROMPT_THEME compact
#set -g FISH_PROMPT_THEME minimaline
set -l theme_dir ~/.config/fish/themes/$FISH_PROMPT_THEME fish_load_theme $FISH_PROMPT_THEME
source $theme_dir/prompt.fish
if test -f $theme_dir/right_prompt.fish
source $theme_dir/right_prompt.fish
end

View File

@ -0,0 +1,25 @@
function fish_load_theme --description "Load a Fish prompt theme"
if test (count $argv) -ne 1
echo "Usage: fish_load_theme <theme>" >&2
return 1
end
set -l theme $argv[1]
set -l theme_dir $__fish_config_dir/themes/$theme
if not test -d $theme_dir
echo "fish_load_theme: Theme '$theme' not found." >&2
return 1
end
if not test -f $theme_dir/prompt.fish
echo "fish_load_theme: Theme '$theme' has no prompt.fish." >&2
return 1
end
source $theme_dir/prompt.fish
if test -f $theme_dir/right_prompt.fish
source $theme_dir/right_prompt.fish
end
end