From cabdb4f8d52d3df589a455a754d584fc53785441 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Fri, 13 Jan 2017 07:28:21 +0100 Subject: [PATCH] feat(zsh): Compdef for polybar-msg --- doc/zsh/CMakeLists.txt | 3 +-- doc/zsh/_polybar_msg | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 doc/zsh/_polybar_msg diff --git a/doc/zsh/CMakeLists.txt b/doc/zsh/CMakeLists.txt index 142bad35..5482f150 100644 --- a/doc/zsh/CMakeLists.txt +++ b/doc/zsh/CMakeLists.txt @@ -1,7 +1,6 @@ # # Zsh completion template # - -install(FILES _polybar +install(FILES _polybar _polybar_msg DESTINATION share/zsh/site-functions COMPONENT tools) diff --git a/doc/zsh/_polybar_msg b/doc/zsh/_polybar_msg new file mode 100644 index 00000000..80611e80 --- /dev/null +++ b/doc/zsh/_polybar_msg @@ -0,0 +1,32 @@ +#compdef polybar-msg +# +# Completion for polybar-msg (https://github.com/jaagr/polybar) +# jaagr +# +_polybar_msg() { + integer ret=1 + + _arguments -n : \ + '-p[Process id of target instance]:process id:_polybar_msg_pids' \ + '(-p)1:message type:(action cmd hook)' \ + '*:: :->args' + + case $state in + args) + case $words[1] in + hook) _arguments ':module name:' ':hook index:'; ret=0 ;; + action) _arguments ':action payload:'; ret=0 ;; + cmd) _arguments ':command payload:'; ret=0 ;; + esac + ;; + esac + + return $ret +} + +(( $+functions[_polybar_msg_pids] )) || _polybar_msg_pids() { + local pids; pids=(${(f)"$(ls -1 /tmp/polybar_mqueue.* | egrep -o '[0-9]+$')"}) + _describe -t pids 'process id of target instance' pids +} + +_polybar_msg "$@"