mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-23 10:11:14 +08:00
c58d14fe3e
This PR sets the default value of `OMF_CONFIG` variable in framework init.fish file. The variable can still be overridden by the user by setting it on `~/.config/fish/config.fish file`. This is in preparation to rewriting install script in plain fish, which will ditch config template and stop replacing `config.fish` contents in favor of just appending Oh My Fish startup.
56 lines
1.6 KiB
Fish
56 lines
1.6 KiB
Fish
# SYNOPSIS
|
|
# Initialize Oh My Fish.
|
|
#
|
|
# OVERVIEW
|
|
# + Autoload Oh My Fish packages, themes and config path
|
|
# + For each <pkg> inside {$OMF_PATH,$OMF_CONFIG}
|
|
# + Autoload <pkg> directory
|
|
# + Source <pkg>.fish
|
|
# + Emit init_<pkg> event
|
|
#
|
|
# + Autoload {$OMF_PATH,$OMF_CONFIG}/functions
|
|
# + Source $OMF_CONFIG/init.fish
|
|
#
|
|
# ENV
|
|
# OSTYPE Operating system.
|
|
# ORIGINAL_PATH Original $PATH preseved across Oh My Fish reloads.
|
|
# OMF_PATH ~/.local/share/omf by default.
|
|
# OMF_IGNORE List of packages to ignore.
|
|
# OMF_CONFIG ~/.config/omf by default.
|
|
# OMF_VERSION Oh My Fish! version
|
|
|
|
# Save PATH before oh my fish for reseting the PATH when we reload OMF.
|
|
if set -q ORIGINAL_PATH
|
|
set PATH $ORIGINAL_PATH
|
|
else
|
|
set -gx ORIGINAL_PATH $PATH
|
|
end
|
|
|
|
# Set OMF_CONFIG if not set.
|
|
if not set -q OMF_CONFIG
|
|
set -q XDG_CONFIG_HOME; or set -l XDG_CONFIG_HOME "$HOME/.config"
|
|
set -gx OMF_CONFIG "$XDG_CONFIG_HOME/omf"
|
|
end
|
|
|
|
# Save the head of function path and autoload core functions
|
|
set -l user_function_path $fish_function_path[1]
|
|
set fish_function_path[1] $OMF_PATH/lib
|
|
|
|
set -l theme {$OMF_PATH,$OMF_CONFIG}/themes/(cat $OMF_CONFIG/theme)
|
|
|
|
for path in $OMF_PATH/lib $OMF_PATH/lib/git {$OMF_PATH,$OMF_CONFIG}/pkg/* $theme
|
|
contains -- (basename $path) $OMF_IGNORE; and continue
|
|
|
|
autoload $path $path/completions
|
|
source $path/(basename $path).fish ^/dev/null
|
|
and emit init_(basename $path) $path
|
|
end
|
|
|
|
autoload $OMF_CONFIG/functions
|
|
autoload $user_function_path
|
|
|
|
# Source custom init.fish file
|
|
source $OMF_CONFIG/init.fish ^/dev/null
|
|
|
|
set -g OMF_VERSION "1.0.0"
|