Merge pull request #9 from oh-my-fish/refactoring

Beginning of many PRs to clean up the code
pull/17/head
Bruno 9 years ago
commit d33d8cbf01

@ -9,40 +9,32 @@
# + Emit init_<pkg> event
#
# + Autoload {$OMF_PATH,$OMF_CONFIG}/functions
# + Source {$OMF_PATH,$OMF_CONFIG}/events
# + Source $OMF_CONFIG/init.fish
#
# ENV
# OSTYPE Operating system.
# RESET_PATH Original $PATH preseved across Oh My Fish reloads.
# OMF_PATH Set in ~/.config/fish/config.fish
# 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 Same as OMF_PATH. ~/.dotfiles by default.
# OMF_CONFIG ~/.config/omf by default.
# OMF_VERSION Oh My Fish! version
if set -q RESET_PATH
set PATH $RESET_PATH
# 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 RESET_PATH $PATH
set -gx ORIGINAL_PATH $PATH
end
set -q OSTYPE; or set -g OSTYPE (uname)
# 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)
set -l paths $OMF_PATH/pkg/*
set -l config $OMF_CONFIG/pkg/*
set -l ignore $OMF_IGNORE
set -l theme {$OMF_PATH,$OMF_CONFIG}/themes/(cat $OMF_CONFIG/theme)
for path in $paths
set config $OMF_CONFIG/(basename $path) $config
end
for path in $OMF_PATH/lib $OMF_PATH/lib/git {$OMF_PATH,$OMF_CONFIG}/pkg/* $theme
contains -- (basename $path) $OMF_IGNORE; and continue
for path in $OMF_PATH/lib $OMF_PATH/lib/git $paths $theme $config
contains -- (basename $path) $ignore; and continue
autoload $path $path/completions
source $path/(basename $path).fish ^/dev/null
and emit init_(basename $path) $path
@ -51,8 +43,7 @@ end
autoload $OMF_CONFIG/functions
autoload $user_function_path
for path in {$OMF_PATH,$OMF_CONFIG}/events.fish $OMF_CONFIG/init.fish
source $path ^/dev/null
end
# Source custom init.fish file
source $OMF_CONFIG/init.fish ^/dev/null
set -g OMF_VERSION "1.0.0"

@ -10,9 +10,11 @@ function autoload -d "autoload a function or completion path"
for path in $argv
if test -d "$path"
set -l dest fish_function_path
if test (basename "$path") = "completions"
if test (basename "$path") = completions
set dest fish_complete_path
end
contains "$path" $$dest; or set $dest "$path" $$dest
end
end

@ -97,9 +97,10 @@ function omf -d "Oh My Fish"
case "t" "theme"
if test (count $argv) -eq 1
set -l ostype (uname)
set -l theme (cat $OMF_CONFIG/theme)
set -l regex "[[:<:]]($theme)[[:>:]]"
test "$OSTYPE" != "Darwin"; and set regex "\b($theme)\b"
test "$ostype" != "Darwin"; and set regex "\b($theme)\b"
omf.list_themes | column | sed -E "s/$regex/"(omf::em)"\1"(omf::off)"/"
omf::off

Loading…
Cancel
Save