Im reporting my use case here as requested by the documentation.
Bassically I'm using it to extend some of the functionality of fishes included functions, without having to rewrite them entirely.
Specifically, I'm currently using it twice:
In my ~/.config/fish/functions/ls.fish:
status get-file functions/ls.fish | source
# in previous fish versions, I did:
# source $__fish_data_dir/functions/ls.fish
functions -c ls __fish_ls
function ls; __fish_ls -A $argv; end
Thus ls gives fishes default behaviour, but also an implicit -A. (if I just did function ls; command ls -A $argv; end, I'd lose the nice colour coding that fish adds).
I also have a ~/.config/fish/completions/git.fish file:
status get-file completions/git.fish | source
# declares a completion for a new git sub command that takes no arguments
function complete-basic -a new description
complete -c git -n __fish_git_needs_command -a $new -d "$description"
end
#declares a completion for a new subcommand that takes the same arguments as original.
function complete-alias -a original new description
complete-basic $new $description
for C in (complete -c git | string match -re "__fish_git_using_command[^']*"$original"[ ']")
eval (string replace -r "__fish_git_using_command" "__fish_git_using_command $new" $C)
end
end
# abort and mend are defined in my ~/.gitconfig [alias] section
complete-basic abort "Undo the current sequencer process"
complete-alias commit mend "Ammend the prior commit"
... # many other aliases
The above uses status get-file to load the existing completions, as well as the helper __fish_git functions.
Im reporting my use case here as requested by the documentation.
Bassically I'm using it to extend some of the functionality of fishes included functions, without having to rewrite them entirely.
Specifically, I'm currently using it twice:
In my
~/.config/fish/functions/ls.fish:Thus
lsgives fishes default behaviour, but also an implicit-A. (if I just didfunction ls; command ls -A $argv; end, I'd lose the nice colour coding that fish adds).I also have a
~/.config/fish/completions/git.fishfile:The above uses
status get-fileto load the existing completions, as well as the helper__fish_gitfunctions.