From 74742bd5af2147b1c8f7e7bca7be32b7808410d1 Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Sat, 24 Sep 2022 10:02:03 +0200 Subject: [PATCH] feat(zsh): add auto complete for cht.sh --- .dotbot.conf.yaml | 1 + zsh/_cht | 21 +++++++++++++++++++++ zshrc | 5 +++-- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 zsh/_cht diff --git a/.dotbot.conf.yaml b/.dotbot.conf.yaml index 5c5b1d2..b9e4b88 100644 --- a/.dotbot.conf.yaml +++ b/.dotbot.conf.yaml @@ -24,6 +24,7 @@ ~/.vale.ini: vale.ini ~/.vale: .vale ~/.wget: wget + ~/.zsh.d: zsh ~/.zshrc: zshrc - shell: diff --git a/zsh/_cht b/zsh/_cht new file mode 100644 index 0000000..e1a4230 --- /dev/null +++ b/zsh/_cht @@ -0,0 +1,21 @@ +#compdef cht.sh + +__CHTSH_LANGS=($(curl -s cheat.sh/:list)) +_arguments -C \ + '--help[show this help message and exit]: :->noargs' \ + '--shell[enter shell repl]: :->noargs' \ + '1:Cheat Sheet:->lang' \ + '*::: :->noargs' && return 0 + +if [[ CURRENT -ge 1 ]]; then + case $state in + noargs) + _message "nothing to complete";; + lang) + compadd -X "Cheat Sheets" ${__CHTSH_LANGS[@]};; + *) + _message "Unknown state, error in autocomplete";; + esac + + return +fi diff --git a/zshrc b/zshrc index f8c40bf..2ce722b 100644 --- a/zshrc +++ b/zshrc @@ -335,6 +335,9 @@ antigen bundle zsh-users/zsh-syntax-highlighting # Tell Antigen that you’re done antigen apply +# Additional zsh plugins +fpath=(~/.zsh.d/ $fpath) + # *** *** Aliases *** *** # ZSH @@ -432,5 +435,3 @@ alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" # Empty the Trash on all mounted volumes and the main HDD # Also, clear Apple’s System Logs to improve shell startup speed alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl" - -