From 9f7363c9ee781fdee6fea3241fc5a1071ef7ec3d Mon Sep 17 00:00:00 2001 From: patrick96 Date: Mon, 24 Jun 2019 18:21:11 +0200 Subject: [PATCH] bash: Remove tabs --- contrib/bash/polybar | 148 +++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/contrib/bash/polybar b/contrib/bash/polybar index 22982d37..d8a40de6 100644 --- a/contrib/bash/polybar +++ b/contrib/bash/polybar @@ -1,94 +1,94 @@ _polybar_config_file() { - local config_path=${XDG_CONFIG_HOME:-$HOME/.config}/polybar/config + local config_path=${XDG_CONFIG_HOME:-$HOME/.config}/polybar/config - for ((i = 0; i < COMP_CWORD; i++)); do - case ${COMP_WORDS[i]} in - --config) - config_path=${COMP_WORDS[i + 2]} - break - ;; - -c) - config_path=${COMP_WORDS[i + 1]} - break - ;; - esac - done + for ((i = 0; i < COMP_CWORD; i++)); do + case ${COMP_WORDS[i]} in + --config) + config_path=${COMP_WORDS[i + 2]} + break + ;; + -c) + config_path=${COMP_WORDS[i + 1]} + break + ;; + esac + done - # Use eval + cd for to get bash's parameter/tilde expansion etc - (eval cd $(dirname "$config_path"); echo $PWD/$(basename "$config_path")) + # Use eval + cd for to get bash's parameter/tilde expansion etc + (eval cd $(dirname "$config_path"); echo $PWD/$(basename "$config_path")) } _polybar_bars() { - local config_file=$(_polybar_config_file) + local config_file=$(_polybar_config_file) - if [ -r "$config_file" ]; then - grep -Po '\[bar/\K(.*)(?=\])' "$config_file" - fi + if [ -r "$config_file" ]; then + grep -Po '\[bar/\K(.*)(?=\])' "$config_file" + fi } _polybar() { - local options='-h --help - -v --version - -l --log= - -q --quiet + local options='-h --help + -v --version + -l --log= + -q --quiet -c --config= - -r --reload - -d --dump= - -m --list-monitors - -M --list-all-monitors - -w --print-wmname - -s --stdout - -p --png=' + -r --reload + -d --dump= + -m --list-monitors + -M --list-all-monitors + -w --print-wmname + -s --stdout + -p --png=' - local log_levels='error - warning - info - trace' + local log_levels='error + warning + info + trace' - COMPREPLY=() + COMPREPLY=() - local cur=${COMP_WORDS[COMP_CWORD]} - case "$cur" in - -*) - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) - ;; - *) - local prev=${COMP_WORDS[COMP_CWORD - 1]} - if [ "$prev" = "=" ]; then - prev=${COMP_WORDS[COMP_CWORD - 2]} - fi + local cur=${COMP_WORDS[COMP_CWORD]} + case "$cur" in + -*) + COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + ;; + *) + local prev=${COMP_WORDS[COMP_CWORD - 1]} + if [ "$prev" = "=" ]; then + prev=${COMP_WORDS[COMP_CWORD - 2]} + fi - case "$prev" in - -l|--log) - COMPREPLY=( $(compgen -W "$log_levels" -- "$cur") ) - return 0 - ;; - -c|--config) - COMPREPLY=( $(compgen -f "$cur") ) - return 0 - ;; - -p|--png) - COMPREPLY=( $(compgen -f -X "!*.png" "$cur") ) - return 0 - ;; - # TODO: read properties of the selected bar from config - -d|--dump) - return 0 - ;; - *) - COMPREPLY=( $(compgen -W "$options $(_polybar_bars)" -- "$cur") ) - ;; - esac - esac + case "$prev" in + -l|--log) + COMPREPLY=( $(compgen -W "$log_levels" -- "$cur") ) + return 0 + ;; + -c|--config) + COMPREPLY=( $(compgen -f "$cur") ) + return 0 + ;; + -p|--png) + COMPREPLY=( $(compgen -f -X "!*.png" "$cur") ) + return 0 + ;; + # TODO: read properties of the selected bar from config + -d|--dump) + return 0 + ;; + *) + COMPREPLY=( $(compgen -W "$options $(_polybar_bars)" -- "$cur") ) + ;; + esac + esac - for ((i = 0; i < ${#COMPREPLY[@]}; i++)); do - case ${COMPREPLY[i]} in - --*=) ;; - -*) COMPREPLY[i]+=" " - esac - done + for ((i = 0; i < ${#COMPREPLY[@]}; i++)); do + case ${COMPREPLY[i]} in + --*=) ;; + -*) COMPREPLY[i]+=" " + esac + done - return 0 + return 0 } complete -o filenames -o noquote -o nospace -F _polybar polybar