2015-08-26 23:20:13 +08:00
|
|
|
# SYNOPSIS
|
|
|
|
# Initialize Oh My Fish.
|
|
|
|
#
|
|
|
|
# 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_CONFIG/init.fish
|
2015-08-28 17:02:02 +08:00
|
|
|
#
|
|
|
|
# ENV
|
|
|
|
# OSTYPE Operating system.
|
2015-09-05 23:56:33 +08:00
|
|
|
# ORIGINAL_PATH Original $PATH preseved across Oh My Fish reloads.
|
2015-09-05 00:54:00 +08:00
|
|
|
# OMF_PATH ~/.local/share/omf by default.
|
2015-08-28 17:02:02 +08:00
|
|
|
# OMF_IGNORE List of packages to ignore.
|
2015-09-05 00:54:00 +08:00
|
|
|
# OMF_CONFIG ~/.config/omf by default.
|
2015-08-28 17:02:02 +08:00
|
|
|
# OMF_VERSION Oh My Fish! version
|
2015-08-26 23:20:13 +08:00
|
|
|
|
2015-09-05 23:56:33 +08:00
|
|
|
# Save PATH before oh my fish for reseting the PATH when we reload OMF.
|
|
|
|
if set -q ORIGINAL_PATH
|
|
|
|
set PATH $ORIGINAL_PATH
|
2015-08-26 23:20:13 +08:00
|
|
|
else
|
2015-09-05 23:56:33 +08:00
|
|
|
set -gx ORIGINAL_PATH $PATH
|
2015-08-26 23:20:13 +08:00
|
|
|
end
|
|
|
|
|
2015-09-29 04:53:46 +08:00
|
|
|
# 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
|
|
|
|
|
2015-08-28 17:02:02 +08:00
|
|
|
# Save the head of function path and autoload core functions
|
2015-08-26 23:20:13 +08:00
|
|
|
set -l user_function_path $fish_function_path[1]
|
|
|
|
set fish_function_path[1] $OMF_PATH/lib
|
|
|
|
|
2015-09-05 01:24:25 +08:00
|
|
|
set -l theme {$OMF_PATH,$OMF_CONFIG}/themes/(cat $OMF_CONFIG/theme)
|
2015-08-26 23:20:13 +08:00
|
|
|
|
2015-09-05 01:24:25 +08:00
|
|
|
for path in $OMF_PATH/lib $OMF_PATH/lib/git {$OMF_PATH,$OMF_CONFIG}/pkg/* $theme
|
|
|
|
contains -- (basename $path) $OMF_IGNORE; and continue
|
2015-08-26 23:20:13 +08:00
|
|
|
|
|
|
|
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-09-05 00:54:00 +08:00
|
|
|
# Source custom init.fish file
|
|
|
|
source $OMF_CONFIG/init.fish ^/dev/null
|
2015-08-28 17:02:02 +08:00
|
|
|
|
|
|
|
set -g OMF_VERSION "1.0.0"
|