From 5f3d5ede350f9bfdacc528981de85f487d1705f6 Mon Sep 17 00:00:00 2001 From: Fabian 'xx4h' Sylvester Date: Sun, 14 Apr 2024 11:37:10 +0200 Subject: [PATCH] Cleanup * comply with shellfmt * activate shellfmt in super-linter --- .github/workflows/linter-full.yml | 5 +- .github/workflows/linter-pr.yml | 5 +- .github/workflows/stale.yml | 1 + color_palette.sh | 6 +- config/helpers.sh | 4 +- config/shell.sh | 10 +- generate_config.sh | 2 +- lib/arg_processing.sh | 4 +- lib/colors.sh | 12 +-- lib/config_file.sh | 8 +- lib/headers.sh | 2 +- lib/muting.sh | 2 +- lib/powerline.sh | 70 +++++++------- lib/text_roll.sh | 12 +-- lib/vcs_helper.sh | 5 +- main.tmux | 6 +- mute_powerline.sh | 2 +- powerline.sh | 2 +- segments/air.sh | 138 ++++++++++++++------------- segments/battery.sh | 138 ++++++++++++++------------- segments/cpu.sh | 10 +- segments/date.sh | 3 +- segments/date_week.sh | 5 +- segments/disk_usage.sh | 7 +- segments/earthquake.sh | 36 +++---- segments/gcalcli.sh | 22 ++--- segments/hostname.sh | 3 +- segments/ifstat.sh | 31 +++--- segments/ifstat_sys.sh | 6 +- segments/kubernetes_context.sh | 3 +- segments/lan_ip.sh | 9 +- segments/macos_notification_count.sh | 9 +- segments/mailcount.sh | 42 ++++---- segments/mode_indicator.sh | 5 +- segments/now_playing.sh | 88 ++++++++--------- segments/pwd.sh | 7 +- segments/rainbarf.sh | 2 +- segments/time.sh | 3 +- segments/tmux_mem_cpu_load.sh | 9 +- segments/tmux_session_info.sh | 3 +- segments/utc_time.sh | 3 +- segments/vcs_branch.sh | 16 ++-- segments/vcs_compare.sh | 14 +-- segments/vcs_modified.sh | 20 ++-- segments/vcs_others.sh | 20 ++-- segments/vcs_revision.sh | 10 +- segments/vcs_rootpath.sh | 10 +- segments/vcs_staged.sh | 17 ++-- segments/vpn.sh | 42 ++++---- segments/wan_ip.sh | 7 +- segments/weather.sh | 113 +++++++++++----------- segments/xkb_layout.sh | 3 +- themes/bubble.sh | 77 ++++++++------- themes/default.sh | 78 +++++++-------- 54 files changed, 584 insertions(+), 583 deletions(-) diff --git a/.github/workflows/linter-full.yml b/.github/workflows/linter-full.yml index 9fd3863a..6a09b928 100644 --- a/.github/workflows/linter-full.yml +++ b/.github/workflows/linter-full.yml @@ -1,3 +1,4 @@ +--- name: Lint Code Base on: @@ -20,7 +21,8 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - # Full git history is needed to get a proper list of changed files within `super-linter` + # Full git history is needed to get a proper list of changed + # files within `super-linter` fetch-depth: 0 - name: Lint Code Base uses: super-linter/super-linter@v6.3.1 @@ -30,6 +32,5 @@ jobs: VALIDATE_BASH_EXEC: false VALIDATE_CPP: false VALIDATE_CLANG_FORMAT: false - VALIDATE_SHELL_SHFMT: false VALIDATE_PYTHON_PYLINT: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/linter-pr.yml b/.github/workflows/linter-pr.yml index c0b007a3..d9748bbe 100644 --- a/.github/workflows/linter-pr.yml +++ b/.github/workflows/linter-pr.yml @@ -1,3 +1,4 @@ +--- name: Lint Pull Request on: @@ -20,7 +21,8 @@ jobs: - name: Checkout Code uses: actions/checkout@v4 with: - # Full git history is needed to get a proper list of changed files within `super-linter` + # Full git history is needed to get a proper list of changed + # files within `super-linter` fetch-depth: 0 - name: Lint Code Base uses: super-linter/super-linter@v6 @@ -30,6 +32,5 @@ jobs: VALIDATE_BASH_EXEC: false VALIDATE_CPP: false VALIDATE_CLANG_FORMAT: false - VALIDATE_SHELL_SHFMT: false VALIDATE_PYTHON_PYLINT: false GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index be304669..a2059e57 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,3 +1,4 @@ +--- name: "Close stale issues and PRs" on: workflow_dispatch: diff --git a/color_palette.sh b/color_palette.sh index ba8c87b6..d596fdce 100755 --- a/color_palette.sh +++ b/color_palette.sh @@ -3,12 +3,12 @@ # Idea from http://superuser.com/questions/285381/how-does-the-tmux-color-palette-work for i in $(seq 0 8 255); do - for j in $(seq "$i" $(( i + 7 ))); do - for _unused in $(seq 1 $(( 7 - ${#j} ))); do + for j in $(seq "$i" $((i + 7))); do + for _unused in $(seq 1 $((7 - ${#j}))); do echo -n " " done echo -en "\x1b[38;5;${j}mcolour${j}" - [[ $(( j % 8 )) != 7 ]] && echo -n " " + [[ $((j % 8)) != 7 ]] && echo -n " " done echo done diff --git a/config/helpers.sh b/config/helpers.sh index ebe39502..77dc5ef8 100644 --- a/config/helpers.sh +++ b/config/helpers.sh @@ -2,9 +2,9 @@ # Other settings and helper functions. debug_mode_enabled() { - [ -n "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" ] && [ "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" != "false" ]; + [ -n "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" ] && [ "$TMUX_POWERLINE_DEBUG_MODE_ENABLED" != "false" ] } patched_font_in_use() { - [ -z "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" ] || [ "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" != "false" ]; + [ -z "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" ] || [ "$TMUX_POWERLINE_PATCHED_FONT_IN_USE" != "false" ] } diff --git a/config/shell.sh b/config/shell.sh index 3d5a3be5..1bf7613d 100644 --- a/config/shell.sh +++ b/config/shell.sh @@ -7,14 +7,14 @@ ostype() { echo "$OSTYPE" | tr '[:upper:]' '[:lower:]'; } export SHELL_PLATFORM='unknown' case "$(ostype)" in - *'linux'* ) SHELL_PLATFORM='linux' ;; - *'darwin'* ) SHELL_PLATFORM='osx' ;; - *'bsd'* ) SHELL_PLATFORM='bsd' ;; +*'linux'*) SHELL_PLATFORM='linux' ;; +*'darwin'*) SHELL_PLATFORM='osx' ;; +*'bsd'*) SHELL_PLATFORM='bsd' ;; esac shell_is_linux() { [[ $SHELL_PLATFORM == 'linux' || $SHELL_PLATFORM == 'bsd' ]]; } -shell_is_osx() { [[ $SHELL_PLATFORM == 'osx' ]]; } -shell_is_bsd() { [[ $SHELL_PLATFORM == 'bsd' || $SHELL_PLATFORM == 'osx' ]]; } +shell_is_osx() { [[ $SHELL_PLATFORM == 'osx' ]]; } +shell_is_bsd() { [[ $SHELL_PLATFORM == 'bsd' || $SHELL_PLATFORM == 'osx' ]]; } export -f shell_is_linux export -f shell_is_osx diff --git a/generate_config.sh b/generate_config.sh index 1c7ab917..878de349 100755 --- a/generate_config.sh +++ b/generate_config.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Generate default config file. -TMUX_POWERLINE_DIR_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +TMUX_POWERLINE_DIR_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export TMUX_POWERLINE_DIR_HOME source "${TMUX_POWERLINE_DIR_HOME}/config/paths.sh" diff --git a/lib/arg_processing.sh b/lib/arg_processing.sh index a288d43b..73fa480d 100644 --- a/lib/arg_processing.sh +++ b/lib/arg_processing.sh @@ -3,8 +3,8 @@ check_arg_segment() { local segment="$1" - if ! [[ "$segment" == "left" || "$segment" == "right" || "$segment" == "window-current-format" || "$segment" == "window-format" ]]; then + if ! [[ "$segment" == "left" || "$segment" == "right" || "$segment" == "window-current-format" || "$segment" == "window-format" ]]; then echo "Argument must be the side to handle {left, right}, or {window-current-format, window-format}, not \"${segment}\"." - exit 1 + exit 1 fi } diff --git a/lib/colors.sh b/lib/colors.sh index 44e04026..aaf3099d 100644 --- a/lib/colors.sh +++ b/lib/colors.sh @@ -19,12 +19,12 @@ __normalize_color() { local result case "$input" in - [0-9]|[0-9][0-9]|[0-9][0-9][0-9]) # handle 1 to 3 digits - result="colour$input" - ;; - *) # Catch-all - result=$input - ;; + [0-9] | [0-9][0-9] | [0-9][0-9][0-9]) # handle 1 to 3 digits + result="colour$input" + ;; + *) # Catch-all + result=$input + ;; esac echo -n "$result" diff --git a/lib/config_file.sh b/lib/config_file.sh index 7630fed0..899e910a 100644 --- a/lib/config_file.sh +++ b/lib/config_file.sh @@ -80,12 +80,10 @@ process_settings() { export TMUX_POWERLINE_STATUS_STYLE="fg=$fg_color,bg=$bg_color" fi - - } generate_default_config() { - read -r -d '' config_contents << EORC + read -r -d '' config_contents < "$TMUX_POWERLINE_CONFIG_FILE_DEFAULT" + echo -e "$config_contents" >"$TMUX_POWERLINE_CONFIG_FILE_DEFAULT" echo "Default configuration file generated to: ${TMUX_POWERLINE_CONFIG_FILE_DEFAULT}" echo "Copy/move it to \"${TMUX_POWERLINE_CONFIG_FILE}\" and make your changes." } __read_config_file() { - if [ -f "$TMUX_POWERLINE_CONFIG_FILE" ]; then + if [ -f "$TMUX_POWERLINE_CONFIG_FILE" ]; then # shellcheck disable=SC1090 source "$TMUX_POWERLINE_CONFIG_FILE" fi diff --git a/lib/headers.sh b/lib/headers.sh index 73409517..25e56e1a 100644 --- a/lib/headers.sh +++ b/lib/headers.sh @@ -2,7 +2,7 @@ # Source all needed libs and helpers, kind of like a main.h. if [ -z "$TMUX_POWERLINE_DIR_HOME" ]; then - lib_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + lib_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" TMUX_POWERLINE_DIR_HOME="$(dirname "$lib_dir")" # step up to parent dir. export TMUX_POWERLINE_DIR_HOME diff --git a/lib/muting.sh b/lib/muting.sh index f37118c5..2e10af6b 100644 --- a/lib/muting.sh +++ b/lib/muting.sh @@ -3,7 +3,7 @@ # In all cases $1 is the side to be muted (eg left/right). powerline_muted() { - [ -e "$(__powerline_mute_file "$1")" ]; + [ -e "$(__powerline_mute_file "$1")" ] } toggle_powerline_mute_status() { diff --git a/lib/powerline.sh b/lib/powerline.sh index 6bc7c9e8..2066edb0 100644 --- a/lib/powerline.sh +++ b/lib/powerline.sh @@ -22,12 +22,12 @@ print_powerline_side() { print_powerline_window_status_current_format() { if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_CURRENT" ]; then TMUX_POWERLINE_WINDOW_STATUS_CURRENT=( - "#[$(format inverse)]" \ - "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" \ - " #I#F " \ - "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" \ - " #W " \ - "#[$(format regular)]" \ + "#[$(format inverse)]" + "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" + " #I#F " + "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" + " #W " + "#[$(format regular)]" "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" ) fi @@ -38,9 +38,9 @@ print_powerline_window_status_current_format() { print_powerline_window_status_format() { if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_FORMAT" ]; then TMUX_POWERLINE_WINDOW_STATUS_FORMAT=( - "#[$(format regular)]" \ - " #I#{?window_flags,#F, } " \ - "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" \ + "#[$(format regular)]" + " #I#{?window_flags,#F, } " + "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" " #W " ) fi @@ -57,14 +57,13 @@ format() { fg_color=$(__normalize_color "$TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR") case $type in - inverse) - echo "fg=$bg_color,bg=$fg_color,nobold,noitalics,nounderscore" - ;; - regular) - echo "fg=$fg_color,bg=$bg_color,nobold,noitalics,nounderscore" - ;; - *) - ;; + inverse) + echo "fg=$bg_color,bg=$fg_color,nobold,noitalics,nounderscore" + ;; + regular) + echo "fg=$fg_color,bg=$bg_color,nobold,noitalics,nounderscore" + ;; + *) ;; esac } @@ -72,16 +71,16 @@ __process_segment_defaults() { # shellcheck disable=SC2154 # disable until we found a better solution for eval input_segments for segment_index in "${!input_segments[@]}"; do local input_segment - read -r -a input_segment <<< "${input_segments[segment_index]}" + read -r -a input_segment <<<"${input_segments[segment_index]}" eval "local default_separator=\$TMUX_POWERLINE_DEFAULT_${upper_side}SIDE_SEPARATOR" powerline_segment_with_defaults=( - "${input_segment[0]:-no_script}" \ - "${input_segment[1]:-$TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR}" \ - "${input_segment[2]:-$TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" \ - "${input_segment[3]:-$default_separator}" \ - "${input_segment[6]:-$spacing_disable}" \ - "${input_segment[7]:-$separator_disable}" \ + "${input_segment[0]:-no_script}" + "${input_segment[1]:-$TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR}" + "${input_segment[2]:-$TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" + "${input_segment[3]:-$default_separator}" + "${input_segment[6]:-$spacing_disable}" + "${input_segment[7]:-$separator_disable}" ) powerline_segments[segment_index]="${powerline_segment_with_defaults[*]}" @@ -91,9 +90,9 @@ __process_segment_defaults() { __process_scripts() { for segment_index in "${!powerline_segments[@]}"; do local powerline_segment - read -r -a powerline_segment <<< "${powerline_segments[segment_index]}" + read -r -a powerline_segment <<<"${powerline_segments[segment_index]}" - if [ -n "$TMUX_POWERLINE_DIR_USER_SEGMENTS" ] && [ -f "$TMUX_POWERLINE_DIR_USER_SEGMENTS/${powerline_segment[0]}.sh" ] ; then + if [ -n "$TMUX_POWERLINE_DIR_USER_SEGMENTS" ] && [ -f "$TMUX_POWERLINE_DIR_USER_SEGMENTS/${powerline_segment[0]}.sh" ]; then local script="$TMUX_POWERLINE_DIR_USER_SEGMENTS/${powerline_segment[0]}.sh" else local script="$TMUX_POWERLINE_DIR_SEGMENTS/${powerline_segment[0]}.sh" @@ -109,7 +108,7 @@ __process_scripts() { local exit_code="$?" unset -f run_segment - if [ "$exit_code" -ne 0 ] && debug_mode_enabled ; then + if [ "$exit_code" -ne 0 ] && debug_mode_enabled; then local seg_name="${script##*/}" echo "Segment '${seg_name}' exited with code ${exit_code}. Aborting." exit 1 @@ -134,14 +133,14 @@ __process_scripts() { __process_colors() { for segment_index in "${!powerline_segments[@]}"; do local powerline_segment - read -r -a powerline_segment <<< "${powerline_segments[segment_index]}" + read -r -a powerline_segment <<<"${powerline_segments[segment_index]}" local separator_enable=${powerline_segment[5]} # Find the next segment that produces content (i.e. skip empty segments). - for next_segment_index in $(eval echo "{$((segment_index + 1))..${#powerline_segments}}") ; do + for next_segment_index in $(eval echo "{$((segment_index + 1))..${#powerline_segments}}"); do [[ -n ${powerline_segments[next_segment_index]} ]] && break done local next_segment - read -r -a next_segment <<< "${powerline_segments[next_segment_index]}" + read -r -a next_segment <<<"${powerline_segments[next_segment_index]}" if [ "$side" == 'left' ]; then powerline_segment[4]=${next_segment[1]:-$TMUX_POWERLINE_DEFAULT_BACKGROUND_COLOR} @@ -165,7 +164,7 @@ __process_colors() { __process_powerline() { for segment_index in "${!powerline_segments[@]}"; do local powerline_segment - read -r -a powerline_segment <<< "${powerline_segments[segment_index]}" + read -r -a powerline_segment <<<"${powerline_segments[segment_index]}" local background_color=${powerline_segment[1]} local foreground_color=${powerline_segment[2]} @@ -188,7 +187,7 @@ __print_left_segment() { local separator_disable=$7 __print_colored_content "$content" "$content_background_color" "$content_foreground_color" - if [ ! "$separator_disable" == "separator_disable" ] ; then + if [ ! "$separator_disable" == "separator_disable" ]; then __print_colored_content "$separator" "$separator_background_color" "$separator_foreground_color" fi } @@ -202,19 +201,18 @@ __print_right_segment() { local separator_foreground_color=$6 local separator_disable=$7 - if [ ! "$separator_disable" == "separator_disable" ] ; then + if [ ! "$separator_disable" == "separator_disable" ]; then __print_colored_content "$separator" "$separator_background_color" "$separator_foreground_color" fi __print_colored_content "$content" "$content_background_color" "$content_foreground_color" } __segment_separator_is_thin() { - [[ ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_LEFT_THIN" || \ - ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" ]]; + [[ ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_LEFT_THIN" || ${powerline_segment[3]} == "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" ]] } __check_platform() { if [ "$SHELL_PLATFORM" == "unknown" ] && debug_mode_enabled; then - echo "Unknown platform; modify config/shell.sh" >&2 + echo "Unknown platform; modify config/shell.sh" >&2 fi } diff --git a/lib/text_roll.sh b/lib/text_roll.sh index 21e77bed..05330a04 100644 --- a/lib/text_roll.sh +++ b/lib/text_roll.sh @@ -6,19 +6,19 @@ # arg4: mode to fill {"space", "repeat"} # arg5: repeat separator roll_text() { - local text="$1" # Text to print + local text="$1" # Text to print if [ -z "$text" ]; then - return; + return fi - local max_len="10" # Default max length. + local max_len="10" # Default max length. if [ -n "$2" ]; then max_len="$2" fi - local speed="1" # Default roll speed in chars per second. + local speed="1" # Default roll speed in chars per second. if [ -n "$3" ]; then speed="$3" @@ -60,13 +60,13 @@ roll_text() { # Truncate text on time-based offset text=${text:offset} - # Ensure text is not longer than max_len + # Ensure text is not longer than max_len text=${text:0:max_len} # Get fill count by substracting length of current text from max_len local fill_count=$((max_len - ${#text})) - for ((index=0; index < fill_count; index++)); do + for ((index = 0; index < fill_count; index++)); do if [ "$fill_mode" = "repeat" ]; then text="${text}${repeat:index:1}" elif [ "$fill_mode" = "space" ] || :; then diff --git a/lib/vcs_helper.sh b/lib/vcs_helper.sh index 293476a0..15915bf0 100644 --- a/lib/vcs_helper.sh +++ b/lib/vcs_helper.sh @@ -3,7 +3,6 @@ # shellcheck source=lib/tmux_adapter.sh source "${TMUX_POWERLINE_DIR_LIB}/tmux_adapter.sh" - get_vcs_type_and_root_path() { tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return @@ -51,14 +50,14 @@ __parse_svn_root_path() { } __get_closest_root_path() { - VCS_TYPES=( git hg svn ) + VCS_TYPES=(git hg svn) path_id=0 highest=0 root_path="" counter=0 for path in "$@"; do [ "${#path}" -gt "$highest" ] && highest="${#path}" && root_path="${path}" && path_id=$counter - counter=$((counter+1)) + counter=$((counter + 1)) done echo -en "${VCS_TYPES[${path_id}]}\n${root_path}" } diff --git a/main.tmux b/main.tmux index 8588dbdc..2883cb77 100755 --- a/main.tmux +++ b/main.tmux @@ -5,7 +5,7 @@ set -o errexit set -o pipefail -TMUX_POWERLINE_DIR_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +TMUX_POWERLINE_DIR_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export TMUX_POWERLINE_DIR_HOME # Obtain the left/right status length settings by reading the tmux-powerline config. @@ -39,8 +39,8 @@ if [ "$TMUX_POWERLINE_STATUS_VISIBILITY" = "2" ]; then window_status=1 left_right_status=0 fi - tmux set-option -g status-format["$window_status"] "${TMUX_POWERLINE_STATUS_FORMAT_WINDOW:-${TMUX_POWERLINE_STATUS_FORMAT_WINDOW_DEFAULT}}" - tmux set-option -g status-format["$left_right_status"] "${TMUX_POWERLINE_STATUS_FORMAT_LEFT:-${TMUX_POWERLINE_STATUS_FORMAT_LEFT_DEFAULT}}" + tmux set-option -g status-format["$window_status"] "${TMUX_POWERLINE_STATUS_FORMAT_WINDOW:-${TMUX_POWERLINE_STATUS_FORMAT_WINDOW_DEFAULT}}" + tmux set-option -g status-format["$left_right_status"] "${TMUX_POWERLINE_STATUS_FORMAT_LEFT:-${TMUX_POWERLINE_STATUS_FORMAT_LEFT_DEFAULT}}" tmux set-option -ag status-format["$left_right_status"] "${TMUX_POWERLINE_STATUS_FORMAT_RIGHT:-${TMUX_POWERLINE_STATUS_FORMAT_RIGHT_DEFAULT}}" fi diff --git a/mute_powerline.sh b/mute_powerline.sh index 1523c88c..8d91bc64 100755 --- a/mute_powerline.sh +++ b/mute_powerline.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -TMUX_POWERLINE_DIR_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +TMUX_POWERLINE_DIR_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export TMUX_POWERLINE_DIR_HOME source "${TMUX_POWERLINE_DIR_HOME}/config/paths.sh" diff --git a/powerline.sh b/powerline.sh index 90007ca4..2427a5db 100755 --- a/powerline.sh +++ b/powerline.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -TMUX_POWERLINE_DIR_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +TMUX_POWERLINE_DIR_HOME="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export TMUX_POWERLINE_DIR_HOME # shellcheck source=lib/headers.sh diff --git a/segments/air.sh b/segments/air.sh index 73c4408a..2d825a64 100755 --- a/segments/air.sh +++ b/segments/air.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_AIR_DATA_PROVIDER_DEFAULT="openweather" TMUX_POWERLINE_SEG_AIR_JSON_DEFAULT="jq" TMUX_POWERLINE_SEG_AIR_UPDATE_PERIOD_DEFAULT="600" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents < $max" | bc -l) )); then + if (($(echo "$n2 > $max" | bc -l))); then max=$n2 fi - if (( $(echo "$n3 > $max" | bc -l) )); then + if (($(echo "$n3 > $max" | bc -l))); then max=$n3 fi - if (( $(echo "$n4 > $max" | bc -l) )); then + if (($(echo "$n4 > $max" | bc -l))); then max=$n4 fi - if (( $(echo "$n5 > $max" | bc -l) )); then + if (($(echo "$n5 > $max" | bc -l))); then max=$n5 fi - if (( $(echo "$n6 > $max" | bc -l) )); then + if (($(echo "$n6 > $max" | bc -l))); then max=$n6 fi echo "$max" } -__get_aqi_level_color_symbol(){ +__get_aqi_level_color_symbol() { local aqi_value=$1 - if (( $(echo "$aqi_value < 51" | bc -l) )); then + if (($(echo "$aqi_value < 51" | bc -l))); then # aqi_level="Good" aqi_color="#8da101" # Green aqi_symbol="😊" - elif (( $(echo "$aqi_value < 101" | bc -l) )); then + elif (($(echo "$aqi_value < 101" | bc -l))); then # aqi_level="Moderate" aqi_color="#dfa000" # Yellow aqi_symbol="😐" - elif (( $(echo "$aqi_value < 151" | bc -l) )); then + elif (($(echo "$aqi_value < 151" | bc -l))); then # aqi_level="Unhealthy for sensitive groups" aqi_color="#f57d26" # Orange aqi_symbol="πŸ™" - elif (( $(echo "$aqi_value < 201" | bc -l) )); then + elif (($(echo "$aqi_value < 201" | bc -l))); then # aqi_level="Unhealthy" aqi_color="#f85552" # Red aqi_symbol="😷" - elif (( $(echo "$aqi_value < 301" | bc -l) )); then + elif (($(echo "$aqi_value < 301" | bc -l))); then # aqi_level="Very unhealthy" aqi_color="#df69ba" # Purple aqi_symbol="😨" - elif (( $(echo "$aqi_value < 501" | bc -l) )); then + elif (($(echo "$aqi_value < 501" | bc -l))); then # aqi_level="Hazardous" aqi_color="#883A26" # Maroon aqi_symbol="πŸ›‘" - elif (( $(echo "$aqi_value < 1001" | bc -l) )); then + elif (($(echo "$aqi_value < 1001" | bc -l))); then # aqi_level="Very Hazardous" aqi_color="#66401a" # Brown aqi_symbol="πŸ’€" diff --git a/segments/battery.sh b/segments/battery.sh index e36c59b5..b98a9a20 100755 --- a/segments/battery.sh +++ b/segments/battery.sh @@ -10,9 +10,8 @@ BATTERY_EMPTY="󱊑" BATTERY_CHARGE="σ°‚„" ADAPTER="σ°š₯" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <} @@ -106,9 +106,9 @@ __goo_earthquake() { __convert_jp_magnitude __convert_jp_timestamp - echo "$location" > "$tmp_file" - echo "$magnitude" >> "$tmp_file" - echo "$timestamp" >> "$tmp_file" + echo "$location" >"$tmp_file" + echo "$magnitude" >>"$tmp_file" + echo "$timestamp" >>"$tmp_file" elif [ -f "$tmp_file" ]; then __read_tmp_file fi @@ -119,7 +119,7 @@ __goo_earthquake() { magnitude_number=$(echo "$magnitude" | sed -e 's/+//' -e 's/-//') if [ -n "$magnitude" ]; then - if __check_alert_time_window && __check_min_magnitude ; then + if __check_alert_time_window && __check_min_magnitude; then echo "${location}${timestamp_fmt}:#[fg=colour0]${magnitude}" fi fi @@ -128,15 +128,15 @@ __goo_earthquake() { __convert_jp_magnitude() { magnitude=${magnitude#ιœ‡εΊ¦} # simplify high-lower designation (only used in extreme cases: above 4) - if [[ "$magnitude" == *εΌ± ]] ; then + if [[ "$magnitude" == *εΌ± ]]; then magnitude="-${magnitude%εΌ±}" - elif [[ "$magnitude" == *εΌ· ]] ; then + elif [[ "$magnitude" == *εΌ· ]]; then magnitude="+${magnitude%εΌ·}" fi } __check_alert_time_window() { - [[ $(( ( $(date +%s) - timestamp ) / 60 )) -lt $TMUX_POWERLINE_SEG_EARTHQUAKE_ALERT_TIME_WINDOW ]] + [[ $((($(date +%s) - timestamp) / 60)) -lt $TMUX_POWERLINE_SEG_EARTHQUAKE_ALERT_TIME_WINDOW ]] } __check_min_magnitude() { @@ -144,7 +144,7 @@ __check_min_magnitude() { } __convert_jp_timestamp() { - if shell_is_osx ; then + if shell_is_osx; then timestamp=$(date -j -f "%YεΉ΄%m月%dζ—₯ %Hζ™‚%Mεˆ†" "$timestamp" +"%s") else timestamp=$(echo "$timestamp" | sed -e 's/εΉ΄/-/' -e 's/月/-/' -e 's/ζ—₯//' -e 's/ζ™‚/:/' -e 's/εˆ†//') @@ -153,7 +153,7 @@ __convert_jp_timestamp() { } __convert_timestamp_to_fmt() { - if shell_is_osx ; then + if shell_is_osx; then timestamp_fmt=$(date -r "$timestamp" +"$TMUX_POWERLINE_SEG_EARTHQUAKE_TIME_FORMAT") else timestamp_fmt=$(date -d "$timestamp" +"$TMUX_POWERLINE_SEG_EARTHQUAKE_TIME_FORMAT") @@ -166,7 +166,7 @@ __read_tmp_file() { fi IFS_bak="$IFS" IFS=$'\n' - read -r -a lines <<< "${tmp_file}" + read -r -a lines <<<"${tmp_file}" IFS="$IFS_bak" location="${lines[0]}" magnitude="${lines[1]}" diff --git a/segments/gcalcli.sh b/segments/gcalcli.sh index b6bb2341..3389a702 100755 --- a/segments/gcalcli.sh +++ b/segments/gcalcli.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT="${TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT:-1}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # gcalcli uses 24hr time format by default - if you want to see 12hr time format, set TMUX_POWERLINE_SEG_GCALCLI_MILITARY_TIME_DEFAULT to 0 export TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT="${TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT}" EORC @@ -13,15 +12,14 @@ EORC } run_segment() { - if ! command -v gcalcli &> /dev/null - then - echo "'gcalcli' could not be found" - return 1 - fi - gcmd=(gcalcli agenda) - if [[ $TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT == 0 ]]; then - gcmd+=(--no-military) - fi - "${gcmd[@]}" | head -2 | tail -1 | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | sed -E 's/ +/ /g' + if ! command -v gcalcli &>/dev/null; then + echo "'gcalcli' could not be found" + return 1 + fi + gcmd=(gcalcli agenda) + if [[ $TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT == 0 ]]; then + gcmd+=(--no-military) + fi + "${gcmd[@]}" | head -2 | tail -1 | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | sed -E 's/ +/ /g' return 0 } diff --git a/segments/hostname.sh b/segments/hostname.sh index 40cb09f8..97823f4e 100755 --- a/segments/hostname.sh +++ b/segments/hostname.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="${TMUX_POWERLINE_SEG_HOSTNAME_FORMAT:-short}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Use short or long format for the hostname. Can be {"short, long"}. export TMUX_POWERLINE_SEG_HOSTNAME_FORMAT="${TMUX_POWERLINE_SEG_HOSTNAME_FORMAT}" EORC diff --git a/segments/ifstat.sh b/segments/ifstat.sh index 93346caa..3a8a507f 100755 --- a/segments/ifstat.sh +++ b/segments/ifstat.sh @@ -9,9 +9,8 @@ TMUX_POWERLINE_SEG_IFSTAT_WWAN_SYMBOL="${TMUX_POWERLINE_SEG_IFSTAT_WWAN_SYMBOL:- TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_SEPARATOR="${TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_SEPARATOR:- | }" TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_EXCLUDES="${TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_EXCLUDES:-^u?tun[0-9]+$}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol for Download. # export TMUX_POWERLINE_SEG_IFSTAT_DOWN_SYMBOL="${TMUX_POWERLINE_SEG_IFSTAT_DOWN_SYMBOL}" # Symbol for Upload. @@ -46,7 +45,7 @@ run_segment() { symbol_down=$TMUX_POWERLINE_SEG_IFSTAT_DOWN_SYMBOL symbol_up=$TMUX_POWERLINE_SEG_IFSTAT_UP_SYMBOL - read -r -a excludes <<< "$TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_EXCLUDES" + read -r -a excludes <<<"$TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_EXCLUDES" data=$(ifstat -z -q 1 1) IFS=$' ' read -r -a interfaces < <(echo -e "${data}" | head -n 1) IFS=$' ' read -r -a flow_data < <(echo -e "${data}" | tail -n 1) @@ -57,21 +56,25 @@ run_segment() { done type="" case ${inf} in - eth*|en*) type="$TMUX_POWERLINE_SEG_IFSTAT_ETHERNET_SYMBOL" - ;; - wl*) type="$TMUX_POWERLINE_SEG_IFSTAT_WLAN_SYMBOL" - ;; - ww*) type="$TMUX_POWERLINE_SEG_IFSTAT_WWAN_SYMBOL" - ;; - *) type="${inf:0:3}*" - ;; + eth* | en*) + type="$TMUX_POWERLINE_SEG_IFSTAT_ETHERNET_SYMBOL" + ;; + wl*) + type="$TMUX_POWERLINE_SEG_IFSTAT_WLAN_SYMBOL" + ;; + ww*) + type="$TMUX_POWERLINE_SEG_IFSTAT_WWAN_SYMBOL" + ;; + *) + type="${inf:0:3}*" + ;; esac - ifstat_seg+=("$(printf "$type $symbol_down %.1f $symbol_up %.1f" "${flow_data[$index]}" "${flow_data[$((index+1))]}")") - index=$((index+2)) + ifstat_seg+=("$(printf "$type $symbol_down %.1f $symbol_up %.1f" "${flow_data[$index]}" "${flow_data[$((index + 1))]}")") + index=$((index + 2)) done if [ "${#ifstat_seg}" -gt 0 ]; then output="" - for (( i=0; i < "${#ifstat_seg[@]}"; i++)); do + for ((i = 0; i < "${#ifstat_seg[@]}"; i++)); do [ "$i" -gt 0 ] && output="${output}${TMUX_POWERLINE_SEG_IFSTAT_INTERFACE_SEPARATOR}" output="${output}${ifstat_seg[$i]}" done diff --git a/segments/ifstat_sys.sh b/segments/ifstat_sys.sh index c8c184a0..5c201c25 100755 --- a/segments/ifstat_sys.sh +++ b/segments/ifstat_sys.sh @@ -27,8 +27,8 @@ run_segment() { RXBN=$(</sys/class/net/"$iface"/statistics/rx_bytes) TXBN=$(</sys/class/net/"$iface"/statistics/tx_bytes) fi - RXDIF=$(echo "$((RXBN - RXB)) / 1024 / ${sleeptime}" | bc ) - TXDIF=$(echo "$((TXBN - TXB)) / 1024 / ${sleeptime}" | bc ) + RXDIF=$(echo "$((RXBN - RXB)) / 1024 / ${sleeptime}" | bc) + TXDIF=$(echo "$((TXBN - TXB)) / 1024 / ${sleeptime}" | bc) if [ "$RXDIF" -gt 1024 ]; then RXDIF=$(echo "scale=1;${RXDIF} / 1024" | bc) @@ -44,6 +44,6 @@ run_segment() { fi # NOTE: '%5.01' for fixed length always - printf "${type} β‡Š %5.01f${RXDIF_UNIT} β‡ˆ %5.01f${TXDIF_UNIT}" "${RXDIF}" "${TXDIF}" + printf "${type} β‡Š %5.01f${RXDIF_UNIT} β‡ˆ %5.01f${TXDIF_UNIT}" "${RXDIF}" "${TXDIF}" return 0 } diff --git a/segments/kubernetes_context.sh b/segments/kubernetes_context.sh index b76935d5..3a0700b2 100644 --- a/segments/kubernetes_context.sh +++ b/segments/kubernetes_context.sh @@ -4,9 +4,8 @@ TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_SYMBOL="${TMUX_POWERLINE_SEG_KUBERNETES_CO TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_SYMBOL_COLOUR:-255}" TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_SEPARATOR="${TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_SEPARATOR:-󰿟}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Kubernetes config context display mode {"name_namespace", "name", "namespace"}. # export TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_DISPLAY_MODE="${TMUX_POWERLINE_SEG_KUBERNETES_CONTEXT_DISPLAY_MODE}" # Kubernetes config context symbol. diff --git a/segments/lan_ip.sh b/segments/lan_ip.sh index d9b55c73..3ffa4a6f 100755 --- a/segments/lan_ip.sh +++ b/segments/lan_ip.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_LAN_IP_SYMBOL="${TMUX_POWERLINE_SEG_LAN_IP_SYMBOL:-β“› }" TMUX_POWERLINE_SEG_LAN_IP_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_LAN_IP_SYMBOL_COLOUR:-255}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol for LAN IP. # export TMUX_POWERLINE_SEG_LAN_IP_SYMBOL="${TMUX_POWERLINE_SEG_LAN_IP_SYMBOL}" # Symbol colour for LAN IP @@ -15,10 +14,10 @@ EORC } run_segment() { - if shell_is_bsd || shell_is_osx ; then + if shell_is_bsd || shell_is_osx; then default_route_nic=$(route get default | grep -i interface | awk '{print $2}') all_nics=$(ifconfig 2>/dev/null | awk -F':' '/^[a-z]/ && !/^lo/ { print $1 }' | tr '\n' ' ') - IFS=' ' read -ra all_nics_array <<< "$all_nics" + IFS=' ' read -ra all_nics_array <<<"$all_nics" # the nic of the default route is considered first all_nics_array=("$default_route_nic" "${all_nics_array[@]}") for nic in "${all_nics_array[@]}"; do @@ -32,7 +31,7 @@ run_segment() { default_route_nic=$(ip route get 1.1.1.1 | grep -o "dev.*" | cut -d ' ' -f 2) # Get the names of all attached NICs. all_nics="$(ip addr show | cut -d ' ' -f2 | tr -d :)" - all_nics=("${all_nics[@]/lo/}") # Remove lo interface. + all_nics=("${all_nics[@]/lo/}") # Remove lo interface. # the nic of the default route is considered first all_nics=("$default_route_nic" "${all_nics[@]}") diff --git a/segments/macos_notification_count.sh b/segments/macos_notification_count.sh index 8a197d0c..554cd815 100755 --- a/segments/macos_notification_count.sh +++ b/segments/macos_notification_count.sh @@ -3,18 +3,17 @@ # Based on http://www.ign.com/boards/threads/a-crumby-way-to-get-an-unread-count-of-imessages-into-applescript.453061379/ # 118 = messages -# 51 = slack +# 51 = slack TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS="${TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS:-118}" TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_CHAR="${TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_CHAR:-πŸ’¬}" - generate_segmentrc() { # Don't generate config entry if we're not on macOS if shell_is_linux || shell_is_bsd; then return 0 fi - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # App ids to query in notification center, separated by space # To get the app id that is associated with a specific app run: # sqlite3 -list "$(getconf DARWIN_USER_DIR)/com.apple.notificationcenter/db2/db" 'select * from app' @@ -32,7 +31,7 @@ EORC run_segment() { local db_location app_ids_array query_condition query_string count db_location="$(getconf DARWIN_USER_DIR)/com.apple.notificationcenter/db2/db" - read -r -a app_ids_array <<< "$TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS" + read -r -a app_ids_array <<<"$TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_APPIDS" query_condition="where app_id=${app_ids_array[0]}" for app_id in "${app_ids_array[@]:1}"; do query_condition="${query_condition} OR app_id=${app_id}" @@ -45,7 +44,7 @@ run_segment() { return $exitcode fi - if [[ -n "$count" && "$count" -gt 0 ]]; then + if [[ -n "$count" && "$count" -gt 0 ]]; then echo "${TMUX_POWERLINE_SEG_MACOS_NOTIFICATION_COUNT_CHAR} ${count}" fi diff --git a/segments/mailcount.sh b/segments/mailcount.sh index 7e68387f..a1cc2113 100755 --- a/segments/mailcount.sh +++ b/segments/mailcount.sh @@ -7,9 +7,8 @@ TMUX_POWERLINE_SEG_MAILCOUNT_MAILCHECKRC="${TMUX_POWERLINE_SEG_MAILCOUNT_MAILCHE TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER="${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER:-gmail.com}" TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_INTERVAL="${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_INTERVAL:-5}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Mailbox type to use. Can be any of {apple_mail, gmail, maildir, mbox, mailcheck} export TMUX_POWERLINE_SEG_MAILCOUNT_MAILBOX_TYPE="" @@ -50,21 +49,22 @@ run_segment() { local count case "$TMUX_POWERLINE_SEG_MAILCOUNT_MAILBOX_TYPE" in - "apple_mail") count=$(__count_apple_mail) ;; - "gmail") count=$(__count_gmail) ;; - "maildir") count=$(__count_maildir) ;; - "mbox") count=$(__count_mbox) ;; - "mailcheck") count=$(__count_mailcheck) ;; - *) - echo "Unknown mailbox type [${TMUX_POWERLINE_SEG_MAILCOUNT_MAILBOX_TYPE}]"; - return 1 + "apple_mail") count=$(__count_apple_mail) ;; + "gmail") count=$(__count_gmail) ;; + "maildir") count=$(__count_maildir) ;; + "mbox") count=$(__count_mbox) ;; + "mailcheck") count=$(__count_mailcheck) ;; + *) + echo "Unknown mailbox type [${TMUX_POWERLINE_SEG_MAILCOUNT_MAILBOX_TYPE}]" + return 1 + ;; esac local exitcode="$?" if [ "$exitcode" -ne 0 ]; then return $exitcode fi - if [[ -n "$count" && "$count" -gt 0 ]]; then + if [[ -n "$count" && "$count" -gt 0 ]]; then echo "βœ‰ ${count}" fi @@ -79,7 +79,7 @@ __count_apple_mail() { __count_gmail() { local tmp_file="${TMUX_POWERLINE_DIR_TEMPORARY}/gmail_count.txt" local tmp_wgetrc="${TMUX_POWERLINE_DIR_TEMPORARY}/tmp_wgetrc.txt" - local override_passget="false" # When true a force reloaded will be done. + local override_passget="false" # When true a force reloaded will be done. # Create the cache file if it doesn't exist. if [ ! -f "$tmp_file" ]; then @@ -88,13 +88,13 @@ __count_gmail() { fi # Refresh mail count if the tempfile is older than $interval minutes. - interval=$(( 60*TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_INTERVAL )) + interval=$((60 * TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_INTERVAL)) if shell_is_osx || shell_is_bsd; then last_update=$(stat -f "%m" "${tmp_file}") elif shell_is_linux; then last_update=$(stat -c "%Y" "${tmp_file}") fi - if [ "$(( $(date +"%s") - last_update ))" -gt "$interval" ] || [ "$override_passget" == true ]; then + if [ "$(($(date +"%s") - last_update))" -gt "$interval" ] || [ "$override_passget" == true ]; then if [ -z "$TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_PASSWORD" ]; then # Get password from keychain if it isn't already set. if shell_is_osx; then __mac_keychain_get_pass "${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_USERNAME}@${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER}" "$TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER" @@ -111,12 +111,12 @@ __count_gmail() { fi # Hide password from command line (visible with e.g. ps(1)). - echo -e "user=${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_USERNAME}@${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER}\npassword=${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_PASSWORD}" > "$tmp_wgetrc" + echo -e "user=${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_USERNAME}@${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER}\npassword=${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_PASSWORD}" >"$tmp_wgetrc" mail=$(wget -q -O - "https://mail.google.com/a/${TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_SERVER}/feed/atom" --config "$tmp_wgetrc" | grep -E -m 1 -o '<fullcount>(.*)</fullcount>' | sed -e 's,.*<fullcount>\([^<]*\)</fullcount>.*,\1,g') rm "$tmp_wgetrc" if [ "$mail" != "" ]; then - echo "$mail" > "$tmp_file" + echo "$mail" >"$tmp_file" else return 1 fi @@ -124,7 +124,7 @@ __count_gmail() { count=$(cat "$tmp_file") echo "$count" - return 0; + return 0 } __count_maildir() { @@ -144,7 +144,7 @@ __count_maildir() { fi echo "$count" - return 0; + return 0 } __count_mbox() { @@ -158,11 +158,11 @@ __count_mbox() { count=$(grep -c '^From [^[:space:]]\+ ... ... .. ..:..:.. ....$' "${TMUX_POWERLINE_SEG_MAILCOUNT_MBOX_INBOX}") echo "$count" - return 0; + return 0 } __mac_keychain_get_pass() { - if result=$(security 2>&1 > /dev/null find-internet-password -ga "$1" -s "$2"); then + if result=$(security 2>&1 >/dev/null find-internet-password -ga "$1" -s "$2"); then # shellcheck disable=SC2001 # too complex for simple bash substitution TMUX_POWERLINE_SEG_MAILCOUNT_GMAIL_PASSWORD=$(echo "$result" | sed -e 's/password: \"\(.*\)\"/\1/g') return 0 @@ -175,5 +175,5 @@ __count_mailcheck() { echo "$count" return 0 fi - return 1; + return 1 } diff --git a/segments/mode_indicator.sh b/segments/mode_indicator.sh index da6585a3..d1c44bf8 100644 --- a/segments/mode_indicator.sh +++ b/segments/mode_indicator.sh @@ -49,9 +49,8 @@ SUSPEND_MODE_TEXT_COLOR_DEFAULT="$TMUX_POWERLINE_CUR_SEGMENT_FG" SEPARATOR_TEXT_DEFAULT=" β€’ " - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Whether the normal & prefix mode section should be enabled. Should be {"true, "false"}. export TMUX_POWERLINE_SEG_MODE_INDICATOR_NORMAL_AND_PREFIX_MODE_ENABLED="${NORMAL_AND_PREFIX_MODE_ENABLED_DEFAULT}" # Normal mode text & color overrides. Defaults to "normal" & the segment foreground color set in the theme used. @@ -113,7 +112,7 @@ __normal_and_prefix_mode_indicator() { prefix_mode="$prefix_text_color$TMUX_POWERLINE_SEG_MODE_INDICATOR_PREFIX_MODE_TEXT" suspend_mode="$suspend_text_color$TMUX_POWERLINE_SEG_MODE_INDICATOR_SUSPEND_MODE_TEXT" - if [ "$(tmux show-option -qv key-table)" = "suspended" ] ; then + if [ "$(tmux show-option -qv key-table)" = "suspended" ]; then normal_and_prefix_indicator="$suspend_mode" else normal_and_prefix_indicator="#{?client_prefix,$prefix_mode,$normal_mode}" diff --git a/segments/now_playing.sh b/segments/now_playing.sh index b1587b75..fc63a104 100755 --- a/segments/now_playing.sh +++ b/segments/now_playing.sh @@ -20,7 +20,7 @@ TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR_DEFAULT="β™«" TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER_DEFAULT="spotify" generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Music player to use. Can be any of {audacious, banshee, cmus, apple_music, itunes, lastfm, plexamp, mocp, mpd, mpd_simple, pithos, playerctl, rdio, rhythmbox, spotify, spotify_wine, file}. export TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER="${TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER_DEFAULT}" # File to be read in case the song is being read from a file @@ -86,29 +86,30 @@ run_segment() { local np local app_exit - IFS=',' read -ra PLAYERS <<< "$TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER" + IFS=',' read -ra PLAYERS <<<"$TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER" for i in "${PLAYERS[@]}"; do case "$i" in - "audacious") np=$(__np_audacious) ;; - "banshee") np=$(__np_banshee) ;; - "cmus") np=$(__np_cmus) ;; - "apple_music") np=$(__np_apple_music) ;; - "itunes") np=$(__np_itunes) ;; - "lastfm") np=$(__np_lastfm) ;; - "plexamp") np=$(__np_plexamp) ;; - "mocp") np=$(__np_mocp) ;; - "mpd") np=$(__np_mpd) ;; - "mpd_simple") np=$(__np_mpd_simple) ;; - "pithos") np=$(__np_pithos) ;; - "rdio") np=$(__np_rdio) ;; - "playerctl") np=$(__np_playerctl) ;; - "rhythmbox") np=$(__np_rhythmbox) ;; - "spotify") np=$(__np_spotify) ;; - "file") np=$(__np_file) ;; - "spotify_wine") np=$(__np_spotify_native) ;; - *) - echo "Unknown music player type [${TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER}]"; - return 1 + "audacious") np=$(__np_audacious) ;; + "banshee") np=$(__np_banshee) ;; + "cmus") np=$(__np_cmus) ;; + "apple_music") np=$(__np_apple_music) ;; + "itunes") np=$(__np_itunes) ;; + "lastfm") np=$(__np_lastfm) ;; + "plexamp") np=$(__np_plexamp) ;; + "mocp") np=$(__np_mocp) ;; + "mpd") np=$(__np_mpd) ;; + "mpd_simple") np=$(__np_mpd_simple) ;; + "pithos") np=$(__np_pithos) ;; + "rdio") np=$(__np_rdio) ;; + "playerctl") np=$(__np_playerctl) ;; + "rhythmbox") np=$(__np_rhythmbox) ;; + "spotify") np=$(__np_spotify) ;; + "file") np=$(__np_file) ;; + "spotify_wine") np=$(__np_spotify_native) ;; + *) + echo "Unknown music player type [${TMUX_POWERLINE_SEG_NOW_PLAYING_MUSIC_PLAYER}]" + return 1 + ;; esac app_exit="$?" [ -n "$np" ] && break @@ -120,12 +121,12 @@ run_segment() { fi if [ -n "$np" ]; then case "$TMUX_POWERLINE_SEG_NOW_PLAYING_TRIM_METHOD" in - "roll") - np=$(roll_text "${np}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_MAX_LEN}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_SPEED_DEFAULT}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_MODE}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_SEPARATOR}") - ;; - "trim") - np=${np:0:TMUX_POWERLINE_SEG_NOW_PLAYING_MAX_LEN} - ;; + "roll") + np=$(roll_text "${np}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_MAX_LEN}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_SPEED_DEFAULT}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_MODE}" "${TMUX_POWERLINE_SEG_NOW_PLAYING_ROLL_SEPARATOR}") + ;; + "trim") + np=${np:0:TMUX_POWERLINE_SEG_NOW_PLAYING_MAX_LEN} + ;; esac echo "${TMUX_POWERLINE_SEG_NOW_PLAYING_NOTE_CHAR} ${np}" fi @@ -165,10 +166,10 @@ __process_settings() { fi if [ -z "$TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT" ]; then export TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT="${TMUX_POWERLINE_SEG_NOW_PLAYING_PLAYERCTL_FORMAT_DEFAULT}" - fi; + fi if [ -z "$TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT" ]; then export TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT="${TMUX_POWERLINE_SEG_NOW_PLAYING_RHYTHMBOX_FORMAT_DEFAULT}" - fi; + fi } __np_mpd() { @@ -187,15 +188,14 @@ __np_mpd() { } __np_file() { - np=$(tr '\n' '|' < "$TMUX_POWERLINE_SEG_NOW_PLAYING_FILE_NAME") + np=$(tr '\n' '|' <"$TMUX_POWERLINE_SEG_NOW_PLAYING_FILE_NAME") echo "$np" } - __np_mpd_simple() { if np=$(MPD_HOST="$TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_HOST" MPD_PORT="$TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_PORT" mpc current -f "$TMUX_POWERLINE_SEG_NOW_PLAYING_MPD_SIMPLE_FORMAT" 2>&1); then if [ -n "$np" ]; then - if mpc | grep "paused" > /dev/null; then + if mpc | grep "paused" >/dev/null; then return 1 fi fi @@ -203,11 +203,13 @@ __np_mpd_simple() { fi } - __np_audacious() { if type audtool >/dev/null 2>&1; then if audtool playback-playing; then - { read -r artist; read -r title; } < <(audtool --current-song-tuple-data artist --current-song-tuple-data title) + { + read -r artist + read -r title + } < <(audtool --current-song-tuple-data artist --current-song-tuple-data title) echo "${artist} - ${title}" fi fi @@ -216,9 +218,9 @@ __np_audacious() { __np_banshee() { banshee_pid=$(pidof banshee) if [ -n "$banshee_pid" ]; then - banshee_status=$(banshee --query-current-state 2> /dev/null) + banshee_status=$(banshee --query-current-state 2>/dev/null) if [[ "$banshee_status" == "current-state: playing" ]]; then - np=$(banshee --query-artist --query-title | cut -d ":" -f2 | sed -e 's/ *$//g' -e 's/^ *//g'| sed -e ':a;N;$!ba;s/\n/ - /g' ) + np=$(banshee --query-artist --query-title | cut -d ":" -f2 | sed -e 's/ *$//g' -e 's/^ *//g' | sed -e ':a;N;$!ba;s/\n/ - /g') echo "$np" fi fi @@ -226,7 +228,7 @@ __np_banshee() { __np_cmus() { #cmus-remote returns EXIT_FAILURE/EXIT_SUCCESS depending on whether or not cmus is running. - if cmus-remote -Q > /dev/null 2>&1; then + if cmus-remote -Q >/dev/null 2>&1; then status=$(cmus-remote -Q | grep "status" | cut -d ' ' -f 2) artist=$(cmus-remote -Q | grep -m 1 "artist" | cut -d ' ' -f 3-) title=$(cmus-remote -Q | grep "title" | cut -d ' ' -f 3-) @@ -280,7 +282,7 @@ __np_lastfm() { url=$(printf "$ENDPOINT_FMT" "$TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_USERNAME" "$TMUX_POWERLINE_SEG_NOW_PLAYING_LASTFM_API_KEY") if np=$(curl --silent "$url" | jq --raw-output '.recenttracks.track[0] | "\(.artist."#text") - \(.name)"'); then if [ -n "$np" ]; then - echo "${np}" > "$TMP_FILE" + echo "${np}" >"$TMP_FILE" fi fi fi @@ -311,7 +313,7 @@ __np_plexamp() { url=$(printf "$ENDPOINT_FMT" "$TMUX_POWERLINE_SEG_NOW_PLAYING_PLEXAMP_TAUTULLI_HOST" "$TMUX_POWERLINE_SEG_NOW_PLAYING_PLEXAMP_TAUTULLI_API_KEY") if np=$(curl --silent "$url" | jq -r ".response.data.sessions[] | select(.username==\"$TMUX_POWERLINE_SEG_NOW_PLAYING_PLEXAMP_USERNAME\" and .media_type==\"track\" and .state==\"playing\") | .grandparent_title + \" - \" + .title"); then if [ -n "$np" ]; then - echo "${np}" > "$TMP_FILE" + echo "${np}" >"$TMP_FILE" fi fi fi @@ -364,12 +366,12 @@ __np_playerctl() { __np_spotify() { if shell_is_linux; then if type tasklist.exe >/dev/null 2>&1; then # WSL - np=$(tasklist.exe /fo list /v /fi "IMAGENAME eq Spotify.exe" | grep " - " | cut -d" " -f3-) - np="${np//[$'\t\r\n']}" + np=$(tasklist.exe /fo list /v /fi "IMAGENAME eq Spotify.exe" | grep " - " | cut -d" " -f3-) + np="${np//[$'\t\r\n']/}" else if metadata=$(dbus-send --reply-timeout=42 --print-reply --session --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' 2>/dev/null); then if [ -n "$metadata" ]; then - state=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|grep -E -A 1 "string"|cut -b 26-|cut -d '"' -f 1|grep -E -v ^$) + state=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' | grep -E -A 1 "string" | cut -b 26- | cut -d '"' -f 1 | grep -E -v ^$) if [[ $state == "Playing" ]]; then artist=$(echo "$metadata" | grep -PA2 "string\s\"xesam:artist\"" | tail -1 | grep -Po "(?<=\").*(?=\")") track=$(echo "$metadata" | grep -PA1 "string\s\"xesam:title\"" | tail -1 | grep -Po "(?<=\").*(?=\")") diff --git a/segments/pwd.sh b/segments/pwd.sh index ec0c8042..aa1c5d77 100755 --- a/segments/pwd.sh +++ b/segments/pwd.sh @@ -8,9 +8,8 @@ source "${TMUX_POWERLINE_DIR_LIB}/tmux_adapter.sh" TMUX_POWERLINE_SEG_PWD_MAX_LEN="${TMUX_POWERLINE_SEG_PWD_MAX_LEN:-40}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Maximum length of output. export TMUX_POWERLINE_SEG_PWD_MAX_LEN="${TMUX_POWERLINE_SEG_PWD_MAX_LEN}" EORC @@ -23,9 +22,9 @@ run_segment() { trunc_symbol="Β·Β·Β·" dir=${tcwd##*/} local max_len="$TMUX_POWERLINE_SEG_PWD_MAX_LEN" - max_len=$(( ( max_len < ${#dir} ) ? ${#dir} : max_len )) + max_len=$(((max_len < ${#dir}) ? ${#dir} : max_len)) ttcwd=${tcwd/#$HOME/\~} - pwdoffset=$(( ${#ttcwd} - max_len )) + pwdoffset=$((${#ttcwd} - max_len)) if [ ${pwdoffset} -gt "0" ]; then ttcwd=${ttcwd:$pwdoffset:$max_len} ttcwd=${trunc_symbol}/${ttcwd#*/} diff --git a/segments/rainbarf.sh b/segments/rainbarf.sh index c9f8cd04..6264a789 100755 --- a/segments/rainbarf.sh +++ b/segments/rainbarf.sh @@ -10,7 +10,7 @@ run_segment() { # Customize via ~/.rainbarf.conf stats=$(rainbarf --tmux) if [ -n "$stats" ]; then - echo "$stats"; + echo "$stats" fi return 0 } diff --git a/segments/time.sh b/segments/time.sh index a64e8298..b95a30c5 100755 --- a/segments/time.sh +++ b/segments/time.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_TIME_FORMAT="${TMUX_POWERLINE_SEG_TIME_FORMAT:-%H:%M}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # date(1) format for the time. Americans might want to have "%I:%M %p". export TMUX_POWERLINE_SEG_TIME_FORMAT="${TMUX_POWERLINE_SEG_TIME_FORMAT}" # Change this to display a different timezone than the system default. diff --git a/segments/tmux_mem_cpu_load.sh b/segments/tmux_mem_cpu_load.sh index 9e568f30..7bd36e2c 100755 --- a/segments/tmux_mem_cpu_load.sh +++ b/segments/tmux_mem_cpu_load.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_TMUX_MEM_CPU_LOAD_ARGS="${TMUX_POWERLINE_SEG_TMUX_MEM_CPU_LOAD_ARGS:--v}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Arguments passed to tmux-mem-cpu-load. # See https://github.com/thewtex/tmux-mem-cpu-load for all available options. # export TMUX_POWERLINE_SEG_TMUX_MEM_CPU_LOAD_ARGS="${TMUX_POWERLINE_SEG_TMUX_MEM_CPU_LOAD_ARGS}" @@ -14,9 +13,9 @@ EORC } run_segment() { - read -r -a args <<< "$TMUX_POWERLINE_SEG_TMUX_MEM_CPU_LOAD_ARGS" + read -r -a args <<<"$TMUX_POWERLINE_SEG_TMUX_MEM_CPU_LOAD_ARGS" stats="" - if type "$TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load" > /dev/null 2>&1; then + if type "$TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load" >/dev/null 2>&1; then stats=$("$TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load" "${args[@]}") elif type tmux-mem-cpu-load >/dev/null 2>&1; then stats=$(tmux-mem-cpu-load "${args[@]}") @@ -25,7 +24,7 @@ run_segment() { fi if [ -n "$stats" ]; then - echo "$stats"; + echo "$stats" fi return 0 } diff --git a/segments/tmux_session_info.sh b/segments/tmux_session_info.sh index 4f888b18..8bf830d1 100755 --- a/segments/tmux_session_info.sh +++ b/segments/tmux_session_info.sh @@ -4,9 +4,8 @@ TMUX_POWERLINE_SEG_TMUX_SESSION_INFO_FORMAT="${TMUX_POWERLINE_SEG_TMUX_SESSION_INFO_FORMAT:-#S:#I.#P}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Session info format to feed into the command: tmux display-message -p # For example, if FORMAT is '[ #S ]', the command is: tmux display-message -p '[ #S ]' export TMUX_POWERLINE_SEG_TMUX_SESSION_INFO_FORMAT="${TMUX_POWERLINE_SEG_TMUX_SESSION_INFO_FORMAT}" diff --git a/segments/utc_time.sh b/segments/utc_time.sh index bd5f0712..3a3bc691 100755 --- a/segments/utc_time.sh +++ b/segments/utc_time.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_UTC_TIME_FORMAT="${TMUX_POWERLINE_SEG_UTC_TIME_FORMAT:-%H:%M %Z}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # date(1) format for the UTC time. export TMUX_POWERLINE_SEG_UTC_TIME_FORMAT="${TMUX_POWERLINE_SEG_UTC_TIME_FORMAT}" EORC diff --git a/segments/vcs_branch.sh b/segments/vcs_branch.sh index 2d091ecb..39da9b38 100755 --- a/segments/vcs_branch.sh +++ b/segments/vcs_branch.sh @@ -17,9 +17,8 @@ TMUX_POWERLINE_SEG_VCS_BRANCH_HG_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VCS_BRANCH_ TMUX_POWERLINE_SEG_VCS_BRANCH_SVN_SYMBOL="${TMUX_POWERLINE_SEG_VCS_BRANCH_SVN_SYMBOL:-$TMUX_POWERLINE_SEG_VCS_BRANCH_DEFAULT_SYMBOL}" TMUX_POWERLINE_SEG_VCS_BRANCH_SVN_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VCS_BRANCH_SVN_SYMBOL_COLOUR:-220}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Max length of the branch name. export TMUX_POWERLINE_SEG_VCS_BRANCH_MAX_LEN="${TMUX_POWERLINE_SEG_VCS_BRANCH_MAX_LEN_DEFAULT}" # Symbol when branch length exceeds max length @@ -45,7 +44,10 @@ EORC run_segment() { local branch - { read -r vcs_type; read -r vcs_rootpath; } < <(get_vcs_type_and_root_path) + { + read -r vcs_type + read -r vcs_rootpath + } < <(get_vcs_type_and_root_path) tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return branch=$(__parse_"${vcs_type}"_branch "$vcs_rootpath") @@ -61,12 +63,12 @@ __parse_git_branch() { local branch # Quit if this is not a Git repo. - if ! branch=$(git symbolic-ref HEAD 2> /dev/null); then + if ! branch=$(git symbolic-ref HEAD 2>/dev/null); then return fi - if [[ -z $branch ]] ; then + if [[ -z $branch ]]; then # attempt to get short-sha-name - if ! branch=":$(git rev-parse --short HEAD 2> /dev/null)"; then + if ! branch=":$(git rev-parse --short HEAD 2>/dev/null)"; then return fi fi @@ -129,7 +131,7 @@ __truncate_branch_name() { # ensure branch name length is less than defined max lenght if [ "${#branch}" -gt "$TMUX_POWERLINE_SEG_VCS_BRANCH_MAX_LEN" ]; then - branch=${branch:0:$((TMUX_POWERLINE_SEG_VCS_BRANCH_MAX_LEN-${#trunc_symbol}))} + branch=${branch:0:$((TMUX_POWERLINE_SEG_VCS_BRANCH_MAX_LEN - ${#trunc_symbol}))} # append trunc_symbol branch="${branch}${trunc_symbol}" fi diff --git a/segments/vcs_compare.sh b/segments/vcs_compare.sh index 48839919..9ac1817a 100755 --- a/segments/vcs_compare.sh +++ b/segments/vcs_compare.sh @@ -13,9 +13,8 @@ TMUX_POWERLINE_SEG_VCS_COMPARE_BEHIND_SYMBOL="${TMUX_POWERLINE_SEG_VCS_COMPARE_B TMUX_POWERLINE_SEG_VCS_COMPARE_AHEAD_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VCS_COMPARE_AHEAD_SYMBOL_COLOUR:-$TMUX_POWERLINE_CUR_SEGMENT_FG}" TMUX_POWERLINE_SEG_VCS_COMPARE_BEHIND_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VCS_COMPARE_BEHIND_SYMBOL_COLOUR:-$TMUX_POWERLINE_CUR_SEGMENT_FG}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol if local branch is behind. # export TMUX_POWERLINE_SEG_VCS_COMPARE_AHEAD_SYMBOL="${TMUX_POWERLINE_SEG_VCS_COMPARE_AHEAD_SYMBOL}" # Symbol colour if local branch is ahead. Defaults to "current segment foreground colour" @@ -29,7 +28,10 @@ EORC } run_segment() { - { read -r vcs_type; read -r _unused; } < <(get_vcs_type_and_root_path) + { + read -r vcs_type + read -r _unused + } < <(get_vcs_type_and_root_path) tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return @@ -43,7 +45,7 @@ run_segment() { __parse_git_stats() { # check if git - [[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return + [[ -z $(git rev-parse --git-dir 2>/dev/null) ]] && return symbolic_ref=$(git symbolic-ref -q HEAD) [[ -z "${symbolic_ref}" ]] && return @@ -54,10 +56,10 @@ __parse_git_stats() { read -r behind ahead < <(git rev-list --left-right --count "$tracking_branch"...HEAD) # print out the information - if [[ $behind -gt 0 ]] ; then + if [[ $behind -gt 0 ]]; then local ret="#[fg=$TMUX_POWERLINE_SEG_VCS_COMPARE_BEHIND_SYMBOL_COLOUR]${TMUX_POWERLINE_SEG_VCS_COMPARE_BEHIND_SYMBOL}#[fg=$TMUX_POWERLINE_CUR_SEGMENT_FG]$behind" fi - if [[ $ahead -gt 0 ]] ; then + if [[ $ahead -gt 0 ]]; then local ret="${ret}#[fg=$TMUX_POWERLINE_SEG_VCS_COMPARE_AHEAD_SYMBOL_COLOUR]${TMUX_POWERLINE_SEG_VCS_COMPARE_AHEAD_SYMBOL}#[fg=$TMUX_POWERLINE_CUR_SEGMENT_FG]$ahead" fi echo "$ret" diff --git a/segments/vcs_modified.sh b/segments/vcs_modified.sh index cc5bb25c..dc5088a1 100755 --- a/segments/vcs_modified.sh +++ b/segments/vcs_modified.sh @@ -10,9 +10,8 @@ source "${TMUX_POWERLINE_DIR_LIB}/vcs_helper.sh" TMUX_POWERLINE_SEG_VCS_MODIFIED_SYMBOL="${TMUX_POWERLINE_SEG_VCS_MODIFIED_SYMBOL:-Β± }" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol for count of modified vcs files. # export TMUX_POWERLINE_SEG_VCS_MODIFIED_SYMBOL="${TMUX_POWERLINE_SEG_VCS_MODIFIED_SYMBOL}" EORC @@ -20,7 +19,10 @@ EORC } run_segment() { - { read -r vcs_type; read -r vcs_rootpath; } < <(get_vcs_type_and_root_path) + { + read -r vcs_type + read -r vcs_rootpath + } < <(get_vcs_type_and_root_path) tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return @@ -33,20 +35,20 @@ run_segment() { fi } -__parse_git_stats(){ - local rootpath +__parse_git_stats() { + local rootpath local modified rootpath=$1 # check if git - [[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return + [[ -z $(git rev-parse --git-dir 2>/dev/null) ]] && return # return the number of modified but not staged items modified=$(git ls-files --modified "$rootpath" | wc -l) echo "$modified" } -__parse_hg_stats(){ +__parse_hg_stats() { local modified modified=$(hg status -m | wc -l) @@ -70,10 +72,10 @@ __parse_svn_stats() { conflicted=$(echo "${svn_st}" | grep -E '^!?\s*C' -c) #print - if [[ $conflicted -gt 0 ]] ; then + if [[ $conflicted -gt 0 ]]; then local ret="ϟ ${conflicted}" fi - if [[ $modified -gt 0 ]] ; then + if [[ $modified -gt 0 ]]; then local ret="${modified} ${ret}" fi echo "${ret}" diff --git a/segments/vcs_others.sh b/segments/vcs_others.sh index 19ba906e..9332b06d 100755 --- a/segments/vcs_others.sh +++ b/segments/vcs_others.sh @@ -9,9 +9,8 @@ source "${TMUX_POWERLINE_DIR_LIB}/vcs_helper.sh" TMUX_POWERLINE_SEG_VCS_OTHERS_SYMBOL="${TMUX_POWERLINE_SEG_VCS_OTHERS_SYMBOL:-β‹―}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol for count of untracked vcs files. # export TMUX_POWERLINE_SEG_VCS_OTHERS_SYMBOL="${TMUX_POWERLINE_SEG_VCS_OTHERS_SYMBOL}" EORC @@ -19,7 +18,10 @@ EORC } run_segment() { - { read -r vcs_type; read -r vcs_rootpath; } < <(get_vcs_type_and_root_path) + { + read -r vcs_type + read -r vcs_rootpath + } < <(get_vcs_type_and_root_path) tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return @@ -33,20 +35,20 @@ run_segment() { return 0 } -__parse_git_stats(){ +__parse_git_stats() { local rootpath - rootpath=$1 + rootpath=$1 # check if git - [[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return + [[ -z $(git rev-parse --git-dir 2>/dev/null) ]] && return # return the number of untracked items - other=$(git ls-files --others --exclude-standard "$rootpath" | wc -l) + other=$(git ls-files --others --exclude-standard "$rootpath" | wc -l) echo "$other" } -__parse_hg_stats(){ +__parse_hg_stats() { other=$(hg status -u | wc -l) if [ -z "$other" ]; then return @@ -54,7 +56,7 @@ __parse_hg_stats(){ echo "$other" } -__parse_svn_stats(){ +__parse_svn_stats() { if ! svn_stats=$(svn stat 2>/dev/null); then return fi diff --git a/segments/vcs_revision.sh b/segments/vcs_revision.sh index 6b83bddd..98dcddf7 100755 --- a/segments/vcs_revision.sh +++ b/segments/vcs_revision.sh @@ -8,9 +8,11 @@ source "${TMUX_POWERLINE_DIR_LIB}/tmux_adapter.sh" # shellcheck source=lib/vcs_helper.sh source "${TMUX_POWERLINE_DIR_LIB}/vcs_helper.sh" - run_segment() { - { read -r vcs_type; read -r _unused; } < <(get_vcs_type_and_root_path) + { + read -r vcs_type + read -r _unused + } < <(get_vcs_type_and_root_path) tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return @@ -31,7 +33,7 @@ __parse_git_stats() { echo "${git_rev}" } -__parse_hg_stats(){ +__parse_hg_stats() { local hg_rev hg_rev=$(hg id -i) if [ -z "$hg_rev" ]; then @@ -39,7 +41,7 @@ __parse_hg_stats(){ fi echo "${hg_rev}" } -__parse_svn_stats(){ +__parse_svn_stats() { local svn_info local svn_rev svn_info=$(svn info 2>/dev/null) diff --git a/segments/vcs_rootpath.sh b/segments/vcs_rootpath.sh index 3a960630..9f337257 100755 --- a/segments/vcs_rootpath.sh +++ b/segments/vcs_rootpath.sh @@ -5,9 +5,8 @@ source "${TMUX_POWERLINE_DIR_LIB}/vcs_helper.sh" TMUX_POWERLINE_SEG_VCS_ROOTPATH_MODE="${TMUX_POWERLINE_SEG_VCS_ROOTPATH_MODE:-name}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Display mode for vcs_rootpath. # Example: (name: folder name only; path: full path, w/o expansion; user_path: full path, w/ tilde expansion) # export TMUX_POWERLINE_SEG_VCS_ROOTPATH_MODE="${TMUX_POWERLINE_SEG_VCS_ROOTPATH_MODE}" @@ -17,7 +16,10 @@ EORC run_segment() { # get root_path - { read -r _unused; read -r root_path; } < <(get_vcs_type_and_root_path) + { + read -r _unused + read -r root_path + } < <(get_vcs_type_and_root_path) if [ -n "$root_path" ]; then if [ "${TMUX_POWERLINE_SEG_VCS_ROOTPATH_MODE}" = "user_path" ]; then @@ -29,7 +31,7 @@ run_segment() { elif [ "${TMUX_POWERLINE_SEG_VCS_ROOTPATH_MODE}" = "name" ] || :; then root_path=${root_path/#$HOME/\~} root_path=${root_path/*\//} - fi + fi echo -n "#[fg=${TMUX_POWERLINE_CUR_SEGMENT_FG}]${root_path}" fi diff --git a/segments/vcs_staged.sh b/segments/vcs_staged.sh index 10d5de17..a6ec7556 100755 --- a/segments/vcs_staged.sh +++ b/segments/vcs_staged.sh @@ -10,9 +10,8 @@ source "${TMUX_POWERLINE_DIR_LIB}/vcs_helper.sh" TMUX_POWERLINE_SEG_VCS_STAGED_SYMBOL="${TMUX_POWERLINE_SEG_VCS_STAGED_SYMBOL:-βŠ• }" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol for count of staged vcs files. # export TMUX_POWERLINE_SEG_VCS_STAGED_SYMBOL="${TMUX_POWERLINE_SEG_VCS_STAGED_SYMBOL}" EORC @@ -20,7 +19,10 @@ EORC } run_segment() { - { read -r vcs_type; read -r _unused; } < <(get_vcs_type_and_root_path) + { + read -r vcs_type + read -r _unused + } < <(get_vcs_type_and_root_path) tmux_path=$(get_tmux_cwd) cd "$tmux_path" || return @@ -35,22 +37,21 @@ run_segment() { return 0 } - -__parse_git_stats(){ +__parse_git_stats() { # Check if git. - [[ -z $(git rev-parse --git-dir 2> /dev/null) ]] && return + [[ -z $(git rev-parse --git-dir 2>/dev/null) ]] && return # Return the number of staged items. staged=$(git diff --staged --name-status | wc -l) echo "$staged" } -__parse_hg_stats(){ +__parse_hg_stats() { # not yet implemented return } -__parse_svn_stats(){ +__parse_svn_stats() { # not yet implemented return } diff --git a/segments/vpn.sh b/segments/vpn.sh index fabd8ec7..af98a558 100644 --- a/segments/vpn.sh +++ b/segments/vpn.sh @@ -6,6 +6,26 @@ TMUX_POWERLINE_SEG_VPN_SYMBOL="${TMUX_POWERLINE_SEG_VPN_SYMBOL:-σ± Ύ }" TMUX_POWERLINE_SEG_VPN_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VPN_SYMBOL_COLOUR:-255}" TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR="${TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR:-󰿟}" +generate_segmentrc() { + read -r -d '' rccontents <<EORC +# Mode for VPN segment {"both", "ip", "name"}. both: Show NIC/IP; ip: Show only IP; name: Show only NIC name +# export TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE="${TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE}" +# Space separated list of tunnel interface names. First match is being used. substring match, regexp can be used. +# Examples: +# export TMUX_POWERLINE_SEG_VPN_NICS="tun" # will match 'tun0', 'utun0', 'itun', 'tun08127387' +# export TMUX_POWERLINE_SEG_VPN_NICS="tun0 tuntun" # will match 'tun0', 'utun0', 'tuntun' +# export TMUX_POWERLINE_SEG_VPN_NICS="^tun0$ ^tun1$" # exactly 'tun0' and 'tun1' +# Default: +# export TMUX_POWERLINE_SEG_VPN_NICS='${TMUX_POWERLINE_SEG_VPN_NICS}' +# Symbol to use for vpn tunnel. +# export TMUX_POWERLINE_SEG_VPN_SYMBOL="${TMUX_POWERLINE_SEG_VPN_SYMBOL}" +# Colour for vpn tunnel symbol +# export TMUX_POWERLINE_SEG_VPN_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VPN_SYMBOL_COLOUR}" +# Symbol for separator +# export TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR="${TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR}" +EORC + echo "$rccontents" +} run_segment() { __process_settings @@ -81,27 +101,6 @@ run_segment() { fi } -generate_segmentrc() { - read -r -d '' rccontents << EORC -# Mode for VPN segment {"both", "ip", "name"}. both: Show NIC/IP; ip: Show only IP; name: Show only NIC name -# export TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE="${TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE}" -# Space separated list of tunnel interface names. First match is being used. substring match, regexp can be used. -# Examples: -# export TMUX_POWERLINE_SEG_VPN_NICS="tun" # will match 'tun0', 'utun0', 'itun', 'tun08127387' -# export TMUX_POWERLINE_SEG_VPN_NICS="tun0 tuntun" # will match 'tun0', 'utun0', 'tuntun' -# export TMUX_POWERLINE_SEG_VPN_NICS="^tun0$ ^tun1$" # exactly 'tun0' and 'tun1' -# Default: -# export TMUX_POWERLINE_SEG_VPN_NICS='${TMUX_POWERLINE_SEG_VPN_NICS}' -# Symbol to use for vpn tunnel. -# export TMUX_POWERLINE_SEG_VPN_SYMBOL="${TMUX_POWERLINE_SEG_VPN_SYMBOL}" -# Colour for vpn tunnel symbol -# export TMUX_POWERLINE_SEG_VPN_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_VPN_SYMBOL_COLOUR}" -# Symbol for separator -# export TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR="${TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR}" -EORC - echo "$rccontents" -} - __process_settings() { if [ -z "$TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE" ]; then export TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE="${TMUX_POWERLINE_SEG_VPN_DISPLAY_MODE}" @@ -119,4 +118,3 @@ __process_settings() { export TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR="${TMUX_POWERLINE_SEG_VPN_DISPLAY_SEPARATOR}" fi } - diff --git a/segments/wan_ip.sh b/segments/wan_ip.sh index 2e78e559..1287d5de 100755 --- a/segments/wan_ip.sh +++ b/segments/wan_ip.sh @@ -3,9 +3,8 @@ TMUX_POWERLINE_SEG_WAN_IP_SYMBOL="${TMUX_POWERLINE_SEG_WAN_IP_SYMBOL:-ⓦ }" TMUX_POWERLINE_SEG_WAN_IP_SYMBOL_COLOUR="${TMUX_POWERLINE_SEG_WAN_IP_SYMBOL_COLOUR:-255}" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Symbol for WAN IP # export TMUX_POWERLINE_SEG_WAN_IP_SYMBOL="${TMUX_POWERLINE_SEG_WAN_IP_SYMBOL}" # Symbol colour for WAN IP @@ -21,7 +20,7 @@ run_segment() { if [ -f "$tmp_file" ]; then if shell_is_osx || shell_is_bsd; then stat >/dev/null 2>&1 && is_gnu_stat=false || is_gnu_stat=true - if [ "$is_gnu_stat" == "true" ];then + if [ "$is_gnu_stat" == "true" ]; then last_update=$(stat -c "%Y" "${tmp_file}") else last_update=$(stat -f "%m" "${tmp_file}") @@ -41,7 +40,7 @@ run_segment() { if [ -z "$wan_ip" ]; then if wan_ip=$(curl --max-time 2 -s http://whatismyip.akamai.com/); then - echo "${wan_ip}" > "$tmp_file" + echo "${wan_ip}" >"$tmp_file" elif [ -f "${tmp_file}" ]; then wan_ip=$(cat "$tmp_file") fi diff --git a/segments/weather.sh b/segments/weather.sh index 7c4f0393..ec285984 100755 --- a/segments/weather.sh +++ b/segments/weather.sh @@ -7,16 +7,14 @@ TMUX_POWERLINE_SEG_WEATHER_JSON_DEFAULT="jq" TMUX_POWERLINE_SEG_WEATHER_UNIT_DEFAULT="c" TMUX_POWERLINE_SEG_WEATHER_UPDATE_PERIOD_DEFAULT="600" - -if shell_is_bsd && [ -f /user/local/bin/grep ]; then +if shell_is_bsd && [ -f /user/local/bin/grep ]; then TMUX_POWERLINE_SEG_WEATHER_GREP_DEFAULT="/usr/local/bin/grep" else TMUX_POWERLINE_SEG_WEATHER_GREP_DEFAULT="grep" fi - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # The data provider to use. Currently only "yahoo" is supported. export TMUX_POWERLINE_SEG_WEATHER_DATA_PROVIDER="${TMUX_POWERLINE_SEG_WEATHER_DATA_PROVIDER_DEFAULT}" # What unit to use. Can be any of {c,f,k}. @@ -40,10 +38,11 @@ run_segment() { local tmp_file="${TMUX_POWERLINE_DIR_TEMPORARY}/temp_weather_file.txt" local weather case "$TMUX_POWERLINE_SEG_WEATHER_DATA_PROVIDER" in - "yrno") weather=$(__yrno) ;; - *) - echo "Unknown weather provider [$TMUX_POWERLINE_SEG_WEATHER_DATA_PROVIDER]"; - return 1 + "yrno") weather=$(__yrno) ;; + *) + echo "Unknown weather provider [$TMUX_POWERLINE_SEG_WEATHER_DATA_PROVIDER]" + return 1 + ;; esac if [ -n "$weather" ]; then echo "$weather" @@ -67,7 +66,7 @@ __process_settings() { export TMUX_POWERLINE_SEG_WEATHER_JSON="${TMUX_POWERLINE_SEG_WEATHER_JSON_DEFAULT}" fi if [ -z "$TMUX_POWERLINE_SEG_WEATHER_LON" ] && [ -z "$TMUX_POWERLINE_SEG_WEATHER_LAT" ]; then - echo "No location defined."; + echo "No location defined." exit 8 fi } @@ -90,8 +89,8 @@ __yrno() { if [ -z "$degree" ]; then if weather_data=$(curl --max-time 4 -s "https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${TMUX_POWERLINE_SEG_WEATHER_LAT}&lon=${TMUX_POWERLINE_SEG_WEATHER_LON}"); then - grep=$TMUX_POWERLINE_SEG_WEATHER_GREP_DEFAULT - error=$(echo "$weather_data" | $grep -i "error"); + grep=$TMUX_POWERLINE_SEG_WEATHER_GREP_DEFAULT + error=$(echo "$weather_data" | $grep -i "error") if [ -n "$error" ]; then echo "error" exit 1 @@ -114,7 +113,7 @@ __yrno() { fi # condition_symbol=$(__get_yrno_condition_symbol "$condition" "$sunrise" "$sunset") condition_symbol=$(__get_yrno_condition_symbol "$condition") - echo "${condition_symbol} ${degree}Β°$(echo "$TMUX_POWERLINE_SEG_WEATHER_UNIT" | tr '[:lower:]' '[:upper:]')" | tee "${tmp_file}" + echo "${condition_symbol} ${degree}Β°$(echo "$TMUX_POWERLINE_SEG_WEATHER_UNIT" | tr '[:lower:]' '[:upper:]')" | tee "${tmp_file}" fi } @@ -125,51 +124,51 @@ __get_yrno_condition_symbol() { # local sunset="$3" local condition=$1 case "$condition" in - "clearsky_day") - echo "β˜€οΈ " - ;; - "clearsky_night") - echo "πŸŒ™" - ;; - "fair_day") - echo "🌀 " - ;; - "fair_night") - echo "🌜" - ;; - "fog") - echo "🌫 " - ;; - "cloudy") - echo "☁️ " - ;; - "rain" | "lightrain" | "heavyrain" | "sleet" | "lightsleet" | "heavysleet") - echo "🌧 " - ;; - "heavyrainandthunder" | "heavyrainshowersandthunder_day" | "heavyrainshowersandthunder_night" | "heavysleetandthunder" | "heavysleetshowersandthunder_day" | "heavysnowandthunder" | "heavysnowshowersandthunder_day" | "heavysnowshowersandthunder_night" | "lightrainandthunder" | "lightrainshowersandthunder_day" | "lightrainshowersandthunder_night" | "lightsleetandthunder" | "lightsnowandthunder" | "lightssleetshowersandthunder_day" | "lightssleetshowersandthunder_night" | "lightssnowshowersandthunder_day" | "lightssnowshowersandthunder_night" | "rainandthunder" | "rainshowersandthunder_day" | "rainshowersandthunder_night" | "sleetandthunder" | "sleetshowersandthunder_day" | "sleetshowersandthunder_night" | "snowandthunder" | "snowshowersandthunder_day" | "snowshowersandthunder_night") - echo "β›ˆοΈ " - ;; - "heavyrainshowers_day" | "heavysleetshowers_day" | "heavysleetshowersandthunder_night" | "lightrainshowers_day" | "lightsleetshowers_day" | "rainshowers_day" | "sleetshowers_day") - echo "🌦️ " - ;; - "heavyrainshowers_night" | "heavysleetshowers_night" | "lightrainshowers_night" | "lightsleetshowers_night" | "rainshowers_night" | "sleetshowers_night") - echo "β˜”" - ;; - "snow" | "lightsnow" | "heavysnow") - echo "❄️ " - ;; - "lightsnowshowers_day" | "lightsnowshowers_night" | "heavysnowshowers_day" | "heavysnowshowers_night" | "snowshowers_day" | "snowshowers_night") - echo "🌨 " - ;; - "partlycloudy_day") - echo "β›…" - ;; - "partlycloudy_night") - echo "πŸŒ—" - ;; - *) - echo "?" - ;; + "clearsky_day") + echo "β˜€οΈ " + ;; + "clearsky_night") + echo "πŸŒ™" + ;; + "fair_day") + echo "🌀 " + ;; + "fair_night") + echo "🌜" + ;; + "fog") + echo "🌫 " + ;; + "cloudy") + echo "☁️ " + ;; + "rain" | "lightrain" | "heavyrain" | "sleet" | "lightsleet" | "heavysleet") + echo "🌧 " + ;; + "heavyrainandthunder" | "heavyrainshowersandthunder_day" | "heavyrainshowersandthunder_night" | "heavysleetandthunder" | "heavysleetshowersandthunder_day" | "heavysnowandthunder" | "heavysnowshowersandthunder_day" | "heavysnowshowersandthunder_night" | "lightrainandthunder" | "lightrainshowersandthunder_day" | "lightrainshowersandthunder_night" | "lightsleetandthunder" | "lightsnowandthunder" | "lightssleetshowersandthunder_day" | "lightssleetshowersandthunder_night" | "lightssnowshowersandthunder_day" | "lightssnowshowersandthunder_night" | "rainandthunder" | "rainshowersandthunder_day" | "rainshowersandthunder_night" | "sleetandthunder" | "sleetshowersandthunder_day" | "sleetshowersandthunder_night" | "snowandthunder" | "snowshowersandthunder_day" | "snowshowersandthunder_night") + echo "β›ˆοΈ " + ;; + "heavyrainshowers_day" | "heavysleetshowers_day" | "heavysleetshowersandthunder_night" | "lightrainshowers_day" | "lightsleetshowers_day" | "rainshowers_day" | "sleetshowers_day") + echo "🌦️ " + ;; + "heavyrainshowers_night" | "heavysleetshowers_night" | "lightrainshowers_night" | "lightsleetshowers_night" | "rainshowers_night" | "sleetshowers_night") + echo "β˜”" + ;; + "snow" | "lightsnow" | "heavysnow") + echo "❄️ " + ;; + "lightsnowshowers_day" | "lightsnowshowers_night" | "heavysnowshowers_day" | "heavysnowshowers_night" | "snowshowers_day" | "snowshowers_night") + echo "🌨 " + ;; + "partlycloudy_day") + echo "β›…" + ;; + "partlycloudy_night") + echo "πŸŒ—" + ;; + *) + echo "?" + ;; esac } diff --git a/segments/xkb_layout.sh b/segments/xkb_layout.sh index da60d5c0..8b3bf43b 100755 --- a/segments/xkb_layout.sh +++ b/segments/xkb_layout.sh @@ -14,9 +14,8 @@ TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON="${TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON:-⌨ }" - generate_segmentrc() { - read -r -d '' rccontents << EORC + read -r -d '' rccontents <<EORC # Keyboard icon export TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON="${TMUX_POWERLINE_SEG_XKB_LAYOUT_ICON}" EORC diff --git a/themes/bubble.sh b/themes/bubble.sh index 1b9b1813..23984549 100644 --- a/themes/bubble.sh +++ b/themes/bubble.sh @@ -51,7 +51,6 @@ sky_blue="#a7c7e7" spotify_green="#1db954" spotify_black="#191414" - TMUX_POWERLINE_SEPARATOR_LEFT_BOLD="ξ‚Ά" TMUX_POWERLINE_SEPARATOR_LEFT_THIN="ξ‚·" TMUX_POWERLINE_SEPARATOR_RIGHT_BOLD="ξ‚΄" @@ -72,13 +71,13 @@ TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SEPARATOR=${TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SE # shellcheck disable=SC2128 if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_CURRENT" ]; then TMUX_POWERLINE_WINDOW_STATUS_CURRENT=( - "#[$(format regular)]" \ - "$TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SEPARATOR" \ - "#[$(format inverse)]" \ - " #I#F " \ - "$TMUX_POWERLINE_SEPARATOR_THIN" \ - " #W " \ - "#[$(format regular)]" \ + "#[$(format regular)]" + "$TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SEPARATOR" + "#[$(format inverse)]" + " #I#F " + "$TMUX_POWERLINE_SEPARATOR_THIN" + " #W " + "#[$(format regular)]" "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" ) fi @@ -93,9 +92,9 @@ fi # shellcheck disable=SC2128 if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_FORMAT" ]; then TMUX_POWERLINE_WINDOW_STATUS_FORMAT=( - "#[$(format regular)]" \ - " #I#{?window_flags,#F, } " \ - "$TMUX_POWERLINE_SEPARATOR_THIN" \ + "#[$(format regular)]" + " #I#{?window_flags,#F, } " + "$TMUX_POWERLINE_SEPARATOR_THIN" " #W " ) fi @@ -132,39 +131,39 @@ fi # shellcheck disable=SC1143,SC2128 if [ -z "$TMUX_POWERLINE_LEFT_STATUS_SEGMENTS" ]; then TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=( - "tmux_session_info $blue $thm_bg" \ - "hostname $eggplant $thm_bg" \ - #"ifstat 30 255" \ - #"ifstat_sys 30 255" \ - "lan_ip $sky_blue $thm_bg ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" \ - "wan_ip $sky_blue $thm_bg" \ - "vcs_branch $thm_gray" \ - #"air ${TMUX_POWERLINE_SEG_AIR_COLOR} $thm_bg" \ - #"vcs_compare 60 255" \ - #"vcs_staged 64 255" \ - #"vcs_modified 9 255" \ - #"vcs_others 245 0" \ + "tmux_session_info $blue $thm_bg" + "hostname $eggplant $thm_bg" + #"ifstat 30 255" + #"ifstat_sys 30 255" + "lan_ip $sky_blue $thm_bg ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" + "wan_ip $sky_blue $thm_bg" + "vcs_branch $thm_gray" + #"air ${TMUX_POWERLINE_SEG_AIR_COLOR} $thm_bg" + #"vcs_compare 60 255" + #"vcs_staged 64 255" + #"vcs_modified 9 255" + #"vcs_others 245 0" ) fi # shellcheck disable=SC1143,SC2128 if [ -z "$TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS" ]; then TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS=( - # "earthquake 3 0" \ - "pwd $mauve $surface0" \ - #"macos_notification_count 29 255" \ - #"mailcount 9 255" \ - "now_playing $spotify_green $spotify_black" \ - #"cpu 240 136" \ - #"load 237 167" \ - #"tmux_mem_cpu_load 234 136" \ - "battery $blue $thm_bg" \ - #"weather 37 255" \ - #"rainbarf 0 ${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" \ - #"xkb_layout 125 117" \ - "date_day $teal $thm_bg" \ - "date $teal $thm_bg ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ - "time $teal $thm_bg ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ - #"utc_time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ + # "earthquake 3 0" + "pwd $mauve $surface0" + #"macos_notification_count 29 255" + #"mailcount 9 255" + "now_playing $spotify_green $spotify_black" + #"cpu 240 136" + #"load 237 167" + #"tmux_mem_cpu_load 234 136" + "battery $blue $thm_bg" + #"weather 37 255" + #"rainbarf 0 ${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" + #"xkb_layout 125 117" + "date_day $teal $thm_bg" + "date $teal $thm_bg ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" + "time $teal $thm_bg ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" + #"utc_time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" ) fi diff --git a/themes/default.sh b/themes/default.sh index 71223b52..0a874daa 100644 --- a/themes/default.sh +++ b/themes/default.sh @@ -29,12 +29,12 @@ TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SEPARATOR=${TMUX_POWERLINE_DEFAULT_RIGHTSIDE_SE # shellcheck disable=SC2128 if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_CURRENT" ]; then TMUX_POWERLINE_WINDOW_STATUS_CURRENT=( - "#[$(format inverse)]" \ - "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" \ - " #I#F " \ - "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" \ - " #W " \ - "#[$(format regular)]" \ + "#[$(format inverse)]" + "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" + " #I#F " + "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" + " #W " + "#[$(format regular)]" "$TMUX_POWERLINE_DEFAULT_LEFTSIDE_SEPARATOR" ) fi @@ -49,9 +49,9 @@ fi # shellcheck disable=SC2128 if [ -z "$TMUX_POWERLINE_WINDOW_STATUS_FORMAT" ]; then TMUX_POWERLINE_WINDOW_STATUS_FORMAT=( - "#[$(format regular)]" \ - " #I#{?window_flags,#F, } " \ - "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" \ + "#[$(format regular)]" + " #I#{?window_flags,#F, } " + "$TMUX_POWERLINE_SEPARATOR_RIGHT_THIN" " #W " ) fi @@ -88,41 +88,41 @@ fi # shellcheck disable=SC1143,SC2128 if [ -z "$TMUX_POWERLINE_LEFT_STATUS_SEGMENTS" ]; then TMUX_POWERLINE_LEFT_STATUS_SEGMENTS=( - "tmux_session_info 148 234" \ - "hostname 33 0" \ - #"mode_indicator 165 0" \ - #"ifstat 30 255" \ - #"ifstat_sys 30 255" \ - "lan_ip 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" \ - #"vpn 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" \ - "wan_ip 24 255" \ - "vcs_branch 29 88" \ - #"vcs_compare 60 255" \ - #"vcs_staged 64 255" \ - #"vcs_modified 9 255" \ - #"vcs_others 245 0" \ + "tmux_session_info 148 234" + "hostname 33 0" + #"mode_indicator 165 0" + #"ifstat 30 255" + #"ifstat_sys 30 255" + "lan_ip 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" + #"vpn 24 255 ${TMUX_POWERLINE_SEPARATOR_RIGHT_THIN}" + "wan_ip 24 255" + "vcs_branch 29 88" + #"vcs_compare 60 255" + #"vcs_staged 64 255" + #"vcs_modified 9 255" + #"vcs_others 245 0" ) fi # shellcheck disable=SC1143,SC2128 if [ -z "$TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS" ]; then TMUX_POWERLINE_RIGHT_STATUS_SEGMENTS=( - #"earthquake 3 0" \ - "pwd 89 211" \ - #"macos_notification_count 29 255" \ - #"mailcount 9 255" \ - "now_playing 234 37" \ - #"cpu 240 136" \ - "load 237 167" \ - #"tmux_mem_cpu_load 234 136" \ - "battery 137 127" \ - #"air ${TMUX_POWERLINE_SEG_AIR_COLOR} 255" \ - "weather 37 255" \ - #"rainbarf 0 ${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" \ - #"xkb_layout 125 117" \ - "date_day 235 136" \ - "date 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ - "time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ - #"utc_time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" \ + #"earthquake 3 0" + "pwd 89 211" + #"macos_notification_count 29 255" + #"mailcount 9 255" + "now_playing 234 37" + #"cpu 240 136" + "load 237 167" + #"tmux_mem_cpu_load 234 136" + "battery 137 127" + #"air ${TMUX_POWERLINE_SEG_AIR_COLOR} 255" + "weather 37 255" + #"rainbarf 0 ${TMUX_POWERLINE_DEFAULT_FOREGROUND_COLOR}" + #"xkb_layout 125 117" + "date_day 235 136" + "date 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" + "time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" + #"utc_time 235 136 ${TMUX_POWERLINE_SEPARATOR_LEFT_THIN}" ) fi