2015-08-26 23:20:13 +08:00
|
|
|
# SYNOPSIS
|
|
|
|
# Initialize Oh My Fish.
|
|
|
|
#
|
|
|
|
# ENV
|
|
|
|
# OSTYPE Operating system.
|
|
|
|
# RESET_PATH Original $PATH preseved across Oh My Fish refreshes.
|
|
|
|
# OMF_PATH Set in ~/.config/fish/config.fish
|
|
|
|
# OMF_IGNORE List of packages to ignore.
|
2015-08-28 01:56:01 +08:00
|
|
|
# OMF_CONFIG Same as OMF_PATH. ~/.config/omf by default.
|
2015-08-26 23:20:13 +08:00
|
|
|
#
|
|
|
|
# OVERVIEW
|
2015-08-28 01:56:01 +08:00
|
|
|
# + Autoload Oh My Fish packages, themes and config path
|
|
|
|
# + For each <pkg> inside {$OMF_PATH,$OMF_CONFIG}
|
2015-08-26 23:20:13 +08:00
|
|
|
# + Autoload <pkg> directory
|
|
|
|
# + Source <pkg>.fish
|
|
|
|
# + Emit init_<pkg> event
|
|
|
|
#
|
2015-08-28 01:56:01 +08:00
|
|
|
# + Autoload {$OMF_PATH,$OMF_CONFIG}/functions
|
|
|
|
# + Source {$OMF_PATH,$OMF_CONFIG} → fish-shell/fish-shell/issues/845
|
|
|
|
# + Source $OMF_CONFIG/init.fish
|
2015-08-26 23:20:13 +08:00
|
|
|
|
|
|
|
if set -q RESET_PATH
|
|
|
|
set PATH $RESET_PATH
|
|
|
|
else
|
|
|
|
set -gx RESET_PATH $PATH
|
|
|
|
end
|
|
|
|
|
|
|
|
set -q OSTYPE; or set -g OSTYPE (uname)
|
|
|
|
|
|
|
|
# Save the head of function path and autoload Oh My Fish core functions
|
|
|
|
set -l user_function_path $fish_function_path[1]
|
|
|
|
set fish_function_path[1] $OMF_PATH/lib
|
|
|
|
|
2015-08-28 01:56:01 +08:00
|
|
|
set -l theme {$OMF_PATH,$OMF_CONFIG}/themes/(cat $OMF_CONFIG/theme)
|
2015-08-26 23:20:13 +08:00
|
|
|
set -l paths $OMF_PATH/pkg/*
|
2015-08-28 01:56:01 +08:00
|
|
|
set -l config $OMF_CONFIG/pkg/*
|
2015-08-26 23:20:13 +08:00
|
|
|
set -l ignore $OMF_IGNORE
|
|
|
|
|
|
|
|
for path in $paths
|
2015-08-28 01:56:01 +08:00
|
|
|
set config $OMF_CONFIG/(basename $path) $config
|
2015-08-26 23:20:13 +08:00
|
|
|
end
|
|
|
|
|
2015-08-28 01:56:01 +08:00
|
|
|
for path in $OMF_PATH/lib $OMF_PATH/lib/git $paths $theme $config
|
2015-08-26 23:20:13 +08:00
|
|
|
contains -- (basename $path) $ignore; and continue
|
|
|
|
autoload $path $path/completions
|
2015-08-28 10:54:36 +08:00
|
|
|
source $path/(basename $path).fish ^/dev/null
|
2015-08-26 23:20:13 +08:00
|
|
|
and emit init_(basename $path) $path
|
|
|
|
end
|
|
|
|
|
2015-08-28 01:56:01 +08:00
|
|
|
autoload $OMF_CONFIG/functions
|
2015-08-26 23:20:13 +08:00
|
|
|
autoload $user_function_path
|
|
|
|
|
2015-08-28 10:54:36 +08:00
|
|
|
for path in {$OMF_PATH,$OMF_CONFIG}/events.fish $OMF_CONFIG/init.fish
|
|
|
|
source "$path" ^/dev/null
|
|
|
|
end
|