dvm for fish shell. refer to https://gist.github.com/7sDream/69eb3ab8c8ca028c4975e922f356a96b
#!fish
function dvm
if not test -f "$DVM_DIR/dvm-helper/dvm-helper"
echo "Installation corrupt: dvm-helper is missing. Please reinstall dvm."
return 1
end
set DVM_OUTPUT $DVM_DIR/.tmp/dvm-output.sh
set DVM_OUTPUT_FISH $DVM_DIR/.tmp/dvm-output.fish
rm -f "$DVM_OUTPUT"
rm -f "$DVM_OUTPUT_FISH"
env DVM_DIR=$DVM_DIR $DVM_DIR/dvm-helper/dvm-helper --shell sh $argv
if test -e "$DVM_OUTPUT"
# convert sh to fish
sed -r -e "s%export (\w+)=\"%set -gx \1 %g" -e "s%:% %g" -e "s%\"\$%%g" "$DVM_OUTPUT" > "$DVM_OUTPUT_FISH"
source "$DVM_OUTPUT_FISH"
end
end
#!fish
## Support functions
function __fish_dvm_using_command
set cmd (commandline -opc)
set subcommands $argv
if [ (count $subcommands) -eq 0 ]
if [ (count $cmd) -eq 1 ]
return 0
else
return 1
end
end
if [ (count $cmd) = (math (count $subcommands) + 1) ]
for i in (seq (count $subcommands))
if not test $subcommands[$i] = $cmd[(math $i + 1)]
return 1
end
end
return 0
end
return 1
end
## dvm
complete -f -c dvm -n '__fish_dvm_using_command' -a "install uninstall use current ls ls-remote deactivate which"
## dvm use
complete -f -c dvm -n '__fish_dvm_using_command use' -a '(command ls $DVM_DIR/bin/docker)'