fish-shell/share/functions/funcsave.fish
Fabian Homborg 6c988abe28 Add $__fish_config_dir variable
Contains the path to the user config.fish (e.g. ~/.config/fish)
without having to do the `set -q XDG_CONFIG_HOME` dance.

See #5270.
2018-10-21 15:42:25 +02:00

28 lines
752 B
Fish

function funcsave --description "Save the current definition of all specified functions to file"
set -l options 'h/help'
argparse -n funcsave --min-args=1 $options -- $argv
or return
if set -q _flag_help
__fish_print_help funcsave
return 0
end
if not mkdir -p $__fish_config_dir/functions
printf (_ "%s: Could not create configuration directory\n") funcsave
return 1
end
set -l retval 0
for funcname in $argv
if functions -q -- $funcname
functions -- $funcname >$__fish_config_dir/functions/$funcname.fish
else
printf (_ "%s: Unknown function '%s'\n") funcsave $funcname
set retval 1
end
end
return $retval
end