Skip to content
Snippets Groups Projects
Commit 2ccf3ad3 authored by Derek Stavis's avatar Derek Stavis
Browse files

I never write commit messages

parent 7023aed6
Branches
Tags
No related merge requests found
...@@ -7,17 +7,11 @@ end ...@@ -7,17 +7,11 @@ end
# Source custom before.init.fish file # Source custom before.init.fish file
source $OMF_CONFIG/before.init.fish ^/dev/null source $OMF_CONFIG/before.init.fish ^/dev/null
# Autoload framework structure, keeping user function path as first
set fish_function_path $fish_function_path[1] \
$OMF_CONFIG/functions \
$OMF_PATH/{lib,git} \
$fish_function_path[2..-1]
# Read current theme # Read current theme
read -l theme < $OMF_CONFIG/theme read -l theme < $OMF_CONFIG/theme
# Prepare Oh My Fish paths # Prepare Oh My Fish paths
set -l omf_function_path {$OMF_CONFIG,$OMF_PATH}/{themes*/$theme/{,functions},pkg/*/{,functions}} set -l omf_function_path {$OMF_CONFIG,$OMF_PATH}/{themes*/$theme/{,functions},pkg/*/{,functions},functions,lib,lib/git}
set -l omf_complete_path {$OMF_CONFIG,$OMF_PATH}/{themes*/$theme/completions,pkg/*/completions} set -l omf_complete_path {$OMF_CONFIG,$OMF_PATH}/{themes*/$theme/completions,pkg/*/completions}
# Autoload functions # Autoload functions
...@@ -30,16 +24,7 @@ set fish_complete_path $fish_complete_path[1] \ ...@@ -30,16 +24,7 @@ set fish_complete_path $fish_complete_path[1] \
$omf_complete_path \ $omf_complete_path \
$fish_complete_path[2..-1] $fish_complete_path[2..-1]
for init in {$OMF_CONFIG,$OMF_PATH}/{pkg/*/init.fish} initialize {$OMF_CONFIG,$OMF_PATH}/pkg/*/init.fish
begin
source $init >/dev/null ^&1
set -l IFS '/'
echo $init | read -la components
emit init_$components[-2] (printf '/%s' $components[1..-2])
end
end
# Source custom init.fish file # Source custom init.fish file
source $OMF_CONFIG/init.fish ^/dev/null source $OMF_CONFIG/init.fish ^/dev/null
......
function __autoload_insert
set -l function_path
set -l complete_path
for path in $argv
not test -d "$path"; and continue
set -l IFS '/'
echo $path | read -la components
if test "$components[-1]" = completions
contains -- $path $fish_complete_path
or set complete_path $complete_path $path
else
contains -- $path $fish_function_path
or set function_path $function_path $path
end
end
test "$function_path"
and set fish_function_path $fish_function_path[1] $function_path $fish_function_path[2..-1]
test "$complete_path"
and set fish_complete_path $fish_complete_path[1] $complete_path $fish_complete_path[2..-1]
return 0
end
function __autoload_erase
set -l function_indexes
set -l complete_indexes
for path in $argv
set -l IFS '/'
echo $path | read -la components
test "$components[-1]" = completions
and set complete_indexes $complete_indexes (contains -i $path $fish_complete_path)
or set function_indexes $function_indexes (contains -i $path $fish_function_path)
end
test -n "$function_indexes"
and set -e fish_function_path[$function_indexes]
test -n "$complete_indexes"
and set -e fish_complete_path[$complete_indexes]
return 0
end
function autoload
set -l paths $argv
switch "$argv[1]"
case '-e' '--erase'
test (count $argv) -ge 2
and __autoload_erase $argv[2..-1]
or echo "usage: autoload $argv[1] <path>..." 1>&2
case "-*" "--*"
echo "autoload: invalid option $argv[1]"
return 1
case '*'
test (count $argv) -ge 1
and __autoload_insert $argv
or echo "usage: autoload <path>..." 1>&2
end
end
function available -a name -d "Check if argument a function or command"
type -q "$name"
end
function initialize -d "Initialize a package"
for init in $argv
set -l IFS '/'
echo $init | read -la components
set package $components[-2]
set path (printf '/%s' $components[1..-2])
set bundle $path/bundle
if test -f $bundle
while read -l type dependency
test "$type" = package
and require "$dependency"
end < $bundle
end
source $init $path
emit init_$package $path
end
end
function reload -d "Reload fish process via exec"
set -q CI; and return 0
set -gx dirprev $dirprev
set -gx dirnext $dirnext
set -gx dirstack $dirstack
set -gx fish_greeting ''
history --save
exec fish
end
function require
set packages $argv
# Skip if plugin has already been loaded.
for package in $packages
if contains -- $package $omf_packages_loaded
set index (contains -i -- $package $packages)
set -e packages[$index]
end
end
set function_path {$OMF_PATH,$OMF_CONFIG}/pkg*/$packages{,/functions}
set completion_path {$OMF_PATH,$OMF_CONFIG}/pkg*/$packages/completions
# Autoload functions
test "$function_path"
and set fish_function_path $fish_function_path[1] \
$function_path \
$fish_function_path[2..-1]
# Autoload completions
test "$complete_path"
and set fish_complete_path $fish_complete_path[1] \
$complete_path \
$fish_complete_path[2..-1]
initialize {$OMF_CONFIG,$OMF_PATH}/pkg*/$packages/init.fish
set -g omf_packages_loaded $packages $omf_packages_loaded
return 0
end
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