aboutsummaryrefslogtreecommitdiff
path: root/completions
diff options
context:
space:
mode:
authorGaƫl PORTAY <gael.portay@collabora.com>2018-12-31 13:17:05 -0500
committerBrian Ashworth <RedSoxFan@users.noreply.github.com>2018-12-31 22:35:57 -0500
commit3b4cf3718b05d5ebd98d730abb742e82f8980287 (patch)
tree32f34621ca10f8187ac3f8d8941b2f5a164cc0de /completions
parent3d7c20f062bebe39199d3872e5b64d5e8d61d100 (diff)
bash: add completion for swaybar
Diffstat (limited to 'completions')
-rw-r--r--completions/bash/swaybar44
1 files changed, 44 insertions, 0 deletions
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