Commit 8217eac3 authored by Derek Stavis's avatar Derek Stavis

themes: supercharge require to also load themes

parent f79cd118
......@@ -15,12 +15,14 @@ set -l theme_function_path {$OMF_CONFIG,$OMF_PATH}/themes*/$theme{,/functions}
# Autoload core library
set fish_function_path $fish_function_path[1] \
$core_function_path \
$theme_function_path \
$fish_function_path[2..-1]
# Require all packages
emit perf:timer:start "Oh My Fish init installed packages"
require --path {$OMF_PATH,$OMF_CONFIG}/pkg/*
emit perf:timer:finish "Oh My Fish init installed packages"
emit perf:timer:start "Oh My Fish init selected theme"
require --theme $theme
emit perf:timer:finish "Oh My Fish init selected theme"
# Backup key bindings
functions -q fish_user_key_bindings
and functions -c fish_user_key_bindings __original_fish_user_key_bindings
......
......@@ -8,29 +8,35 @@ function require
return 1
end
# If bundle should be
# If bundle should not be processed
if set index (contains -i -- --no-bundle $packages)
set -e packages[$index]
set ignore_bundle
end
# If requiring a theme we load the root path
if set index (contains -i -- --theme $packages)
set -e packages[$index]
set package_path {$OMF_PATH,$OMF_CONFIG}/theme?/$packages
set function_path $package_path
else
set package_path {$OMF_PATH,$OMF_CONFIG}/pk?/$packages
end
# Requiring absolute paths
if set index (contains -i -- --path $packages)
set -e packages[$index]
set package_path $packages
# Requiring specific packages from default paths
else
set package_path {$OMF_PATH,$OMF_CONFIG}/pkg*/$packages
# Exit with error if no package paths were generated
test -z "$package_path"
and return 1
end
set function_path $package_path/functions*
set complete_path $package_path/completions*
set init_path $package_path/init.fish*
# Exit with error if no paths were generated
test -z "$package_path"
and return 1
# Build package paths
set function_path $function_path $package_path/function?
set complete_path $package_path/completion?
set init_path $package_path/ini?.fish
# Autoload functions
test -n "$function_path"
......
......@@ -19,9 +19,12 @@ function omf.theme.set -a target_theme
return $OMF_INVALID_ARG
end
# Replace autoload paths of current theme with the target one
autoload -e {$OMF_CONFIG,$OMF_PATH}/themes/$current_theme
autoload {$OMF_CONFIG,$OMF_PATH}/themes/$target_theme
# Remove current theme paths
set -l current_theme_paths {$OMF_CONFIG,$OMF_PATH}/theme?/{,functions,completions}/$current_theme
autoload -e $current_theme_paths
# Require new theme
require --theme $target_theme
# Find target theme's fish_prompt and link to user function path
for path in {$OMF_CONFIG,$OMF_PATH}/themes/$target_theme/$prompt_filename
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment