commit 9e839dd93ba81edf8dd75436b10dc901cc20f1bc parent 1143e815f0c0e19effa74e0e600dd2d9acac7ed4 Author: Sean Enck <sean@ttypty.com> Date: Thu, 21 Mar 2024 21:52:47 -0400 fish completions should work Diffstat:
| A | internal/app/doc/fish.sh | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 44 insertions(+), 0 deletions(-)
diff --git a/internal/app/doc/fish.sh b/internal/app/doc/fish.sh @@ -0,0 +1,44 @@ +complete -c {{ $.Executable }} -f + +{{- range $idx, $profile := $.Profiles }} + +function {{ $profile.Name }} + set -l commands {{ range $idx, $value := $profile.Options }}{{ if gt $idx 0}} {{ end }}{{ $value }}{{ end }} + complete -c {{ $.Executable }} -n "not __fish_seen_subcommand_from $commands" -a "$commands" + complete -c {{ $.Executable }} -n "__fish_seen_subcommand_from {{ $.HelpCommand }}" -a "{{ $.HelpAdvancedCommand }}" +{{- if not $profile.ReadOnly }} +{{- if $profile.CanList }} + complete -c {{ $.Executable }} -n "__fish_seen_subcommand_from {{ $.InsertCommand }} {{ $.MultiLineCommand }} {{ $.RemoveCommand }}; and test (count (commandline -opc)) -lt 3" -a "({{ $.DoList }})" + complete -c {{ $.Executable }} -n "__fish_seen_subcommand_from {{ $.MoveCommand }}; and test (count (commandline -opc)) -lt 4" -a "({{ $.DoList }})" +{{- end}} +{{- end}} +{{- if $profile.CanTOTP }} + set -l totps {{ $.TOTPListCommand }}{{ range $key, $value := .TOTPSubCommands }} {{ $value }}{{ end }} + complete -c {{ $.Executable }} -n "__fish_seen_subcommand_from {{ $.TOTPCommand }}" -a "$totps" +{{- if $profile.CanList }} + complete -c {{ $.Executable }} -n "__fish_seen_subcommand_from {{ $.TOTPCommand }}; and __fish_seen_subcommand_from $totps" -a "({{ $.DoTOTPList }})" +{{- end}} +{{- end}} +{{- if $profile.CanList }} + complete -c {{ $.Executable }} -n "__fish_seen_subcommand_from {{ $.ShowCommand }} {{ $.JSONCommand }}{{ if $profile.CanClip }} {{ $.ClipCommand }} {{end}}; and test (count (commandline -opc)) -lt 3" -a "({{ $.DoList}})" +{{- end}} +end +{{- end}} + +function {{ $.Executable }}-completions +{{- if eq (len $.Profiles) 1 }} + {{ $.DefaultProfile.Name }} +{{- else}} +{{- range $idx, $profile := $.Profiles }} +{{- if not $profile.IsDefault }} + if [ "{{ $.CompletionEnv }}" = "{{ $profile.Display }}" ] + {{ $profile.Name }} + return + end +{{- end}} +{{- end}} + {{ $.DefaultProfile.Name }} +{{- end}} +end + +{{ $.Executable }}-completions