mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
parent
e893c8ca97
commit
afb56a007d
1 changed files with 8 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
||||||
function __fish_complete_env_subcommand
|
function __fish_complete_env_subcommand
|
||||||
argparse -s s/ignore-environment u/unset h-help v-version -- (commandline -opc) (commandline -ct) 2>/dev/null
|
argparse -s s/ignore-environment u/unset= h-help v-version -- (commandline -opc) (commandline -ct) 2>/dev/null
|
||||||
or return
|
or return 1
|
||||||
|
|
||||||
# argv[1] is `env` or an alias.
|
# argv[1] is `env` or an alias.
|
||||||
set -e argv[1]
|
set -e argv[1]
|
||||||
|
@ -8,6 +8,7 @@ function __fish_complete_env_subcommand
|
||||||
# Remove all VAR=VAL arguments up to the first that isn't
|
# Remove all VAR=VAL arguments up to the first that isn't
|
||||||
while set -q argv[1]
|
while set -q argv[1]
|
||||||
if string match -q '*=*' -- $argv[1]
|
if string match -q '*=*' -- $argv[1]
|
||||||
|
or string match -q -- '-*' $argv[1]
|
||||||
set -e argv[1]
|
set -e argv[1]
|
||||||
else
|
else
|
||||||
break
|
break
|
||||||
|
@ -15,19 +16,17 @@ function __fish_complete_env_subcommand
|
||||||
end
|
end
|
||||||
|
|
||||||
# Then complete the rest as if it was given as a command.
|
# Then complete the rest as if it was given as a command.
|
||||||
if set -q argv[1]
|
if test -n "$argv"
|
||||||
complete -C"$argv"
|
complete -C "$argv"
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Files aren't useful with env. They are correctly suggested with the command.
|
complete -c env -a "(__fish_complete_env_subcommand)"
|
||||||
complete -c env -f
|
|
||||||
|
|
||||||
complete -c env -a "(__fish_complete_env_subcommand)" # -d "Command"
|
# complete VAR= only if the cursor is left of the =, otherwise complete the file right of the =
|
||||||
|
complete -c env -n 'not __fish_complete_env_subcommand; and not string match -eq = -- (commandline -ct)' -a "(set -n)=" -f -d "Redefine variable"
|
||||||
complete -c env -n 'not __fish_complete_env_subcommand' -a "(set -n)=" -x -d "Redefine variable"
|
|
||||||
complete -c env -n 'not __fish_complete_env_subcommand' -s i -l ignore-environment -d "Start with an empty environment"
|
complete -c env -n 'not __fish_complete_env_subcommand' -s i -l ignore-environment -d "Start with an empty environment"
|
||||||
complete -c env -n 'not __fish_complete_env_subcommand' -s u -l unset -d "Remove variable from the environment" -x -a "(set -n)"
|
complete -c env -n 'not __fish_complete_env_subcommand' -s u -l unset -d "Remove variable from the environment" -x -a "(set -n)"
|
||||||
complete -c env -n 'not __fish_complete_env_subcommand' -l help -d "Display help and exit"
|
complete -c env -n 'not __fish_complete_env_subcommand' -l help -d "Display help and exit"
|
||||||
|
|
Loading…
Reference in a new issue