fish-shell/share/completions/env.fish
Fabian Homborg 69b464bc37 Run fish_indent on all our fish scripts
It's now good enough to do so.

We don't allow grid-alignment:

```fish
complete -c foo -s b -l barnanana -a '(something)'
complete -c foo -s z              -a '(something)'
```

becomes

```fish
complete -c foo -s b -l barnanana -a '(something)'
complete -c foo -s z -a '(something)'
```

It's just more trouble than it is worth.

The one part I'd change:

We align and/or'd parts of an if-condition with the in-block code:

```fish
if true
   and false
    dosomething
end
```

becomes

```fish
if true
    and false
    dosomething
end
```

but it's not used terribly much and if we ever fix it we can just
reindent.
2020-01-13 20:34:22 +01:00

34 lines
1.4 KiB
Fish

function __fish_complete_env_subcommand
argparse -s s/ignore-environment u/unset= h-help v-version -- (commandline -opc) (commandline -ct) 2>/dev/null
or return 1
# argv[1] is `env` or an alias.
set -e argv[1]
# Remove all VAR=VAL arguments up to the first that isn't
while set -q argv[1]
if string match -q '*=*' -- $argv[1]
or string match -q -- '-*' $argv[1]
set -e argv[1]
else
break
end
end
# Then complete the rest as if it was given as a command.
if test -n "$argv"
__fish_complete_subcommand --commandline $argv
return 0
end
return 1
end
complete -c env -a "(__fish_complete_env_subcommand)"
# 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' -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' -l help -d "Display help and exit"
complete -c env -n 'not __fish_complete_env_subcommand' -l version -d "Display version and exit"