From f0c00ad82599556ea7da2d494c23c19ef6464bda Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 3 Dec 2020 20:19:06 +0100 Subject: [PATCH] Add Zsh completion. --- completions/_mastorss | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 completions/_mastorss diff --git a/completions/_mastorss b/completions/_mastorss new file mode 100644 index 0000000..ce1da03 --- /dev/null +++ b/completions/_mastorss @@ -0,0 +1,26 @@ +# -*- mode: shell-script; -*- +#compdef mastorss + +local context state state_descr line +typeset -A opt_args + +_arguments \ + "(- *)--dry-run[Do everything like normal, but don't post anything and don't update the config file.]" \ + "(- *)--help[Show a short help message.]" \ + "(- *)--version[Show version, copyright and license.]" \ + "::Profile:->profiles" + +case "$state" in + profiles) + # Find config dir. + local config_dir="${XDG_CONFIG_HOME}" + [[ -z "${config_dir}" ]] && config_dir="${HOME}/.config" + config_dir+="/mastorss" + + # Extract profile names from config files. + for file in "${config_dir}"/config-*; do + profile="${file/*config-/}" + compadd ${profile%.json} + done + ;; +esac