Skip to content

Instantly share code, notes, and snippets.

@Roy-Orbison
Last active April 17, 2026 01:30
Show Gist options
  • Select an option

  • Save Roy-Orbison/9768b938bc5dfbac69b7e20d3387a416 to your computer and use it in GitHub Desktop.

Select an option

Save Roy-Orbison/9768b938bc5dfbac69b7e20d3387a416 to your computer and use it in GitHub Desktop.
Bash completion for acme.sh. Save in /usr/share/bash-completion/completions or similar.
_comp_cmd_acme_sh()
{
local cur prev words cword
_init_completion -n : || return
local commands
commands='
--create-account-key
--create-csr
--create-domain-key
--cron
--deactivate
--deactivate-account
--deploy
--help
--info
--install
--install-cert
--install-cronjob
--issue
--list
--list-profiles
--register-account
--remove
--renew
--renew-all
--revoke
--set-default-ca
--set-default-chain
--set-notify
--show-csr
--sign-csr
--to-pkcs12
--to-pkcs8
--uninstall
--uninstall-cronjob
--update-account
--upgrade
--version
'
if (( cword == 1 )); then
COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
return 0
fi
local command="${words[1]}"
case "$prev" in
--domain | \
-d | \
--challenge-alias | \
--domain-alias)
COMPREPLY=( $( compgen -W "$(acme.sh --list | tail -n +2 | grep -Eo '^[^[:space:]]+')" -- "$cur" ) )
return 0
;;
--preferred-chain | \
--cert-profile | \
--certificate-profile | \
--valid-to | \
--valid-from | \
--eab-kid | \
--eab-hmac-key | \
--reloadcmd | \
--useragent | \
--email | \
-m | \
--days | \
--httpport | \
--tlsport | \
--local-address | \
--pre-hook | \
--post-hook | \
--renew-hook | \
--deploy-hook | \
--extended-key-usage | \
--branch | \
-b | \
--notify-hook | \
--notify-source | \
--password)
# These all need a value. Some could have smarter completion but
# better to offer nothing than more options or files & dirs.
COMPREPLY=()
return 0
;;
--debug)
if [[ "$cur" != -* ]]; then
COMPREPLY=( $( compgen -W '0 1 2 3' -- "$cur" ) )
return 0
fi
;;
--webroot | \
-w | \
--home | \
--cert-home | \
--config-home | \
--ca-path)
_filedir -d
return 0
;;
--dns)
if [[ "$cur" != -* ]]; then
COMPREPLY=()
local dnsapis
if dnsapis="$( compgen -G "$HOME/.acme.sh/dnsapi/dns_?*.sh" )"; then
readarray -t COMPREPLY <<<"$dnsapis"
COMPREPLY=( "${COMPREPLY[@]##*/}" )
COMPREPLY=( "${COMPREPLY[@]%.sh}" )
COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -- "$cur" ) )
fi
unset dnsapis
return 0
fi
;;
--dnssleep)
COMPREPLY=( $( compgen -W '10 20 30 40 50 60' -- "$cur" ) )
return 0
;;
--keylength | \
-k)
COMPREPLY=( $( compgen -W '
2048
3072
4096
8192
ec-256
ec-384
ec-521
' -- "$cur" ) )
return 0
;;
--accountkeylength | \
-ak)
COMPREPLY=( $( compgen -W '
2048
3072
4096
' -- "$cur" ) )
return 0
;;
--log)
if [[ "$cur" != -* ]]; then
_filedir
return 0
fi
;;
--log-level)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return 0
;;
--syslog)
COMPREPLY=( $( compgen -W '0 3 6 7' -- "$cur" ) )
return 0
;;
--cert-file | \
--key-file | \
--ca-file | \
--fullchain-file | \
--accountconf | \
--accountkey | \
--ca-bundle | \
--csr | \
--openssl-bin)
_filedir
return 0
;;
--server)
COMPREPLY=( $( compgen -W '
actalis
google
google_test
letsencrypt
letsencrypttest
sslcom
zerossl
' -- "$cur" ) )
return 0
;;
--auto-upgrade)
if [[ "$cur" != -* ]]; then
COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
return 0
fi
;;
--notify-level)
COMPREPLY=( $( compgen -W '0 1 2 3' -- "$cur" ) )
return 0
;;
--notify-mode)
COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
return 0
;;
--revoke-reason)
COMPREPLY=({0..10})
COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -- "$cur" ) )
return 0
;;
esac
local opts
opts='
--accountconf
--accountkeylength
--alpn
--always-force-new-domain-key
--apache
--ca-bundle
--ca-file
--ca-path
--cert-file
--cert-home
--certificate-profile
--challenge-alias
--config-home
--csr
--debug
--deploy-hook
--dns
--dnssleep
--domain
--domain-alias
--eab-hmac-key
--eab-kid
--force
--force-color
--fullchain-file
--home
--httpport
--insecure
--key-file
--keylength
--listen-v4
--listen-v6
--listraw
--local-address
--log
--log-level
--no-color
--no-profile
--notify-hook
--notify-level
--notify-mode
--notify-source
--ocsp-must-staple
--openssl-bin
--output-insecure
--password
--post-hook
--pre-hook
--preferred-chain
--reloadcmd
--renew-hook
--request-v4
--request-v6
--revoke-reason
--server
--staging
--standalone
--stateless
--stop-renew-on-error
--syslog
--test
--tlsport
--use-wget
--useragent
--valid-from
--valid-to
--webroot
--yes-I-know-dns-manual-mode-enough-go-ahead-please
'
case "$command" in
--create-csr | \
-ccr)
opts+='
--extended-key-usage
'
;;
--install)
opts+='
--accountkey
--cert-home
--email
--no-cron
--no-profile
'
;;
--issue)
opts+='
--days
'
;;
--list)
opts+='
--listraw
'
;;
--renew-all)
opts+='
--stop-renew-on-error
--treat-skip-as-success
'
;;
--revoke)
opts+='
--revoke-reason
'
;;
--to-pkcs12)
opts+='
--password
'
;;
--update-account)
opts+='
--email
'
;;
--upgrade)
opts+='
--auto-upgrade
--branch
'
;;
esac
case "$command" in
--deploy | \
--install-cert | \
-i | \
--remove | \
--renew | \
-r | \
--revoke | \
--to-pkcs8 | \
--to-pkcs12 | \
--create-csr | \
-ccr)
opts+='
--ecc
'
;;
esac
COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
} &&
complete -F _comp_cmd_acme_sh acme.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment