diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index fe6d86c..8c17b66 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -95,11 +95,7 @@ bind-key C-a set-option -g prefix C-a # No delay for escape key press set -sg escape-time 0 -setw -g window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #W " -setw -g window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #W " - # List of plugins -set -g @plugin 'catppuccin/tmux' set -g @plugin 'tmux-plugins/tpm' set -g @plugin 'tmux-plugins/tmux-sensible' set -g @plugin 'tmux-plugins/tmux-yank' @@ -107,9 +103,10 @@ set -g @plugin 'christoomey/vim-tmux-navigator' set -g @plugin 'tmux-plugins/tmux-cpu' set -g @plugin 'tmux-plugins/tmux-battery' set -g @plugin 'tmux-plugins/tmux-cowboy' # Kill process in pane w/ prefix+* +set -g @plugin 'catppuccin/tmux' #set -g @plugin 'odedlaz/tmux-onedark-theme' -# set -g @catppuccin_flavour 'latte' # or frappe, macchiato, mocha +set -g @catppuccin_flavour 'macchiato' # or frappe, macchiato, mocha # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) run '~/.tmux/plugins/tpm/tpm' diff --git a/tmux/.tmux/plugins/tmux b/tmux/.tmux/plugins/tmux deleted file mode 160000 index d9e5c6d..0000000 --- a/tmux/.tmux/plugins/tmux +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d9e5c6d1e3b2c6f6f344f7663691c4c8e7ebeb4c diff --git a/tmux/.tmux/plugins/tmux-cpu/.github/workflows/check.yml b/tmux/.tmux/plugins/tmux-cpu/.github/workflows/check.yml new file mode 100644 index 0000000..6a7de52 --- /dev/null +++ b/tmux/.tmux/plugins/tmux-cpu/.github/workflows/check.yml @@ -0,0 +1,12 @@ +name: Check +on: + push: + pull_request: +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: luizm/action-sh-checker@master + env: + SHELLCHECK_OPTS: -x diff --git a/tmux/.tmux/plugins/tmux-cpu/cpu.tmux b/tmux/.tmux/plugins/tmux-cpu/cpu.tmux index 576c206..40d8124 100755 --- a/tmux/.tmux/plugins/tmux-cpu/cpu.tmux +++ b/tmux/.tmux/plugins/tmux-cpu/cpu.tmux @@ -1,6 +1,6 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$CURRENT_DIR/scripts/helpers.sh" @@ -65,16 +65,19 @@ set_tmux_option() { do_interpolation() { local all_interpolated="$1" - for ((i=0; i<${#cpu_commands[@]}; i++)); do + for ((i = 0; i < ${#cpu_commands[@]}; i++)); do all_interpolated=${all_interpolated//${cpu_interpolation[$i]}/${cpu_commands[$i]}} done echo "$all_interpolated" } update_tmux_option() { - local option=$1 - local option_value=$(get_tmux_option "$option") - local new_option_value=$(do_interpolation "$option_value") + local option + local option_value + local new_option_value + option=$1 + option_value=$(get_tmux_option "$option") + new_option_value=$(do_interpolation "$option_value") set_tmux_option "$option" "$new_option_value" } diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh index e78b9fd..e072405 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_bg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" cpu_low_bg_color="" @@ -19,13 +20,15 @@ get_bg_color_settings() { } print_bg_color() { - local cpu_percentage=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//') - local load_status=$(load_status $cpu_percentage) - if [ $load_status == "low" ]; then + local cpu_percentage + local load_status + cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//') + load_status=$(load_status "$cpu_percentage" "cpu") + if [ "$load_status" == "low" ]; then echo "$cpu_low_bg_color" - elif [ $load_status == "medium" ]; then + elif [ "$load_status" == "medium" ]; then echo "$cpu_medium_bg_color" - elif [ $load_status == "high" ]; then + elif [ "$load_status" == "high" ]; then echo "$cpu_high_bg_color" fi } @@ -34,4 +37,4 @@ main() { get_bg_color_settings print_bg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh index e4f7b90..3afb80e 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_fg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" cpu_low_fg_color="" @@ -19,13 +20,15 @@ get_fg_color_settings() { } print_fg_color() { - local cpu_percentage=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//') - local load_status=$(load_status $cpu_percentage) - if [ $load_status == "low" ]; then + local cpu_percentage + local load_status + cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//') + load_status=$(load_status "$cpu_percentage" "cpu") + if [ "$load_status" == "low" ]; then echo "$cpu_low_fg_color" - elif [ $load_status == "medium" ]; then + elif [ "$load_status" == "medium" ]; then echo "$cpu_medium_fg_color" - elif [ $load_status == "high" ]; then + elif [ "$load_status" == "high" ]; then echo "$cpu_high_fg_color" fi } @@ -34,4 +37,4 @@ main() { get_fg_color_settings print_fg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_icon.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_icon.sh index ca57775..99b9272 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_icon.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_icon.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" # script global variables @@ -21,13 +22,15 @@ get_icon_settings() { } print_icon() { - local cpu_percentage=$($CURRENT_DIR/cpu_percentage.sh | sed -e 's/%//') - local load_status=$(load_status $cpu_percentage) - if [ $load_status == "low" ]; then + local cpu_percentage + local load_status + cpu_percentage=$("$CURRENT_DIR"/cpu_percentage.sh | sed -e 's/%//') + load_status=$(load_status "$cpu_percentage" "cpu") + if [ "$load_status" == "low" ]; then echo "$cpu_low_icon" - elif [ $load_status == "medium" ]; then + elif [ "$load_status" == "medium" ]; then echo "$cpu_medium_icon" - elif [ $load_status == "high" ]; then + elif [ "$load_status" == "high" ]; then echo "$cpu_high_icon" fi } @@ -36,4 +39,4 @@ main() { get_icon_settings print_icon "$1" } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh index 7816e0e..15190f0 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_percentage.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" cpu_percentage_format="%3.1f%%" @@ -25,9 +26,10 @@ print_cpu_percentage() { else if is_cygwin; then usage="$(cached_eval WMIC cpu get LoadPercentage | grep -Eo '^[0-9]+')" + # shellcheck disable=SC2059 printf "$cpu_percentage_format" "$usage" else - load=`cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}'` + load=$(cached_eval ps -aux | awk '{print $3}' | tail -n+2 | awk '{s+=$1} END {print s}') cpus=$(cpus_number) echo "$load $cpus" | awk -v format="$cpu_percentage_format" '{printf format, $1/$2}' fi diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp.sh index e645ac5..624632f 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" cpu_temp_format="%2.0f" @@ -11,7 +12,13 @@ print_cpu_temp() { cpu_temp_format=$(get_tmux_option "@cpu_temp_format" "$cpu_temp_format") cpu_temp_unit=$(get_tmux_option "@cpu_temp_unit" "$cpu_temp_unit") if command_exists "sensors"; then - ([ "$cpu_temp_unit" == F ] && sensors -f || sensors) | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}' + local val + if [[ "$cpu_temp_unit" == F ]]; then + val="$(sensors -f)" + else + val="$(sensors)" + fi + echo "$val" | sed -e 's/^Tccd/Core /' | awk -v format="$cpu_temp_format$cpu_temp_unit" '/^Core [0-9]+/ {gsub("[^0-9.]", "", $3); sum+=$3; n+=1} END {printf(format, sum/n)}' fi } diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_bg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_bg_color.sh index 7cabaa2..c1fadd9 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_bg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_bg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" cpu_temp_low_bg_color="" @@ -19,13 +20,15 @@ get_bg_color_settings() { } print_bg_color() { - local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//') - local cpu_temp_status=$(temp_status $cpu_temp) - if [ $cpu_temp_status == "low" ]; then + local cpu_temp + local cpu_temp_status + cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//') + cpu_temp_status=$(temp_status "$cpu_temp") + if [ "$cpu_temp_status" == "low" ]; then echo "$cpu_temp_low_bg_color" - elif [ $cpu_temp_status == "medium" ]; then + elif [ "$cpu_temp_status" == "medium" ]; then echo "$cpu_temp_medium_bg_color" - elif [ $cpu_temp_status == "high" ]; then + elif [ "$cpu_temp_status" == "high" ]; then echo "$cpu_temp_high_bg_color" fi } diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_fg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_fg_color.sh index 73bb9bc..d5e4c6d 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_fg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_fg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" cpu_temp_low_fg_color="" @@ -19,13 +20,15 @@ get_fg_color_settings() { } print_fg_color() { - local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//') - local cpu_temp_status=$(temp_status $cpu_temp) - if [ $cpu_temp_status == "low" ]; then + local cpu_temp + local cpu_temp_status + cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//') + cpu_temp_status=$(temp_status "$cpu_temp") + if [ "$cpu_temp_status" == "low" ]; then echo "$cpu_temp_low_fg_color" - elif [ $cpu_temp_status == "medium" ]; then + elif [ "$cpu_temp_status" == "medium" ]; then echo "$cpu_temp_medium_fg_color" - elif [ $cpu_temp_status == "high" ]; then + elif [ "$cpu_temp_status" == "high" ]; then echo "$cpu_temp_high_fg_color" fi } diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_icon.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_icon.sh index 85dfec0..93ad8df 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_icon.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/cpu_temp_icon.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" # script global variables @@ -21,13 +22,15 @@ get_icon_settings() { } print_icon() { - local cpu_temp=$($CURRENT_DIR/cpu_temp.sh | sed -e 's/[^0-9.]//') - local cpu_temp_status=$(temp_status $cpu_temp) - if [ $cpu_temp_status == "low" ]; then + local cpu_temp + local cpu_temp_status + cpu_temp=$("$CURRENT_DIR"/cpu_temp.sh | sed -e 's/[^0-9.]//') + cpu_temp_status=$(temp_status "$cpu_temp") + if [ "$cpu_temp_status" == "low" ]; then echo "$cpu_temp_low_icon" - elif [ $cpu_temp_status == "medium" ]; then + elif [ "$cpu_temp_status" == "medium" ]; then echo "$cpu_temp_medium_icon" - elif [ $cpu_temp_status == "high" ]; then + elif [ "$cpu_temp_status" == "high" ]; then echo "$cpu_temp_high_icon" fi } @@ -36,4 +39,4 @@ main() { get_icon_settings print_icon "$1" } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_bg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_bg_color.sh index d1cabc6..9b978fc 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_bg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_bg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gpu_low_bg_color="" @@ -19,13 +20,15 @@ get_bg_color_settings() { } print_bg_color() { - local gpu_percentage=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//') - local gpu_load_status=$(load_status $gpu_percentage) - if [ $gpu_load_status == "low" ]; then + local gpu_percentage + local gpu_load_status + gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//') + gpu_load_status=$(load_status "$gpu_percentage" "gpu") + if [ "$gpu_load_status" == "low" ]; then echo "$gpu_low_bg_color" - elif [ $gpu_load_status == "medium" ]; then + elif [ "$gpu_load_status" == "medium" ]; then echo "$gpu_medium_bg_color" - elif [ $gpu_load_status == "high" ]; then + elif [ "$gpu_load_status" == "high" ]; then echo "$gpu_high_bg_color" fi } @@ -34,4 +37,4 @@ main() { get_bg_color_settings print_bg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_fg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_fg_color.sh index 2d42830..aa02cf6 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_fg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_fg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gpu_low_fg_color="" @@ -19,13 +20,15 @@ get_fg_color_settings() { } print_fg_color() { - local gpu_percentage=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//') - local gpu_load_status=$(load_status $gpu_percentage) - if [ $gpu_load_status == "low" ]; then + local gpu_percentage + local gpu_load_status + gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//') + gpu_load_status=$(load_status "$gpu_percentage" "gpu") + if [ "$gpu_load_status" == "low" ]; then echo "$gpu_low_fg_color" - elif [ $gpu_load_status == "medium" ]; then + elif [ "$gpu_load_status" == "medium" ]; then echo "$gpu_medium_fg_color" - elif [ $gpu_load_status == "high" ]; then + elif [ "$gpu_load_status" == "high" ]; then echo "$gpu_high_fg_color" fi } @@ -34,4 +37,4 @@ main() { get_fg_color_settings print_fg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_icon.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_icon.sh index 6f4e4e8..0bb52f4 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_icon.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_icon.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" # script global variables @@ -21,13 +22,15 @@ get_icon_settings() { } print_icon() { - local gpu_percentage=$($CURRENT_DIR/gpu_percentage.sh | sed -e 's/%//') - local gpu_load_status=$(load_status $gpu_percentage) - if [ $gpu_load_status == "low" ]; then + local gpu_percentage + local gpu_load_status + gpu_percentage=$("$CURRENT_DIR"/gpu_percentage.sh | sed -e 's/%//') + gpu_load_status=$(load_status "$gpu_percentage" "gpu") + if [ "$gpu_load_status" == "low" ]; then echo "$gpu_low_icon" - elif [ $gpu_load_status == "medium" ]; then + elif [ "$gpu_load_status" == "medium" ]; then echo "$gpu_medium_icon" - elif [ $gpu_load_status == "high" ]; then + elif [ "$gpu_load_status" == "high" ]; then echo "$gpu_high_icon" fi } @@ -36,4 +39,4 @@ main() { get_icon_settings print_icon "$1" } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_percentage.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_percentage.sh index d78dce1..e68785e 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_percentage.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_percentage.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gpu_percentage_format="%3.1f%%" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp.sh index ea9ed4d..05179a0 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gpu_temp_format="%2.0f" @@ -20,7 +21,7 @@ print_gpu_temp() { return fi tempC=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)C.*/\1/p' | awk '{sum+=$1; n+=1} END {printf "%5.3f", sum/n}') - if [ $gpu_temp_unit == "C" ]; then + if [ "$gpu_temp_unit" == "C" ]; then echo "$tempC" | awk -v format="${gpu_temp_format}C" '{sum+=$1} END {printf format, sum}' else echo "$tempC" | awk -v format="${gpu_temp_format}F" '{sum+=$1} END {printf format, sum*9/5+32}' @@ -30,4 +31,4 @@ print_gpu_temp() { main() { print_gpu_temp } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_bg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_bg_color.sh index 2bb5a70..57c566e 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_bg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_bg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gpu_temp_low_bg_color="" @@ -19,13 +20,15 @@ get_bg_color_settings() { } print_bg_color() { - local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//') - local gpu_temp_status=$(temp_status $gpu_temp) - if [ $gpu_temp_status == "low" ]; then + local gpu_temp + local gpu_temp_status + gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//') + gpu_temp_status=$(temp_status "$gpu_temp") + if [ "$gpu_temp_status" == "low" ]; then echo "$gpu_temp_low_bg_color" - elif [ $gpu_temp_status == "medium" ]; then + elif [ "$gpu_temp_status" == "medium" ]; then echo "$gpu_temp_medium_bg_color" - elif [ $gpu_temp_status == "high" ]; then + elif [ "$gpu_temp_status" == "high" ]; then echo "$gpu_temp_high_bg_color" fi } @@ -34,4 +37,4 @@ main() { get_bg_color_settings print_bg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_fg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_fg_color.sh index 4b15d7f..5dc5094 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_fg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_fg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gpu_temp_low_fg_color="" @@ -19,13 +20,15 @@ get_fg_color_settings() { } print_fg_color() { - local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//') - local gpu_temp_status=$(temp_status $gpu_temp) - if [ $gpu_temp_status == "low" ]; then + local gpu_temp + local gpu_temp_status + gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//') + gpu_temp_status=$(temp_status "$gpu_temp") + if [ "$gpu_temp_status" == "low" ]; then echo "$gpu_temp_low_fg_color" - elif [ $gpu_temp_status == "medium" ]; then + elif [ "$gpu_temp_status" == "medium" ]; then echo "$gpu_temp_medium_fg_color" - elif [ $gpu_temp_status == "high" ]; then + elif [ "$gpu_temp_status" == "high" ]; then echo "$gpu_temp_high_fg_color" fi } @@ -34,4 +37,4 @@ main() { get_fg_color_settings print_fg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_icon.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_icon.sh index d4a162d..ece6487 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_icon.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gpu_temp_icon.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" # script global variables @@ -21,13 +22,15 @@ get_icon_settings() { } print_icon() { - local gpu_temp=$($CURRENT_DIR/gpu_temp.sh | sed -e 's/[^0-9.]//') - local gpu_temp_status=$(temp_status $gpu_temp) - if [ $gpu_temp_status == "low" ]; then + local gpu_temp + local gpu_temp_status + gpu_temp=$("$CURRENT_DIR"/gpu_temp.sh | sed -e 's/[^0-9.]//') + gpu_temp_status=$(temp_status "$gpu_temp") + if [ "$gpu_temp_status" == "low" ]; then echo "$gpu_temp_low_icon" - elif [ $gpu_temp_status == "medium" ]; then + elif [ "$gpu_temp_status" == "medium" ]; then echo "$gpu_temp_medium_icon" - elif [ $gpu_temp_status == "high" ]; then + elif [ "$gpu_temp_status" == "high" ]; then echo "$gpu_temp_high_icon" fi } @@ -36,4 +39,4 @@ main() { get_icon_settings print_icon "$1" } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_bg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_bg_color.sh index 3e13315..e8d95e6 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_bg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_bg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gram_low_bg_color="" @@ -19,13 +20,15 @@ get_bg_color_settings() { } print_bg_color() { - local gram_percentage=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//') - local gram_load_status=$(load_status $gram_percentage) - if [ $gram_load_status == "low" ]; then + local gram_percentage + local gram_load_status + gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//') + gram_load_status=$(load_status "$gram_percentage" "gram") + if [ "$gram_load_status" == "low" ]; then echo "$gram_low_bg_color" - elif [ $gram_load_status == "medium" ]; then + elif [ "$gram_load_status" == "medium" ]; then echo "$gram_medium_bg_color" - elif [ $gram_load_status == "high" ]; then + elif [ "$gram_load_status" == "high" ]; then echo "$gram_high_bg_color" fi } @@ -34,4 +37,4 @@ main() { get_bg_color_settings print_bg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_fg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_fg_color.sh index bb0d035..4f4d155 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_fg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_fg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gram_low_fg_color="" @@ -19,13 +20,15 @@ get_fg_color_settings() { } print_fg_color() { - local gram_percentage=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//') - local gram_load_status=$(load_status $gram_percentage) - if [ $gram_load_status == "low" ]; then + local gram_percentage + local gram_load_status + gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//') + gram_load_status=$(load_status "$gram_percentage" "gram") + if [ "$gram_load_status" == "low" ]; then echo "$gram_low_fg_color" - elif [ $gram_load_status == "medium" ]; then + elif [ "$gram_load_status" == "medium" ]; then echo "$gram_medium_fg_color" - elif [ $gram_load_status == "high" ]; then + elif [ "$gram_load_status" == "high" ]; then echo "$gram_high_fg_color" fi } @@ -34,4 +37,4 @@ main() { get_fg_color_settings print_fg_color } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_icon.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_icon.sh index 491acf4..04eb694 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_icon.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_icon.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" # script global variables @@ -21,13 +22,15 @@ get_icon_settings() { } print_icon() { - local gram_percentage=$($CURRENT_DIR/gram_percentage.sh | sed -e 's/%//') - local gram_load_status=$(load_status $gram_percentage) - if [ $gram_load_status == "low" ]; then + local gram_percentage + local gram_load_status + gram_percentage=$("$CURRENT_DIR"/gram_percentage.sh | sed -e 's/%//') + gram_load_status=$(load_status "$gram_percentage" "gram") + if [ "$gram_load_status" == "low" ]; then echo "$gram_low_icon" - elif [ $gram_load_status == "medium" ]; then + elif [ "$gram_load_status" == "medium" ]; then echo "$gram_medium_icon" - elif [ $gram_load_status == "high" ]; then + elif [ "$gram_load_status" == "high" ]; then echo "$gram_high_icon" fi } @@ -36,4 +39,4 @@ main() { get_icon_settings print_icon "$1" } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_percentage.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_percentage.sh index 9588b43..269c260 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/gram_percentage.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/gram_percentage.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" gram_percentage_format="%3.1f%%" @@ -17,10 +18,10 @@ print_gram_percentage() { echo "No GPU" return fi - echo "$loads" | awk -v format="$gram_percentage_format" '{used+=$1; tot+=$2} END {printf format, 100*$1/$2}' + echo "$loads" | awk -v format="$gram_percentage_format" '{used+=$1; tot+=$2} END {printf format, 100*used/tot}' } main() { print_gram_percentage } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/helpers.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/helpers.sh index 8e71710..b669418 100644 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/helpers.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/helpers.sh @@ -1,10 +1,15 @@ +#!/usr/bin/env bash + export LANG=C export LC_ALL=C get_tmux_option() { - local option="$1" - local default_value="$2" - local option_value="$(tmux show-option -qv "$option")" + local option + local default_value + local option_value + option="$1" + default_value="$2" + option_value="$(tmux show-option -qv "$option")" if [ -z "$option_value" ]; then option_value="$(tmux show-option -gqv "$option")" fi @@ -16,42 +21,43 @@ get_tmux_option() { } is_osx() { - [ $(uname) == "Darwin" ] + [ "$(uname)" == "Darwin" ] } is_freebsd() { - [ $(uname) == "FreeBSD" ] + [ "$(uname)" == "FreeBSD" ] } is_openbsd() { - [ $(uname) == "OpenBSD" ] + [ "$(uname)" == "OpenBSD" ] } is_linux() { - [ $(uname) == "Linux" ] + [ "$(uname)" == "Linux" ] } is_cygwin() { - command -v WMIC &> /dev/null + command -v WMIC &>/dev/null } is_linux_iostat() { # Bug in early versions of linux iostat -V return error code - iostat -c &> /dev/null + iostat -c &>/dev/null } # is second float bigger or equal? fcomp() { - awk -v n1=$1 -v n2=$2 'BEGIN {if (n1<=n2) exit 0; exit 1}' + awk -v n1="$1" -v n2="$2" 'BEGIN {if (n1<=n2) exit 0; exit 1}' } load_status() { local percentage=$1 - cpu_medium_thresh=$(get_tmux_option "@cpu_medium_thresh" "30") - cpu_high_thresh=$(get_tmux_option "@cpu_high_thresh" "80") - if fcomp $cpu_high_thresh $percentage; then + local prefix=$2 + medium_thresh=$(get_tmux_option "@${prefix}_medium_thresh" "30") + high_thresh=$(get_tmux_option "@${prefix}_high_thresh" "80") + if fcomp "$high_thresh" "$percentage"; then echo "high" - elif fcomp $cpu_medium_thresh $percentage && fcomp $percentage $cpu_high_thresh; then + elif fcomp "$medium_thresh" "$percentage" && fcomp "$percentage" "$high_thresh"; then echo "medium" else echo "low" @@ -59,12 +65,13 @@ load_status() { } temp_status() { - local temp=$1 + local temp + temp=$1 cpu_temp_medium_thresh=$(get_tmux_option "@cpu_temp_medium_thresh" "80") cpu_temp_high_thresh=$(get_tmux_option "@cpu_temp_high_thresh" "90") - if fcomp $cpu_temp_high_thresh $temp; then + if fcomp "$cpu_temp_high_thresh" "$temp"; then echo "high" - elif fcomp $cpu_temp_medium_thresh $temp && fcomp $temp $cpu_temp_high_thresh; then + elif fcomp "$cpu_temp_medium_thresh" "$temp" && fcomp "$temp" "$cpu_temp_high_thresh"; then echo "medium" else echo "low" @@ -76,7 +83,7 @@ cpus_number() { if command_exists "nproc"; then nproc else - echo "$(( $(sed -n 's/^processor.*:\s*\([0-9]\+\)/\1/p' /proc/cpuinfo | tail -n 1) + 1 ))" + echo "$(($(sed -n 's/^processor.*:\s*\([0-9]\+\)/\1/p' /proc/cpuinfo | tail -n 1) + 1))" fi else sysctl -n hw.ncpu @@ -84,12 +91,14 @@ cpus_number() { } command_exists() { - local command="$1" - command -v "$command" &> /dev/null + local command + command="$1" + command -v "$command" &>/dev/null } get_tmp_dir() { - local tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}" + local tmpdir + tmpdir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}" [ -d "$tmpdir" ] || local tmpdir=~/tmp echo "$tmpdir/tmux-$EUID-cpu" } @@ -98,32 +107,41 @@ get_time() { date +%s.%N } -get_cache_val(){ - local key="$1" +get_cache_val() { + local key + local timeout + local cache + key="$1" # seconds after which cache is invalidated - local timeout="${2:-2}" - local cache="$(get_tmp_dir)/$key" + timeout="${2:-2}" + cache="$(get_tmp_dir)/$key" if [ -f "$cache" ]; then - awk -v cache="$(head -n1 "$cache")" -v timeout=$timeout -v now=$(get_time) \ - 'BEGIN {if (now - timeout < cache) exit 0; exit 1}' \ - && tail -n+2 "$cache" + awk -v cache="$(head -n1 "$cache")" -v timeout="$timeout" -v now="$(get_time)" \ + 'BEGIN {if (now - timeout < cache) exit 0; exit 1}' && + tail -n+2 "$cache" fi } -put_cache_val(){ - local key="$1" - local val="${@:2}" - local tmpdir="$(get_tmp_dir)" +put_cache_val() { + local key + local val + local tmpdir + key="$1" + val="${*:2}" + tmpdir="$(get_tmp_dir)" [ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir" - echo "$(get_time)" > "$tmpdir/$key" - echo -n "$val" >> "$tmpdir/$key" + get_time >"$tmpdir/$key" + echo -n "$val" >>"$tmpdir/$key" echo -n "$val" } -cached_eval(){ - local command="$1" - local key="$(basename "$command")" - local val="$(get_cache_val "$key")" +cached_eval() { + local command + local key + local val + command="$1" + key="$(basename "$command")" + val="$(get_cache_val "$key")" if [ -z "$val" ]; then put_cache_val "$key" "$($command "${@:2}")" else diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_bg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_bg_color.sh index e864d23..57ae7e7 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_bg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_bg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" ram_low_bg_color="" @@ -19,13 +20,15 @@ get_bg_color_settings() { } print_bg_color() { - local ram_percentage=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//') - local ram_load_status=$(load_status $ram_percentage) - if [ $ram_load_status == "low" ]; then + local ram_percentage + local ram_load_status + ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//') + ram_load_status=$(load_status "$ram_percentage" "ram") + if [ "$ram_load_status" == "low" ]; then echo "$ram_low_bg_color" - elif [ $ram_load_status == "medium" ]; then + elif [ "$ram_load_status" == "medium" ]; then echo "$ram_medium_bg_color" - elif [ $ram_load_status == "high" ]; then + elif [ "$ram_load_status" == "high" ]; then echo "$ram_high_bg_color" fi } diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_fg_color.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_fg_color.sh index 9102870..9d5a172 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_fg_color.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_fg_color.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" ram_low_fg_color="" @@ -19,13 +20,15 @@ get_fg_color_settings() { } print_fg_color() { - local ram_percentage=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//') - local ram_load_status=$(load_status $ram_percentage) - if [ $ram_load_status == "low" ]; then + local ram_percentage + local ram_load_status + ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//') + ram_load_status=$(load_status "$ram_percentage" "ram") + if [ "$ram_load_status" == "low" ]; then echo "$ram_low_fg_color" - elif [ $ram_load_status == "medium" ]; then + elif [ "$ram_load_status" == "medium" ]; then echo "$ram_medium_fg_color" - elif [ $ram_load_status == "high" ]; then + elif [ "$ram_load_status" == "high" ]; then echo "$ram_high_fg_color" fi } diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_icon.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_icon.sh index e27c64d..5ad253b 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_icon.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_icon.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" # script global variables @@ -21,13 +22,15 @@ get_icon_settings() { } print_icon() { - local ram_percentage=$($CURRENT_DIR/ram_percentage.sh | sed -e 's/%//') - local ram_load_status=$(load_status $ram_percentage) - if [ $ram_load_status == "low" ]; then + local ram_percentage + local ram_load_status + ram_percentage=$("$CURRENT_DIR"/ram_percentage.sh | sed -e 's/%//') + ram_load_status=$(load_status "$ram_percentage" "ram") + if [ "$ram_load_status" == "low" ]; then echo "$ram_low_icon" - elif [ $ram_load_status == "medium" ]; then + elif [ "$ram_load_status" == "medium" ]; then echo "$ram_medium_icon" - elif [ $ram_load_status == "high" ]; then + elif [ "$ram_load_status" == "high" ]; then echo "$ram_high_icon" fi } @@ -36,4 +39,4 @@ main() { get_icon_settings print_icon "$1" } -main +main "$@" diff --git a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_percentage.sh b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_percentage.sh index df31c2c..25c85cd 100755 --- a/tmux/.tmux/plugins/tmux-cpu/scripts/ram_percentage.sh +++ b/tmux/.tmux/plugins/tmux-cpu/scripts/ram_percentage.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/helpers.sh source "$CURRENT_DIR/helpers.sh" ram_percentage_format="%3.1f%%" sum_macos_vm_stats() { - grep -Eo '[0-9]+' \ - | awk '{ a += $1 * 4096 } END { print a }' + grep -Eo '[0-9]+' | + awk '{ a += $1 * 4096 } END { print a }' } print_ram_percentage() { @@ -20,23 +21,26 @@ print_ram_percentage() { # page size of 4096 bytes stats="$(cached_eval vm_stat)" - used_and_cached=$(echo "$stats" \ - | grep -E "(Pages active|Pages inactive|Pages speculative|Pages wired down|Pages occupied by compressor)" \ - | sum_macos_vm_stats \ + used_and_cached=$( + echo "$stats" | + grep -E "(Pages active|Pages inactive|Pages speculative|Pages wired down|Pages occupied by compressor)" | + sum_macos_vm_stats ) - cached=$(echo "$stats" \ - | grep -E "(Pages purgeable|File-backed pages)" \ - | sum_macos_vm_stats \ + cached=$( + echo "$stats" | + grep -E "(Pages purgeable|File-backed pages)" | + sum_macos_vm_stats ) - free=$(echo "$stats" \ - | grep -E "(Pages free)" \ - | sum_macos_vm_stats \ + free=$( + echo "$stats" | + grep -E "(Pages free)" | + sum_macos_vm_stats ) - used=$(($used_and_cached - $cached)) - total=$(($used_and_cached + $free)) + used=$((used_and_cached - cached)) + total=$((used_and_cached + free)) echo "$used $total" | awk -v format="$ram_percentage_format" '{printf(format, 100*$1/$2)}' fi diff --git a/tmux/.tmux/plugins/tmux-sensible/README.md b/tmux/.tmux/plugins/tmux-sensible/README.md index 7185b67..fff34fa 100644 --- a/tmux/.tmux/plugins/tmux-sensible/README.md +++ b/tmux/.tmux/plugins/tmux-sensible/README.md @@ -24,56 +24,60 @@ Tested and working on Linux, OSX and Cygwin. ### Options - # utf8 is on - set -g utf8 on - set -g status-utf8 on +```tmux +# Address vim mode switching delay (http://superuser.com/a/252717/65504) +set -s escape-time 0 - # address vim mode switching delay (http://superuser.com/a/252717/65504) - set -s escape-time 0 +# Increase scrollback buffer size from 2000 to 50000 lines +set -g history-limit 50000 - # increase scrollback buffer size - set -g history-limit 50000 +# Increase tmux messages display duration from 750ms to 4s +set -g display-time 4000 - # tmux messages are displayed for 4 seconds - set -g display-time 4000 +# Refresh 'status-left' and 'status-right' more often, from every 15s to 5s +set -g status-interval 5 - # refresh 'status-left' and 'status-right' more often - set -g status-interval 5 +# (OS X) Fix pbcopy/pbpaste for old tmux versions (pre 2.6) +set -g default-command "reattach-to-user-namespace -l $SHELL" - # set only on OS X where it's required - set -g default-command "reattach-to-user-namespace -l $SHELL" +# Upgrade $TERM +set -g default-terminal "screen-256color" - # upgrade $TERM - set -g default-terminal "screen-256color" +# Emacs key bindings in tmux command prompt (prefix + :) are better than +# vi keys, even for vim users +set -g status-keys emacs - # emacs key bindings in tmux command prompt (prefix + :) are better than - # vi keys, even for vim users - set -g status-keys emacs +# Focus events enabled for terminals that support them +set -g focus-events on - # focus events enabled for terminals that support them - set -g focus-events on - - # super useful when using "grouped sessions" and multi-monitor setup - setw -g aggressive-resize on +# Super useful when using "grouped sessions" and multi-monitor setup +setw -g aggressive-resize on +``` ### Key bindings - # easier and faster switching between next/prev window - bind C-p previous-window - bind C-n next-window +```tmux +# Easier and faster switching between next/prev window +bind C-p previous-window +bind C-n next-window +``` Above bindings enhance the default `prefix + p` and `prefix + n` bindings by allowing you to hold `Ctrl` and repeat `a + p`/`a + n` (if your prefix is `C-a`), which is a lot quicker. - # source .tmux.conf as suggested in `man tmux` - bind R source-file '~/.tmux.conf' +```tmux +# Source .tmux.conf as suggested in `man tmux` +bind R source-file '~/.tmux.conf' +``` "Adaptable" key bindings that build upon your `prefix` value: - # if prefix is 'C-a' - bind C-a send-prefix - bind a last-window +```tmux +# If prefix is 'C-a' +bind C-a send-prefix +bind a last-window +``` If prefix is `C-b`, above keys will be `C-b` and `b`.
If prefix is `C-z`, above keys will be `C-z` and `z`... you get the idea. @@ -82,7 +86,9 @@ If prefix is `C-z`, above keys will be `C-z` and `z`... you get the idea. Add plugin to the list of TPM plugins in `.tmux.conf`: - set -g @plugin 'tmux-plugins/tmux-sensible' +```tmux +set -g @plugin 'tmux-plugins/tmux-sensible' +``` Hit `prefix + I` to fetch the plugin and source it. That's it! @@ -94,7 +100,9 @@ Clone the repo: Add this line to the bottom of `.tmux.conf`: - run-shell ~/clone/path/sensible.tmux +```tmux +run-shell ~/clone/path/sensible.tmux +``` Reload TMUX environment with `$ tmux source-file ~/.tmux.conf`, and that's it. diff --git a/tmux/.tmux/plugins/tmux-sensible/sensible.tmux b/tmux/.tmux/plugins/tmux-sensible/sensible.tmux old mode 100644 new mode 100755 index 5cf2af6..66db3c1 --- a/tmux/.tmux/plugins/tmux-sensible/sensible.tmux +++ b/tmux/.tmux/plugins/tmux-sensible/sensible.tmux @@ -11,7 +11,7 @@ is_osx() { } iterm_terminal() { - [[ "$TERM_PROGRAM" =~ ^iTerm ]] + [[ "${TERM_PROGRAM}" =~ ^iTerm || "${LC_TERMINAL}" =~ ^iTerm ]] } command_exists() { @@ -45,7 +45,7 @@ server_option_value_not_changed() { } key_binding_not_set() { - local key="$1" + local key="${1//\\/\\\\}" if $(tmux list-keys | grep -q "${KEY_BINDING_REGEX}${key}[[:space:]]"); then return 1 else @@ -64,15 +64,20 @@ key_binding_not_changed() { fi } +get_tmux_config() { + local tmux_config_xdg="${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf" + local tmux_config="$HOME/.tmux.conf" + + if [ -f "${tmux_config_xdg}" ]; then + echo "${tmux_config_xdg}" + else + echo ${tmux_config} + fi +} + main() { # OPTIONS - # enable utf8 (option removed in tmux 2.2) - tmux set-option -g utf8 on 2>/dev/null - - # enable utf8 in tmux status-left and status-right (option removed in tmux 2.2) - tmux set-option -g status-utf8 on 2>/dev/null - # address vim mode switching delay (http://superuser.com/a/252717/65504) if server_option_value_not_changed "escape-time" "500"; then tmux set-option -s escape-time 0 @@ -153,9 +158,11 @@ main() { # source `.tmux.conf` file - as suggested in `man tmux` if key_binding_not_set "R"; then - tmux bind-key R run-shell ' \ - tmux source-file ~/.tmux.conf > /dev/null; \ - tmux display-message "Sourced .tmux.conf!"' + local tmux_config=$(get_tmux_config) + + tmux bind-key R run-shell " \ + tmux source-file ${tmux_config} > /dev/null; \ + tmux display-message 'Sourced ${tmux_config}!'" fi } main diff --git a/tmux/.tmux/plugins/tmux-yank/README.md b/tmux/.tmux/plugins/tmux-yank/README.md index b6d8916..cfe5a79 100644 --- a/tmux/.tmux/plugins/tmux-yank/README.md +++ b/tmux/.tmux/plugins/tmux-yank/README.md @@ -76,6 +76,8 @@ without `reattach-to-user-namespace`. It doesn't hurt to have it installed. - OS X 10.10: Yosemite โ€“ *not required* - OS X 10.11: El Capitan โ€“ *not required* - macOS 10.12: Sierra โ€“ *required* +- macOS 10.14: Mojave - *required* +- macOS 10.15: Catalina - *not required* The easiest way to use `reattach-to-user-namespace` with `tmux` is use to use the [`tmux-sensible`](https://github.com/tmux-plugins/tmux-sensible) diff --git a/tmux/.tmux/plugins/tmux-yank/citest b/tmux/.tmux/plugins/tmux-yank/citest old mode 100644 new mode 100755 diff --git a/tmux/.tmux/plugins/tmux-yank/scripts/copy_line.sh b/tmux/.tmux/plugins/tmux-yank/scripts/copy_line.sh old mode 100644 new mode 100755 diff --git a/tmux/.tmux/plugins/tmux-yank/scripts/copy_pane_pwd.sh b/tmux/.tmux/plugins/tmux-yank/scripts/copy_pane_pwd.sh old mode 100644 new mode 100755 index 07b6f95..1db321f --- a/tmux/.tmux/plugins/tmux-yank/scripts/copy_pane_pwd.sh +++ b/tmux/.tmux/plugins/tmux-yank/scripts/copy_pane_pwd.sh @@ -16,10 +16,13 @@ display_notice() { main() { local copy_command + local payload # shellcheck disable=SC2119 copy_command="$(clipboard_copy_command)" + payload="$(pane_current_path | tr -d '\n')" # $copy_command below should not be quoted - pane_current_path | tr -d '\n' | $copy_command + echo "$payload" | $copy_command + tmux set-buffer "$payload" display_notice } main diff --git a/tmux/.tmux/plugins/tmux-yank/scripts/helpers.sh b/tmux/.tmux/plugins/tmux-yank/scripts/helpers.sh index c80a93f..66beeec 100644 --- a/tmux/.tmux/plugins/tmux-yank/scripts/helpers.sh +++ b/tmux/.tmux/plugins/tmux-yank/scripts/helpers.sh @@ -174,7 +174,7 @@ clipboard_copy_command() { } # Cache the TMUX version for speed. -tmux_version="$(tmux -V | cut -d ' ' -f 2)" +tmux_version="$(tmux -V | cut -d ' ' -f 2 | sed 's/next-//')" tmux_is_at_least() { if [[ $tmux_version == "$1" ]] || [[ $tmux_version == master ]]; then @@ -200,6 +200,9 @@ tmux_is_at_least() { if ((10#${current_version[i]} < 10#${wanted_version[i]})); then return 1 fi + if ((10#${current_version[i]} > 10#${wanted_version[i]})); then + return 0 + fi done return 0 } diff --git a/tmux/.tmux/plugins/tmux-yank/yank.tmux b/tmux/.tmux/plugins/tmux-yank/yank.tmux old mode 100644 new mode 100755 diff --git a/tmux/.tmux/plugins/tmux/LICENSE b/tmux/.tmux/plugins/tmux/LICENSE new file mode 100644 index 0000000..006383b --- /dev/null +++ b/tmux/.tmux/plugins/tmux/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Catppuccin + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/tmux/.tmux/plugins/tmux/README.md b/tmux/.tmux/plugins/tmux/README.md new file mode 100644 index 0000000..6bf042c --- /dev/null +++ b/tmux/.tmux/plugins/tmux/README.md @@ -0,0 +1,58 @@ +

+ Logo
+ + Catppuccin for Tmux + +

+ +

+ + + +

+ +

+ +

+ +## Themes + +- ๐ŸŒป [Latte](./catppuccin-latte.tmuxtheme) +- ๐Ÿชด [Frappรฉ](./catppuccin-frappe.tmuxtheme) +- ๐ŸŒบ [Macchiato](./catppuccin-macchiato.tmuxtheme) +- ๐ŸŒฟ [Mocha](./catppuccin-mocha.tmuxtheme) + +## Usage + +### TPM + +1. Install [TPM](https://github.com/tmux-plugins/tpm) +2. Add the Catppuccin plugin: + +```bash +set -g @plugin 'catppuccin/tmux' +# ...alongside +set -g @plugin 'tmux-plugins/tpm' +``` + +3. (Optional) Set your preferred flavour, it defaults to `"mocha"`: + +```bash +set -g @catppuccin_flavour 'latte' # or frappe, macchiato, mocha +``` + +### Manual + +1. Copy your desired theme's configuration contents into your Tmux config (usually stored at `~/.tmux.conf`) +2. Reload Tmux by either restarting the session or reloading it with `tmux source-file ~/.tmux.conf` + +## ๐Ÿ’ Thanks to + +- [Pocco81](https://github.com/catppuccin) +- [vinnyA3](https://github.com/vinnyA3) + +  + +

+

Copyright © 2021-present Catppuccin Org +

diff --git a/tmux/.tmux/plugins/tmux/assets/frappe.webp b/tmux/.tmux/plugins/tmux/assets/frappe.webp new file mode 100644 index 0000000..64c14f8 Binary files /dev/null and b/tmux/.tmux/plugins/tmux/assets/frappe.webp differ diff --git a/tmux/.tmux/plugins/tmux/assets/latte.webp b/tmux/.tmux/plugins/tmux/assets/latte.webp new file mode 100644 index 0000000..6e48ac9 Binary files /dev/null and b/tmux/.tmux/plugins/tmux/assets/latte.webp differ diff --git a/tmux/.tmux/plugins/tmux/assets/macchiato.webp b/tmux/.tmux/plugins/tmux/assets/macchiato.webp new file mode 100644 index 0000000..df3aa04 Binary files /dev/null and b/tmux/.tmux/plugins/tmux/assets/macchiato.webp differ diff --git a/tmux/.tmux/plugins/tmux/assets/mocha.webp b/tmux/.tmux/plugins/tmux/assets/mocha.webp new file mode 100644 index 0000000..d9ee469 Binary files /dev/null and b/tmux/.tmux/plugins/tmux/assets/mocha.webp differ diff --git a/tmux/.tmux/plugins/tmux/assets/preview.webp b/tmux/.tmux/plugins/tmux/assets/preview.webp new file mode 100644 index 0000000..3224dc1 Binary files /dev/null and b/tmux/.tmux/plugins/tmux/assets/preview.webp differ diff --git a/tmux/.tmux/plugins/tmux/catppuccin-frappe.tmuxtheme b/tmux/.tmux/plugins/tmux/catppuccin-frappe.tmuxtheme new file mode 100755 index 0000000..8ed37a8 --- /dev/null +++ b/tmux/.tmux/plugins/tmux/catppuccin-frappe.tmuxtheme @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" +# WARNING: hex colors can't contain capital letters + +# --> Catppuccin (Frappe) +thm_bg="#303446" +thm_fg="#c6d0f5" +thm_cyan="#99d1db" +thm_black="#292c3c" +thm_gray="#414559" +thm_magenta="#ca9ee6" +thm_pink="#f4b8e4" +thm_red="#e78284" +thm_green="#a6d189" +thm_yellow="#e5c890" +thm_blue="#8caaee" +thm_orange="#ef9f76" +thm_black4="#626880" + +# ----------------------------=== Theme ===-------------------------- + +# utils +set() { + local option=$1 + local value=$2 + tmux set-option -gq "$option" "$value" +} + +setw() { + local option=$1 + local value=$2 + tmux set-window-option -gq "$option" "$value" +} + +# status +set status "on" +set status-bg "${thm_bg}" +set status-justify "left" +set status-left-length "100" +set status-right-length "100" + +# messages +set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" +set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + +# panes +set pane-border-style "fg=${thm_gray}" +set pane-active-border-style "fg=${thm_blue}" + +# windows +setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" +setw window-status-separator "" +setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + +# --------=== Statusline + +set status-left "" +set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]๎‚ถ#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]๏†ฎ #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]๎‚ถ#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]๎ž• #[fg=$thm_fg,bg=$thm_gray] #S " + +# current_dir +setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " +setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " + +# parent_dir/current_dir +# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " +# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + +# --------=== Modes +setw clock-mode-colour "${thm_blue}" +setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/tmux/.tmux/plugins/tmux/catppuccin-latte.tmuxtheme b/tmux/.tmux/plugins/tmux/catppuccin-latte.tmuxtheme new file mode 100755 index 0000000..1ddb188 --- /dev/null +++ b/tmux/.tmux/plugins/tmux/catppuccin-latte.tmuxtheme @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" +# WARNING: hex colors can't contain capital letters + +# --> Catppuccin (Latte) +thm_bg="#dce0e8" +thm_fg="#4c4f69" +thm_cyan="#179299" +thm_black="#e6e9ef" +thm_gray="#bcc0cc" +thm_magenta="#ea76cb" +thm_pink="#8839ef" +thm_red="#d20f39" +thm_green="#40a02b" +thm_yellow="#df8e1d" +thm_blue="#1e66f5" +thm_orange="#fe640b" +thm_black4="#acb0be" + +# ----------------------------=== Theme ===-------------------------- + +# utils +set() { + local option=$1 + local value=$2 + tmux set-option -gq "$option" "$value" +} + +setw() { + local option=$1 + local value=$2 + tmux set-window-option -gq "$option" "$value" +} + +# status +set status "on" +set status-bg "${thm_bg}" +set status-justify "left" +set status-left-length "100" +set status-right-length "100" + +# messages +set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" +set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + +# panes +set pane-border-style "fg=${thm_gray}" +set pane-active-border-style "fg=${thm_blue}" + +# windows +setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" +setw window-status-separator "" +setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + +# --------=== Statusline + +set status-left "" +set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]๎‚ถ#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]๏†ฎ #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]๎‚ถ#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]๎ž• #[fg=$thm_fg,bg=$thm_gray] #S " + +# current_dir +setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " +setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " + +# parent_dir/current_dir +# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " +# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + +# --------=== Modes +setw clock-mode-colour "${thm_blue}" +setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/tmux/.tmux/plugins/tmux/catppuccin-macchiato.tmuxtheme b/tmux/.tmux/plugins/tmux/catppuccin-macchiato.tmuxtheme new file mode 100755 index 0000000..3b16b64 --- /dev/null +++ b/tmux/.tmux/plugins/tmux/catppuccin-macchiato.tmuxtheme @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" +# WARNING: hex colors can't contain capital letters + +# --> Catppuccin (Macchiato) +thm_bg="#24273a" +thm_fg="#cad3f5" +thm_cyan="#91d7e3" +thm_black="#1e2030" +thm_gray="#363a4f" +thm_magenta="#c6a0f6" +thm_pink="#f5bde6" +thm_red="#ed8796" +thm_green="#a6da95" +thm_yellow="#eed49f" +thm_blue="#8aadf4" +thm_orange="#f5a97f" +thm_black4="#5b6078" + +# ----------------------------=== Theme ===-------------------------- + +# utils +set() { + local option=$1 + local value=$2 + tmux set-option -gq "$option" "$value" +} + +setw() { + local option=$1 + local value=$2 + tmux set-window-option -gq "$option" "$value" +} + +# status +set status "on" +set status-bg "${thm_bg}" +set status-justify "left" +set status-left-length "100" +set status-right-length "100" + +# messages +set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" +set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + +# panes +set pane-border-style "fg=${thm_gray}" +set pane-active-border-style "fg=${thm_blue}" + +# windows +setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" +setw window-status-separator "" +setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + +# --------=== Statusline + +set status-left "" +set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]๎‚ถ#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]๏†ฎ #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]๎‚ถ#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]๎ž• #[fg=$thm_fg,bg=$thm_gray] #S " + +# current_dir +setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #W " +setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #W " + +# parent_dir/current_dir +# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " +# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + +# --------=== Modes +setw clock-mode-colour "${thm_blue}" +setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/tmux/.tmux/plugins/tmux/catppuccin-mocha.tmuxtheme b/tmux/.tmux/plugins/tmux/catppuccin-mocha.tmuxtheme new file mode 100755 index 0000000..d0b64fa --- /dev/null +++ b/tmux/.tmux/plugins/tmux/catppuccin-mocha.tmuxtheme @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +# NOTE: you can use vars with $ and ${} as long as the str is double quoted: "" +# WARNING: hex colors can't contain capital letters + +# --> Catppuccin (Mocha) +thm_bg="#1e1e2e" +thm_fg="#cdd6f4" +thm_cyan="#89dceb" +thm_black="#181825" +thm_gray="#313244" +thm_magenta="#cba6f7" +thm_pink="#f5c2e7" +thm_red="#f38ba8" +thm_green="#a6e3a1" +thm_yellow="#f9e2af" +thm_blue="#89b4fa" +thm_orange="#fab387" +thm_black4="#585b70" + +# ----------------------------=== Theme ===-------------------------- + +# utils +set() { + local option=$1 + local value=$2 + tmux set-option -gq "$option" "$value" +} + +setw() { + local option=$1 + local value=$2 + tmux set-window-option -gq "$option" "$value" +} + +# status +set status "on" +set status-bg "${thm_bg}" +set status-justify "left" +set status-left-length "100" +set status-right-length "100" + +# messages +set message-style "fg=${thm_cyan},bg=${thm_gray},align=centre" +set message-command-style "fg=${thm_cyan},bg=${thm_gray},align=centre" + +# panes +set pane-border-style "fg=${thm_gray}" +set pane-active-border-style "fg=${thm_blue}" + +# windows +setw window-status-activity-style "fg=${thm_fg},bg=${thm_bg},none" +setw window-status-separator "" +setw window-status-style "fg=${thm_fg},bg=${thm_bg},none" + +# --------=== Statusline + +set status-left "" +set status-right "#[fg=$thm_pink,bg=$thm_bg,nobold,nounderscore,noitalics]๎‚ถ#[fg=$thm_bg,bg=$thm_pink,nobold,nounderscore,noitalics]๏†ฎ #[fg=$thm_fg,bg=$thm_gray] #W #{?client_prefix,#[fg=$thm_red],#[fg=$thm_green]}#[bg=$thm_gray]๎‚ถ#{?client_prefix,#[bg=$thm_red],#[bg=$thm_green]}#[fg=$thm_bg]๎ž• #[fg=$thm_fg,bg=$thm_gray] #S " + +# current_dir +setw window-status-format "#[fg=$thm_bg,bg=$thm_blue] #I #[fg=$thm_fg,bg=$thm_gray] #{b:pane_current_path} " +setw window-status-current-format "#[fg=$thm_bg,bg=$thm_orange] #I #[fg=$thm_fg,bg=$thm_bg] #{b:pane_current_path} " + +# parent_dir/current_dir +# setw window-status-format "#[fg=colour232,bg=colour111] #I #[fg=colour222,bg=colour235] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " +# setw window-status-current-format "#[fg=colour232,bg=colour208] #I #[fg=colour255,bg=colour237] #(echo '#{pane_current_path}' | rev | cut -d'/' -f-2 | rev) " + +# --------=== Modes +setw clock-mode-colour "${thm_blue}" +setw mode-style "fg=${thm_pink} bg=${thm_black4} bold" diff --git a/tmux/.tmux/plugins/tmux/catppuccin.tmux b/tmux/.tmux/plugins/tmux/catppuccin.tmux new file mode 100755 index 0000000..928321f --- /dev/null +++ b/tmux/.tmux/plugins/tmux/catppuccin.tmux @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +get-tmux-option() { + local option value default + option="$1" + default="$2" + value="$(tmux show-option -gqv "$option")" + + if [ -n "$value" ]; then + echo "$value" + else + echo "$default" + fi +} + +main() { + local theme + theme="$(get-tmux-option "@catppuccin_flavour" "mocha")" + tmux run -b "$CURRENT_DIR/catppuccin-${theme}.tmuxtheme" +} + +main "$@" diff --git a/tmux/.tmux/plugins/tpm/docs/how_to_create_plugin.md b/tmux/.tmux/plugins/tpm/docs/how_to_create_plugin.md index b1a68f9..f7d9c13 100644 --- a/tmux/.tmux/plugins/tpm/docs/how_to_create_plugin.md +++ b/tmux/.tmux/plugins/tpm/docs/how_to_create_plugin.md @@ -92,12 +92,12 @@ That should set up the key binding. Now hit `prefix + T` and see if it works. ### 6. publish the plugin When everything is ready, push the plugin to an online git repository, -preferably Github. +preferably GitHub. Other users can install your plugin by just adding plugin git URL to the `@plugin` list in their `.tmux.conf`. -If the plugin is on Github, your users will be able to use the shorthand of +If the plugin is on GitHub, your users will be able to use the shorthand of `github_username/repository`. ### Conclusion diff --git a/tmux/.tmux/plugins/tpm/lib/tmux-test b/tmux/.tmux/plugins/tpm/lib/tmux-test new file mode 160000 index 0000000..33fa65f --- /dev/null +++ b/tmux/.tmux/plugins/tpm/lib/tmux-test @@ -0,0 +1 @@ +Subproject commit 33fa65fbfb72ba6dd106c21bf5ee6cc353ecdbb6 diff --git a/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh b/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh index 81e6836..e2450ac 100755 --- a/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh +++ b/tmux/.tmux/plugins/tpm/scripts/install_plugins.sh @@ -26,7 +26,7 @@ clone() { # tries cloning: # 1. plugin name directly - works if it's a valid git url -# 2. expands the plugin name to point to a github repo and tries cloning again +# 2. expands the plugin name to point to a GitHub repo and tries cloning again clone_plugin() { local plugin="$1" local branch="$2" diff --git a/tmux/.tmux/plugins/vim-tmux-navigator/README.md b/tmux/.tmux/plugins/vim-tmux-navigator/README.md index 63e5e7c..256dd98 100644 --- a/tmux/.tmux/plugins/vim-tmux-navigator/README.md +++ b/tmux/.tmux/plugins/vim-tmux-navigator/README.md @@ -115,16 +115,16 @@ Add the following to your `~/.vimrc` to define your custom maps: ``` vim let g:tmux_navigator_no_mappings = 1 -nnoremap {Left-Mapping} :TmuxNavigateLeft -nnoremap {Down-Mapping} :TmuxNavigateDown -nnoremap {Up-Mapping} :TmuxNavigateUp -nnoremap {Right-Mapping} :TmuxNavigateRight -nnoremap {Previous-Mapping} :TmuxNavigatePrevious +noremap {Left-Mapping} :TmuxNavigateLeft +noremap {Down-Mapping} :TmuxNavigateDown +noremap {Up-Mapping} :TmuxNavigateUp +noremap {Right-Mapping} :TmuxNavigateRight +noremap {Previous-Mapping} :TmuxNavigatePrevious ``` *Note* Each instance of `{Left-Mapping}` or `{Down-Mapping}` must be replaced in the above code with the desired mapping. Ie, the mapping for `` => -Left would be created with `nnoremap :TmuxNavigateLeft`. +Left would be created with `noremap :TmuxNavigateLeft`. ##### Autosave on leave @@ -199,6 +199,33 @@ With this enabled you can use ` C-l` to clear the screen. Thanks to [Brian Hogan][] for the tip on how to re-map the clear screen binding. +#### Disable Wrapping + +By default, if you tru to move past the edge of the screen, tmux/vim will +"wrap" around to the opposite side. To disable this, you'll need to +configure both tmux and vim: + +For vim, you only need to enable this option: +```vim +let g:tmux_navigator_no_wrap = 1 +``` + +Tmux doesn't haave an option, so whatever key bindings you have need to be set +to conditionally wrap based on position on screen: +```tmux +is_vim="ps -o state= -o comm= -t '#{pane_tty}' \ + | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'" +bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if-shell -F '#{pane_at_left}' {} { select-pane -L } } +bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } } +bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } } +bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if-shell -F '#{pane_at_right}' {} { select-pane -R } } + +bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' {} { select-pane -L } +bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D } +bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U } +bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R } +``` + #### Nesting If you like to nest your tmux sessions, this plugin is not going to work properly. It probably never will, as it would require detecting when Tmux would @@ -236,7 +263,7 @@ Troubleshooting This is likely due to conflicting key mappings in your `~/.vimrc`. You can use the following search pattern to find conflicting mappings -`\vn(nore)?map\s+\`. Any matching lines should be deleted or +`\v(nore)?map\s+\`. Any matching lines should be deleted or altered to avoid conflicting with the mappings from the plugin. Another option is that the pattern matching included in the `.tmux.conf` is diff --git a/tmux/.tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt b/tmux/.tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt index 752abb4..d4ae0ad 100644 --- a/tmux/.tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt +++ b/tmux/.tmux/plugins/vim-tmux-navigator/doc/tmux-navigator.txt @@ -30,10 +30,10 @@ CONFIGURATION *tmux-navigator-configuration* * Custom Key Bindings let g:tmux_navigator_no_mappings = 1 - nnoremap {Left-mapping} :TmuxNavigateLeft - nnoremap {Down-Mapping} :TmuxNavigateDown - nnoremap {Up-Mapping} :TmuxNavigateUp - nnoremap {Right-Mapping} :TmuxNavigateRight - nnoremap {Previous-Mapping} :TmuxNavigatePrevious + noremap {Left-mapping} :TmuxNavigateLeft + noremap {Down-Mapping} :TmuxNavigateDown + noremap {Up-Mapping} :TmuxNavigateUp + noremap {Right-Mapping} :TmuxNavigateRight + noremap {Previous-Mapping} :TmuxNavigatePrevious vim:tw=78:ts=8:ft=help:norl: diff --git a/tmux/.tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim b/tmux/.tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim index 45a8f7f..81a593a 100644 --- a/tmux/.tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim +++ b/tmux/.tmux/plugins/vim-tmux-navigator/plugin/tmux_navigator.vim @@ -16,11 +16,11 @@ function! s:VimNavigate(direction) endfunction if !get(g:, 'tmux_navigator_no_mappings', 0) - nnoremap :TmuxNavigateLeft - nnoremap :TmuxNavigateDown - nnoremap :TmuxNavigateUp - nnoremap :TmuxNavigateRight - nnoremap :TmuxNavigatePrevious + noremap :TmuxNavigateLeft + noremap :TmuxNavigateDown + noremap :TmuxNavigateUp + noremap :TmuxNavigateRight + noremap :TmuxNavigatePrevious endif if empty($TMUX) @@ -50,6 +50,12 @@ if !exists("g:tmux_navigator_preserve_zoom") let g:tmux_navigator_preserve_zoom = 0 endif +if !exists("g:tmux_navigator_no_wrap") + let g:tmux_navigator_no_wrap = 0 +endif + +let s:pane_position_from_direction = {'h': 'left', 'j': 'bottom', 'k': 'top', 'l': 'right'} + function! s:TmuxOrTmateExecutable() return (match($TMUX, 'tmate') != -1 ? 'tmate' : 'tmux') endfunction @@ -120,6 +126,9 @@ function! s:TmuxAwareNavigate(direction) if g:tmux_navigator_preserve_zoom == 1 let l:args .= ' -Z' endif + if g:tmux_navigator_no_wrap == 1 + let args = 'if -F "#{pane_at_' . s:pane_position_from_direction[a:direction] . '}" "" "' . args . '"' + endif silent call s:TmuxCommand(args) if s:NeedsVitalityRedraw() redraw! diff --git a/tmux/.tmuxinator/dev.yml b/tmux/.tmuxinator/dev.yml index 61b3022..a945f3b 100644 --- a/tmux/.tmuxinator/dev.yml +++ b/tmux/.tmuxinator/dev.yml @@ -7,7 +7,7 @@ windows: panes: - main: - hgd gmscore - - vim -S ~/.sessions/gmscore.vim + - vim - other: - hgd gmscore - other2: @@ -18,7 +18,7 @@ windows: panes: - main: - hgd experimental - - vim -S ~/.sessions/experimental.vim + - vim - other: - hgd experimental - other2: @@ -29,7 +29,7 @@ windows: - main: - hgd notes - cd ../company/users/cnieves/ - - vim -S ~/.sessions/notes.vim + - vim - other: - hgd notes - cd ../company/users/cnieves/ @@ -41,7 +41,7 @@ windows: panes: - main: - cd ~/.vim/prefs - - vim -S ~/.sessions/vim.vim + - vim - other: - cd ~/.vim/prefs - other2: