mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 13:57:17 +08:00
completions/dd: re-use built-in file completion for "dd if=the-file"
This allows to complete file arguments even if they contain variables. Add similar logic for arguments to Maven's -D option. See https://github.com/fish-shell/fish-shell/issues/5248#issuecomment-857614957
This commit is contained in:
parent
48426d6285
commit
73b13315de
|
@ -10,14 +10,8 @@ function __fish_complete_dd -d 'Complete dd operands'
|
|||
case 'if=*' 'of=*'
|
||||
string replace = ' ' -- $operand_string | read -l operand value
|
||||
|
||||
for entry in $value*
|
||||
# if $entry is a directory, append a '/'
|
||||
if test -d $entry
|
||||
echo $operand"="$entry/
|
||||
else
|
||||
echo $operand"="$entry
|
||||
end
|
||||
end
|
||||
# Use normal file completions.
|
||||
printf "$operand=%s\n" (complete -C "__fish_command_without_completions $value")
|
||||
|
||||
case 'iflag=*' 'oflag=*'
|
||||
string replace = ' ' -- $operand_string | read -l operand complete
|
||||
|
|
|
@ -34,7 +34,20 @@ complete -c mvn -r -f -o b -l builder -d "The id of the build strategy to use."
|
|||
complete -c mvn -f -o C -l strict-checksums -d "Fail the build if checksums don't match"
|
||||
complete -c mvn -f -o c -l lax-checksums -d "Warn if checksums don't match"
|
||||
complete -c mvn -f -o cpu -l check-plugin-updates -d "Ineffective, only kept for backward compatibility"
|
||||
|
||||
function __fish_mvn_complete_definition
|
||||
set -l current_token (commandline -t)
|
||||
set -l previous_token (commandline -opc)[-1]
|
||||
string match -qr -- '^(-D|--define\b)' $current_token $previous_token
|
||||
or return
|
||||
set -l keyval (string split --max=1 -- = $current_token)
|
||||
or return
|
||||
# Use normal file completion for the value.
|
||||
printf -- "$keyval[1]=%s\n" (complete -C "__fish_command_without_completions $keyval[2]")
|
||||
end
|
||||
|
||||
complete -c mvn -f -o D -l define -d "Define a system property"
|
||||
complete -c mvn -f -a "(__fish_mvn_complete_definition)"
|
||||
complete -c mvn -f -o e -l errors -d "Produce execution error messages"
|
||||
complete -c mvn -f -o emp -l encrypt-master-password -d "Encrypt master security password"
|
||||
complete -c mvn -f -o ep -l encrypt-password -d "Encrypt server password"
|
||||
|
|
Loading…
Reference in New Issue
Block a user