dotfiles/fish/functions/import.fish

22 lines
576 B
Fish
Executable File

#!/usr/bin/env
source (status dirname)/../include/parent.fish
function import
set -f self_directory (parent_script_dir)
if set -q debug;
echo "importing $argv.fish from [$self_directory]"
end
if starts_with '@' "$argv"
set -f include_dir "$(status dirname)/../include/"
set -f import_path \
(string replace '@' "$include_dir" "$argv")
source "$import_path.fish"
return 0
end
if starts_with '/' "$argv"
source "$argv.fish"
return 0
end
source $self_directory/"$argv.fish"
end