From 3b4cf3718b05d5ebd98d730abb742e82f8980287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Mon, 31 Dec 2018 13:17:05 -0500 Subject: [PATCH] bash: add completion for swaybar --- completions/bash/swaybar | 44 ++++++++++++++++++++++++++++++++++++++++ meson.build | 1 + 2 files changed, 45 insertions(+) create mode 100644 completions/bash/swaybar diff --git a/completions/bash/swaybar b/completions/bash/swaybar new file mode 100644 index 00000000..504588f1 --- /dev/null +++ b/completions/bash/swaybar @@ -0,0 +1,44 @@ +# swaybar(1) completion + +_swaybar() +{ + local cur prev + _get_comp_words_by_ref cur prev + + short=( + -h + -v + -s + -b + -d + ) + + long=( + --help + --version + --socket + --bar_id + --debug + ) + + case $prev in + -s|--socket) + _filedir + return + ;; + -b|--bar_id) + bars=($(swaymsg -t get_bar_config | sed -e '/^\[/,/\]$/{//d;s/^ *"\(.*\)",\?.*$/\1/}')) + COMPREPLY=($(compgen -W "${bars[*]}" -- "$cur")) + return + ;; + esac + + if [[ $cur == --* ]]; then + COMPREPLY=($(compgen -W "${long[*]}" -- "$cur")) + else + COMPREPLY=($(compgen -W "${short[*]}" -- "$cur")) + COMPREPLY+=($(compgen -W "${long[*]}" -- "$cur")) + fi + +} && +complete -F _swaybar swaybar diff --git a/meson.build b/meson.build index 981f74ac..b1353b59 100644 --- a/meson.build +++ b/meson.build @@ -213,6 +213,7 @@ endif if (get_option('bash-completions')) bash_files = files( 'completions/bash/sway', + 'completions/bash/swaybar', 'completions/bash/swayidle', 'completions/bash/swaylock', 'completions/bash/swaymsg',