diff --git a/.config/polybar/launch.sh b/.config/polybar/launch.sh index fae12c2..d0a4b35 100755 --- a/.config/polybar/launch.sh +++ b/.config/polybar/launch.sh @@ -24,7 +24,7 @@ if ! pgrep -ax polybar >/dev/null 2>&1; then primary="$(xrandr -q | grep primary | cut -d' ' -f1)" for m in $(polybar --list-monitors | cut -d':' -f1); do export TRAY_POS=none - [ "$m" != "$primary" ] || export TRAY_POS=right + [[ "$m" != "$primary" ]] || export TRAY_POS=right export MONITOR="$m" polybar --reload -c "$BASE_DIR/config" main & done diff --git a/.config/polybar/scripts/battery.sh b/.config/polybar/scripts/battery.sh index 697e9a0..fe31803 100755 --- a/.config/polybar/scripts/battery.sh +++ b/.config/polybar/scripts/battery.sh @@ -17,13 +17,13 @@ declare -a ramp ramp=(          ) # display in red when under $low and no charger is connected -[ "$bat" -gt "$low" ] || [ "$ac" -eq 1 ] || color="$red" +[[ "$bat" -gt "$low" || "$ac" -eq 1 ]] || color="$red" # display in green when over $full and a charger is connected -[ "$bat" -lt "$full" ] || [ "$ac" -eq 0 ] || color="$green" +[[ "$bat" -lt "$full" || "$ac" -eq 0 ]] || color="$green" let "icon_index = $bat / (${#ramp[@]} - 1)" -[ $icon_index -lt ${#ramp[@]} ] || icond_index=10 +[[ $icon_index -lt ${#ramp[@]} ]] || icond_index=10 icon="${ramp[$icon_index]}" -[ "$ac" -eq 0 ] || charge="" +[[ "$ac" -eq 0 ]] || charge="" echo "${color}${icon}${charge} ${bat}%" diff --git a/.config/polybar/scripts/bluetooth.sh b/.config/polybar/scripts/bluetooth.sh index 5414c35..b47ee59 100755 --- a/.config/polybar/scripts/bluetooth.sh +++ b/.config/polybar/scripts/bluetooth.sh @@ -3,7 +3,7 @@ bluetooth_print() { bluetoothctl | while read -r; do - if [ "$(systemctl is-active "bluetooth.service")" = "active" ]; then + if [[ "$(systemctl is-active "bluetooth.service")" = "active" ]]; then devices_paired=$(echo paired-devices | bluetoothctl | sed -n '/paired-devices/,$p' | grep Device | cut -d ' ' -f 2) counter=0 @@ -14,7 +14,7 @@ bluetooth_print() { if echo "$device_info" | grep -q "Connected: yes"; then device_alias=$(echo "$device_info" | grep "Alias" | cut -d ' ' -f 2-) - if [ $counter -gt 0 ]; then + if [[ $counter -gt 0 ]]; then printf ", %s" "$device_alias" else printf ": %s" "$device_alias" diff --git a/.config/rofi/powermenu.sh b/.config/rofi/powermenu.sh index 3513f41..f635b63 100755 --- a/.config/rofi/powermenu.sh +++ b/.config/rofi/powermenu.sh @@ -27,7 +27,7 @@ function scheduled_suspend { # make sure the input was a valid number # side effect: 0 minutes is not possible - [ "$min" -ne 0 ] || exit 1 + [[ "$min" -ne 0 ]] || exit 1 notify-send "suspend in" "$min minutes" sleep $((min*60)) && systemctl suspend @@ -37,15 +37,15 @@ function scheduled_suspend { # Note: bash does not keep the order of the keys thus they get sorted chosen="$(printf '%s\n' "${!entries[@]}" | sort | rofi "${rofi_args[@]}" "power: ")" # exit if nothing was selected -[ -n "$chosen" ] || exit 1 +[[ -n "$chosen" ]] || exit 1 # handle scheduled suspend different -[ "$chosen" != "suspend (scheduled)" ] || { ${entries[$chosen]}; exit $?; } +[[ "$chosen" != "suspend (scheduled)" ]] || { ${entries[$chosen]}; exit $?; } # Confirm choice yesNo="$(echo -e "yes\nno" | rofi "${rofi_args[@]}" "Are you sure you want to ${chosen}? ")" # Exit if "No" -[ "$yesNo" == "yes" ] || exit 1 +[[ "$yesNo" == "yes" ]] || exit 1 # Execute ${entries[$chosen]} diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 326dd53..01bdba1 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -2,7 +2,7 @@ ## Created: 2018-11-23 # Set terminals title if this is a scratchpad-terminal -[ -z "$SCRATCHPAD_TERMINAL" ] || printf "\x1b\x5d\x30\x3bscratchpad-terminal\x07" +[[ -z "$SCRATCHPAD_TERMINAL" ]] || printf "\x1b\x5d\x30\x3bscratchpad-terminal\x07" # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc. # Initialization code that may require console input (password prompts, [y/n] @@ -16,7 +16,7 @@ ZSH_CONF="$ZDOTDIR/plugins" # https://github.com/romkatv/dotfiles-public/blob/7e49fc4fb71d/.zshrc#L35 comp-conf() { emulate -L zsh - [ ! "$1.zwc" -nt "$1" ] && [ -w "${1:h}" ] || return 0 + [[ ! "$1.zwc" -nt "$1" && -w "${1:h}" ]] || return 0 zmodload -F zsh/files b:zf_mv b:zf_rm local tmp="$1.tmp.$$.zwc" { @@ -29,7 +29,7 @@ comp-conf() { # https://github.com/romkatv/dotfiles-public/blob/7e49fc4fb71d/.zshrc#L47 comp-source() { emulate -L zsh - [ -e "$1" ] && comp-conf "$1" && source -- "$1" + [[ -e "$1" ]] && comp-conf "$1" && source -- "$1" } ## set zshoptions @@ -70,21 +70,21 @@ autoload -U select-word-style && select-word-style bash ## Setup the prompt # use bright version of colors when printing bold if command -v dircolors >/dev/null 2>&1; then - if [ -e "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors" ]; then + if [[ -e "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors" ]]; then eval "$(dircolors -b "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors")" else eval "$(dircolors -b)" fi fi -if [ -e "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme" ]; then +if [[ -e "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme" ]]; then comp-source "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme" # To customize prompt, run `p10k configure` or edit $ZSH_CONF/p10k.zsh-theme. comp-source "$ZSH_CONF/p10k.zsh-theme" fi ## Setup zsh completion system -[ ! -d "$ZSH_CONF/completion" ] || fpath=("$ZSH_CONF/completion" $fpath) +[[ ! -d "$ZSH_CONF/completion" ]] || fpath=("$ZSH_CONF/completion" $fpath) autoload -Uz compinit compinit -d "${XDG_CACHE_HOME:-$HOME/.cache}/zsh/zcompdump-$ZSH_VERSION" @@ -123,13 +123,13 @@ comp-source "$ZSH_CONF/fzf-tab/fzf-tab.plugin.zsh" autoload edit-command-line; zle -N edit-command-line ! alias run-help >/dev/null 2>&1 || unalias run-help autoload run-help run-help-git zmv -if [ -d "$ZDOTDIR/autoload" ]; then +if [[ -d "$ZDOTDIR/autoload" ]]; then fpath=("$ZDOTDIR/autoload" $fpath) autoload -Uz -- "" "${fpath[1]}"/[^_.]*(.xN:t) fi ! command -v direnv >/dev/null 2>&1 || eval "$(direnv hook zsh)" # stderred -if [ -e "$ZSH_CONF/stderred/build/libstderred.so" ]; then +if [[ -e "$ZSH_CONF/stderred/build/libstderred.so" ]]; then export LD_PRELOAD="$ZSH_CONF/stderred/build/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}" export STDERRED_ESC_CODE="$(tput bold && tput setaf 1)" export STDERRED_BLACKLIST="^(git|curl|wget|swipl)$" @@ -143,7 +143,7 @@ comp-source "$ZSH_CONF/completion.zsh" # async_init ### syntax-highlight > keys # syntax highlighting -if [ -e "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then +if [[ -e "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then comp-source "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" comp-source "$ZSH_CONF/zsh-syntax-highlighting.zsh-theme" fi @@ -164,7 +164,7 @@ elif command -v nano >/dev/null 2>&1; then fi # `sudo nano` won't work without this (?) -if [ "$TERM" = "xterm-kitty" ]; then +if [[ "$TERM" = "xterm-kitty" ]]; then export TERM=xterm-256color fi @@ -198,5 +198,5 @@ zle_highlight=('paste:none') ## History HISTSIZE=1000000 SAVEHIST=1000000 -[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/zsh" ] || mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/zsh" +[[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/zsh" ]] || mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/zsh" HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/.zsh_history" diff --git a/.config/zsh/autoload/clang-format b/.config/zsh/autoload/clang-format index 9a3fdb6..8f013e5 100755 --- a/.config/zsh/autoload/clang-format +++ b/.config/zsh/autoload/clang-format @@ -12,7 +12,7 @@ if (( ! idx )); then fi local style="${@[$idx]#-style}" prefix="" -if [ -n "$style" ]; then +if [[ -n "$style" ]]; then # Flag was given in form -style=