···31313232 ::: {.note}
3333 If your computer supports both BIOS and UEFI boot, choose the UEFI option.
3434+ You will likely need to disable "Secure Boot" to use the UEFI option. The exact steps vary by device manufacturer but generally "Secure Boot" will be listed under "Boot", "Security" or "Advanced" in the BIOS/UEFI menu.
3435 :::
35363637 ::: {.note}
···11+#!/usr/bin/env bash
22+33+_ks_completions() {
44+ local cur prev commands secrets
55+ COMPREPLY=()
66+ cur="${COMP_WORDS[COMP_CWORD]}"
77+ prev="${COMP_WORDS[COMP_CWORD-1]}"
88+ commands="add show cp rm ls rand init help version"
99+1010+ case "$prev" in
1111+ ks)
1212+ # Provide top-level command suggestions
1313+ COMPREPLY=($(compgen -W "$commands" -- "$cur"))
1414+ return 0
1515+ ;;
1616+ show|cp|rm)
1717+ # Provide dynamic completion for secrets
1818+ if secrets=$(ks ls 2>/dev/null); then
1919+ COMPREPLY=($(compgen -W "$secrets" -- "$cur"))
2020+ fi
2121+ return 0
2222+ ;;
2323+ add)
2424+ # For `ks add`, suggest options for adding secrets
2525+ COMPREPLY=($(compgen -W "-n" -- "$cur"))
2626+ return 0
2727+ ;;
2828+ rand)
2929+ # No specific completions for `ks rand`
3030+ return 0
3131+ ;;
3232+ esac
3333+3434+ case "${COMP_WORDS[1]}" in
3535+ ls|init|help|version)
3636+ # No additional completions for these commands
3737+ return 0
3838+ ;;
3939+ esac
4040+}
4141+4242+# Register the completion function for the `ks` command
4343+complete -F _ks_completions ks
+55
pkgs/by-name/ks/ks/ks-completion.zsh
···11+#compdef ks
22+33+_ks() {
44+ local -a commands
55+ commands=(
66+ "add:Add a secret (-n for secure note)"
77+ "show:Decrypt and reveal a secret"
88+ "cp:Copy a secret to the clipboard"
99+ "rm:Remove a secret from the keychain"
1010+ "ls:List all secrets in the keychain"
1111+ "rand:Generate a random secret (optionally specify size)"
1212+ "init:Initialize the selected keychain"
1313+ "help:Show help information"
1414+ "version:Print the version number"
1515+ )
1616+1717+ local context curcontext="$curcontext" state line
1818+ typeset -A opt_args
1919+2020+ _arguments \
2121+ '(-k)-k[Specify keychain]:keychain name:_files' \
2222+ '1:command:->command' \
2323+ '*::arguments:->args'
2424+2525+ case $state in
2626+ command)
2727+ _describe -t commands 'ks commands' commands
2828+ ;;
2929+ args)
3030+ case $line[1] in
3131+ add)
3232+ _arguments \
3333+ '(-n)-n[Add a secure note instead of a password]' \
3434+ '1:key[The name of the secret to add]' \
3535+ '2:value[The value of the secret to add]' \
3636+ '*::values:filename'
3737+ ;;
3838+ show|cp|rm)
3939+ local -a secrets
4040+ secrets=("${(@f)$(ks ls 2>/dev/null)}")
4141+ _describe -t secrets 'secrets' secrets
4242+ ;;
4343+ ls)
4444+ # No additional arguments for `ks ls`
4545+ ;;
4646+ rand)
4747+ _arguments '1:size[The size of the random secret to generate]'
4848+ ;;
4949+ *)
5050+ ;;
5151+ esac
5252+ ;;
5353+ esac
5454+}
5555+