From 72e385c44dfa2e1f7a81ec6a21d7016d60572ac6 Mon Sep 17 00:00:00 2001 From: Janno Tjarks Date: Fri, 11 Feb 2022 16:38:16 +0100 Subject: [PATCH 01/46] Added kubernetes-context plugin --- README.md | 1 + scripts/dracula.sh | 6 +++++ scripts/kubernetes_context.sh | 51 +++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100755 scripts/kubernetes_context.sh diff --git a/README.md b/README.md index f4b3c51..3c0b143 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul * When prefix is enabled smiley face turns from green to yellow * When charging, 'AC' is displayed * If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature +* Current kubernetes context ## Compatibility diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..2c571cc 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -24,6 +24,7 @@ main() show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) + show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") # Dracula Color Pallette @@ -168,6 +169,11 @@ main() script="#($current_dir/network_ping.sh)" fi + if [ $plugin = "kubernetes-context" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray") + script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)" + fi + if [ $plugin = "weather" ]; then # wait unit $datafile exists just to avoid errors # this should almost never need to wait unless something unexpected occurs diff --git a/scripts/kubernetes_context.sh b/scripts/kubernetes_context.sh new file mode 100755 index 0000000..ded1417 --- /dev/null +++ b/scripts/kubernetes_context.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +label=$1 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +current_context=$(kubectl config view --minify --output 'jsonpath={.current-context}'; echo) +current_user=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.user}'; echo) +current_cluster=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.cluster}'; echo) +current_namespace=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.namespace}'; echo) + +main() +{ + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + OUTPUT_STRING="" + if [ ! -z "$current_user" ] + then + OUTPUT_STRING="${current_user}@" + fi + + if [ ! -z "$current_cluster" ] + then + OUTPUT_STRING="${OUTPUT_STRING}${current_cluster}" + fi + + if [ ! -z "$current_namespace" ] + then + OUTPUT_STRING="${OUTPUT_STRING}:${current_namespace}" + fi + + if [ "$OUTPUT_STRING" = "" ] + then + OUTPUT_STRING="kubeconfig not valid" + fi + + if [ "$label" = "" ] + then + echo "${OUTPUT_STRING}" + else + echo "${label} ${OUTPUT_STRING}" + fi + + sleep $RATE +} + +# run the main driver +main From fb043e3ac2aadb412bdbff79324b6764b857e468 Mon Sep 17 00:00:00 2001 From: Janno Tjarks Date: Fri, 11 Feb 2022 17:38:01 +0100 Subject: [PATCH 02/46] Added the plugin spotify-tui --- README.md | 1 + scripts/dracula.sh | 5 +++++ scripts/spotify-tui.sh | 24 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100755 scripts/spotify-tui.sh diff --git a/README.md b/README.md index f4b3c51..952e038 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul * When prefix is enabled smiley face turns from green to yellow * When charging, 'AC' is displayed * If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature +* Spotify playback (needs the tool spotify-tui installed) ## Compatibility diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..df07e5d 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -168,6 +168,11 @@ main() script="#($current_dir/network_ping.sh)" fi + if [ $plugin = "spotify-tui" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray") + script="#($current_dir/spotify-tui.sh)" + fi + if [ $plugin = "weather" ]; then # wait unit $datafile exists just to avoid errors # this should almost never need to wait unless something unexpected occurs diff --git a/scripts/spotify-tui.sh b/scripts/spotify-tui.sh new file mode 100755 index 0000000..dc07206 --- /dev/null +++ b/scripts/spotify-tui.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +main() +{ + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + + if ! command -v spt &> /dev/null + then + exit 1 + fi + + spotify_playback=$(spt playback) + echo ${spotify_playback} + +} + +# run the main driver +main From 3e75296b73f483806291f4f1c5ff4bb09a8ad465 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Sat, 18 Jun 2022 05:35:23 -0400 Subject: [PATCH 03/46] Add attached-clients plugin --- scripts/attached_clients.sh | 35 +++++++++++++++++++++++++++++++++++ scripts/dracula.sh | 5 +++++ 2 files changed, 40 insertions(+) create mode 100755 scripts/attached_clients.sh diff --git a/scripts/attached_clients.sh b/scripts/attached_clients.sh new file mode 100755 index 0000000..ca7056d --- /dev/null +++ b/scripts/attached_clients.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +# configuration +# @dracula-clients-minimum 1 +# @dracula-clients-singular client +# @dracula-clients-plural clients + +current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source $current_dir/utils.sh + +count_clients() { + pane=$(tmux list-panes -F "#{session_name}" | head -n 1) + tmux list-clients -t $pane | wc -l | tr -d ' ' +} + +main() { + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + clients_count=$(count_clients) + clients_minimum=$(get_tmux_option "@dracula-clients-minimum" 1) + if (( $clients_count >= $clients_minimum )); then + if (( $clients_count > 1 )); then + clients_label=$(get_tmux_option "@dracula-clients-plural" "clients") + else + clients_label=$(get_tmux_option "@dracula-clients-singular" "client") + fi + echo "$clients_count $clients_label" + fi + sleep $RATE +} + +# run main driver +main diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..ebb33d6 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -168,6 +168,11 @@ main() script="#($current_dir/network_ping.sh)" fi + if [ $plugin = "attached-clients" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-attached-clients-colors" "cyan dark_gray") + script="#($current_dir/attached_clients.sh)" + fi + if [ $plugin = "weather" ]; then # wait unit $datafile exists just to avoid errors # this should almost never need to wait unless something unexpected occurs From 07813ac51a50c13db22b8139ae58b0e1cb73c72d Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Sat, 18 Jun 2022 06:28:11 -0400 Subject: [PATCH 04/46] Add documentation for attached_clients.sh --- INSTALL.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index f62a08d..5e8d2a8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, The order that you define the plugins will be the order on the status bar left to right. ```bash -# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, attached-clients, weather, time set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` @@ -215,3 +215,19 @@ Switch from default fahrenheit to celsius set -g @dracula-show-fahrenheit false ``` + +#### attached-clients options + +Set the minimum number of clients to show (otherwise, show nothing) + +```bash +set -g @dracula-clients-minimum 1 +``` + +Set the label when there is one client, or more than one client + +```bash +set -g @dracula-clients-singular client +set -g @dracula-clients-plural clients +``` + From 44018dede10404f1c3115f8aa8bacacced47c2d0 Mon Sep 17 00:00:00 2001 From: pataquets Date: Sun, 10 Jul 2022 19:51:32 +0200 Subject: [PATCH 05/46] Add 'custom' status plugin to get status texts from external scripts. --- README.md | 1 + scripts/dracula.sh | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 409e56e..1812ac5 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - CPU usage (percentage or load average) - RAM usage - GPU usage +- Custom status texts from external scripts - Color code based on if prefix is active or not - List of windows with current window highlighted - When prefix is enabled smiley face turns from green to yellow diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..1a33ba7 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -127,9 +127,21 @@ main() for plugin in "${plugins[@]}"; do + if case $plugin in custom:*) true;; *) false;; esac; then + script=${plugin#"custom:"} + if [[ -x "${current_dir}/${script}" ]]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-custom-plugin-colors" "cyan dark_gray") + script="#($current_dir/${script})" + else + colors[0]="red" + colors[1]="dark_gray" + script="${script} not found!" + fi + fi + if [ $plugin = "git" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray") - script="#($current_dir/git.sh)" + script="#($current_dir/git.sh)" fi if [ $plugin = "battery" ]; then From d9b6d00121255ba5d850341da075e7b54933b80c Mon Sep 17 00:00:00 2001 From: Yusuke Uchida Date: Sat, 18 Sep 2021 21:40:30 +0900 Subject: [PATCH 06/46] dracula.sh: add use_arbitrary_time_format and time_format options --- scripts/dracula.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..321a3f1 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -24,6 +24,8 @@ main() show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) + use_arbitrary_time_format=$(get_tmux_option "@arbitrary_time_format" false) + time_format=$(get_tmux_option "@time_format" "Y-%m-%d(%a) %H:%M:%S") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") # Dracula Color Pallette @@ -181,15 +183,20 @@ main() if [ $plugin = "time" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white") - if $show_day_month && $show_military ; then # military time and dd/mm - script="%a %d/%m %R ${timezone} " - elif $show_military; then # only military time - script="%a %m/%d %R ${timezone} " - elif $show_day_month; then # only dd/mm - script="%a %d/%m %I:%M %p ${timezone} " - else - script="%a %m/%d %I:%M %p ${timezone} " - fi + case $use_arbitrary_time_format in + false) + script=${time_format} + true) + if $show_day_month && $show_military ; then # military time and dd/mm + script="%a %d/%m %R ${timezone} " + elif $show_military; then # only military time + script="%a %m/%d %R ${timezone} " + elif $show_day_month; then # only dd/mm + script="%a %d/%m %I:%M %p ${timezone} " + else + script="%a %m/%d %I:%M %p ${timezone} " + fi + esac fi if $show_powerline; then From bca34814a43f902ca0d2147766e6b43dfb49bdd0 Mon Sep 17 00:00:00 2001 From: Yusuke Uchida Date: Sat, 18 Sep 2021 21:42:09 +0900 Subject: [PATCH 07/46] dracula.sh: add prefix dracula- --- scripts/dracula.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 321a3f1..61853b5 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -24,8 +24,8 @@ main() show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) - use_arbitrary_time_format=$(get_tmux_option "@arbitrary_time_format" false) - time_format=$(get_tmux_option "@time_format" "Y-%m-%d(%a) %H:%M:%S") + use_arbitrary_time_format=$(get_tmux_option "@dracula-arbitrary-time-format" false) + time_format=$(get_tmux_option "@dracula-time-format" "Y-%m-%d(%a) %H:%M:%S") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") # Dracula Color Pallette From 4b6bdaf9e26a26d1f95aa159c3220b569eae10d1 Mon Sep 17 00:00:00 2001 From: Yusuke Uchida Date: Sat, 18 Sep 2021 21:46:48 +0900 Subject: [PATCH 08/46] dracula.sh: fixed branch --- scripts/dracula.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 61853b5..8845e0c 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -183,10 +183,8 @@ main() if [ $plugin = "time" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white") - case $use_arbitrary_time_format in + case $use_arbitrary_time_format in false) - script=${time_format} - true) if $show_day_month && $show_military ; then # military time and dd/mm script="%a %d/%m %R ${timezone} " elif $show_military; then # only military time @@ -196,6 +194,8 @@ main() else script="%a %m/%d %I:%M %p ${timezone} " fi + true) + script=${time_format} esac fi From d4f3009800c500a3b6d7736b58e3c57958f7ad8b Mon Sep 17 00:00:00 2001 From: Yusuke Uchida Date: Sat, 18 Sep 2021 22:15:41 +0900 Subject: [PATCH 09/46] dracula.sh: changed default value of time_format --- scripts/dracula.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 8845e0c..799538d 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -25,7 +25,7 @@ main() show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) use_arbitrary_time_format=$(get_tmux_option "@dracula-arbitrary-time-format" false) - time_format=$(get_tmux_option "@dracula-time-format" "Y-%m-%d(%a) %H:%M:%S") + time_format=$(get_tmux_option "@dracula-time-format" "%Y-%m-%d(%a) %H:%M") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") # Dracula Color Pallette From c39cc30213d68d6e5cb12e0c0afae76741c0c693 Mon Sep 17 00:00:00 2001 From: Yusuke Uchida Date: Sat, 18 Sep 2021 22:15:54 +0900 Subject: [PATCH 10/46] dracula.sh: debug case statement --- scripts/dracula.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 799538d..5e858f2 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -193,9 +193,9 @@ main() script="%a %d/%m %I:%M %p ${timezone} " else script="%a %m/%d %I:%M %p ${timezone} " - fi + fi;; true) - script=${time_format} + script=${time_format};; esac fi From 597f7bed29310bb9546c83315337e1f89a05f7f4 Mon Sep 17 00:00:00 2001 From: Yusuke Uchida Date: Sat, 16 Oct 2021 00:57:10 +0900 Subject: [PATCH 11/46] dracula.sh: deleted use_arbitrary_time_format option --- scripts/dracula.sh | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 5e858f2..c93aa94 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -24,7 +24,6 @@ main() show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) - use_arbitrary_time_format=$(get_tmux_option "@dracula-arbitrary-time-format" false) time_format=$(get_tmux_option "@dracula-time-format" "%Y-%m-%d(%a) %H:%M") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") @@ -183,20 +182,19 @@ main() if [ $plugin = "time" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white") - case $use_arbitrary_time_format in - false) - if $show_day_month && $show_military ; then # military time and dd/mm - script="%a %d/%m %R ${timezone} " - elif $show_military; then # only military time - script="%a %m/%d %R ${timezone} " - elif $show_day_month; then # only dd/mm - script="%a %d/%m %I:%M %p ${timezone} " - else - script="%a %m/%d %I:%M %p ${timezone} " - fi;; - true) - script=${time_format};; - esac + if [ -n "$time_format" ]; then + script=${time_format} + else + if $show_day_month && $show_military ; then # military time and dd/mm + script="%a %d/%m %R ${timezone} " + elif $show_military; then # only military time + script="%a %m/%d %R ${timezone} " + elif $show_day_month; then # only dd/mm + script="%a %d/%m %I:%M %p ${timezone} " + else + script="%a %m/%d %I:%M %p ${timezone} " + fi + fi fi if $show_powerline; then From 0850532083a9683e5d7af78c3b7a195ca9f86c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Fri, 26 Aug 2022 10:55:12 +0200 Subject: [PATCH 12/46] feat: add network-vpn plugin (only macOS) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- INSTALL.md | 6 +++--- scripts/dracula.sh | 5 +++++ scripts/network_vpn.sh | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 scripts/network_vpn.sh diff --git a/INSTALL.md b/INSTALL.md index e1b6587..0cc70b1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, The order that you define the plugins will be the order on the status bar left to right. ```bash -# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, network-vpn, weather, time set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` @@ -190,13 +190,13 @@ set -g @dracula-git-disable-status true Set symbol to use for when branch is up to date with HEAD ```bash -# default is ✓. Avoid using non unicode characters that bash uses like $, * and ! +# default is ✓. Avoid using non unicode characters that bash uses like $, * and ! set -g @dracula-git-show-current-symbol ✓ ``` Set symbol to use for when branch diverges from HEAD ```bash -# default is unicode !. Avoid bash special characters +# default is unicode !. Avoid bash special characters set -g @dracula-git-show-diff-symbol ! ``` diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..8887f90 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -168,6 +168,11 @@ main() script="#($current_dir/network_ping.sh)" fi + if [ $plugin = "network-vpn" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-vpn-colors" "cyan dark_gray") + script="#($current_dir/network_vpn.sh)" + fi + if [ $plugin = "weather" ]; then # wait unit $datafile exists just to avoid errors # this should almost never need to wait unless something unexpected occurs diff --git a/scripts/network_vpn.sh b/scripts/network_vpn.sh new file mode 100755 index 0000000..468445e --- /dev/null +++ b/scripts/network_vpn.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source $current_dir/utils.sh + +vpn_function() { + case $(uname -s) in + Linux | Darwin) + vpn=$(scutil --nc list | grep Connected) + + if [ -z $vpn ]; then + echo "" + else + echo "VPN" + fi + ;; + + CYGWIN* | MINGW32* | MSYS* | MINGW*) + # TODO - windows compatability + ;; + esac +} + +main() { + + echo $(vpn_function) +} + +# run main driver +main From 731114654d4471606d7c5dfa16b473a1594300f8 Mon Sep 17 00:00:00 2001 From: tarantila <5209092+tarantila@users.noreply.github.com> Date: Wed, 31 Aug 2022 14:12:26 +0200 Subject: [PATCH 13/46] Display CPU label on CPU load configuration Change to display the defined value of "dracula-cpu-usage-label" (e.g. CPU) when load average is used instead percentage. Before this change the label was not displayed if CPU load average is used. --- scripts/cpu_info.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index 41b49c1..b73db09 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -44,10 +44,10 @@ main() { # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) cpu_load=$(get_tmux_option "@dracula-cpu-display-load" false) + cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU") if [ "$cpu_load" = true ]; then - echo "$(get_load)" + echo "$cpu_label $(get_load)" else - cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU") cpu_percent=$(get_percent) echo "$cpu_label $cpu_percent" fi From eedd33771fa4e6cac274f208a1e19a8e756f3b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Tue, 20 Sep 2022 14:29:45 +0200 Subject: [PATCH 14/46] git: add remote info support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this new option, we get information about which remote branch we're tracking. On top of this, we'll get information about ahead/behind commits when we diverged from remote. The output format will be in the form: 'local...remote +ahead -behind', where ahead and behind are the number of commits ahead and behind. This functionality is controlled by a new option called '@dracula-git-show-remote-status'. Note that for this to be properly displayed, we need to increase the size of the right status bar when the git plugin is enabled. In order to be easier to introduce the change, getMessage() was also a bit changed in order to be easier to append the remote info. Signed-off-by: Nuno Sá --- INSTALL.md | 6 ++++++ scripts/dracula.sh | 3 ++- scripts/git.sh | 37 ++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ebeae4e..32a6159 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -212,6 +212,12 @@ Hide untracked files from being displayed as local changes set -g @dracula-git-no-untracked-files true ``` +Show remote tracking branch together with diverge/sync state +```bash +# default is false +set -g @dracula-git-show-remote-status true +``` + #### weather options Switch from default fahrenheit to celsius diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..845d392 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -129,7 +129,8 @@ main() if [ $plugin = "git" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray") - script="#($current_dir/git.sh)" + tmux set-option -g status-right-length 250 + script="#($current_dir/git.sh)" fi if [ $plugin = "battery" ]; then diff --git a/scripts/git.sh b/scripts/git.sh index 235c44e..965d9ec 100755 --- a/scripts/git.sh +++ b/scripts/git.sh @@ -8,6 +8,7 @@ IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-git-show-curre IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-git-show-diff-symbol" "!") IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-git-no-repo-message" "") IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-git-no-untracked-files" "false") +IFS=' ' read -r -a show_remote_status <<< $(get_tmux_option "@dracula-git-show-remote-status" "false") # Get added, modified, updated and deleted files from git status getChanges() @@ -110,37 +111,59 @@ getBranch() fi } +getRemoteInfo() +{ + base=$(git -C $path for-each-ref --format='%(upstream:short) %(upstream:track)' "$(git -C $path symbolic-ref -q HEAD)") + remote=$(echo "$base" | cut -d" " -f1) + out="" + + if [ -n "$remote" ]; then + out="...$remote" + ahead=$(echo "$base" | grep -E -o 'ahead[ [:digit:]]+' | cut -d" " -f2) + behind=$(echo "$base" | grep -E -o 'behind[ [:digit:]]+' | cut -d" " -f2) + + [ -n "$ahead" ] && out+=" +$ahead" + [ -n "$behind" ] && out+=" -$behind" + fi + + echo "$out" +} + # return the final message for the status bar getMessage() { if [ $(checkForGitDir) == "true" ]; then branch="$(getBranch)" - + output="" + if [ $(checkForChanges) == "true" ]; then changes="$(getChanges)" if [ "${hide_status}" == "false" ]; then if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then - echo "${changes} $branch" + output=$(echo "${changes} $branch") else - echo "$diff_symbol ${changes} $branch" + output=$(echo "$diff_symbol ${changes} $branch") fi else if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then - echo "$branch" + output=$(echo "$branch") else - echo "$diff_symbol $branch" + output=$(echo "$diff_symbol $branch") fi fi else if [ $(checkEmptySymbol $current_symbol) == "true" ]; then - echo "$branch" + output=$(echo "$branch") else - echo "$current_symbol $branch" + output=$(echo "$current_symbol $branch") fi fi + + [ "$show_remote_status" == "true" ] && output+=$(getRemoteInfo) + echo "$output" else echo $no_repo_message fi From 143a0d888800d150593ba8c72a4e7b6c8a2c2885 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Fri, 28 Oct 2022 01:10:30 -0400 Subject: [PATCH 15/46] Add option to show/hide empty plugins --- scripts/dracula.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2b5e1f4..b8889a2 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -25,6 +25,7 @@ main() show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") + show_empty_plugins=$(get_tmux_option "@dracula-show-empty-plugins" true) # Dracula Color Pallette white='#f8f8f2' @@ -193,10 +194,18 @@ main() fi if $show_powerline; then - tmux set-option -ga status-right "#[fg=${!colors[0]},bg=${powerbg},nobold,nounderscore,noitalics]${right_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script " + if $show_empty_plugins; then + tmux set-option -ga status-right "#[fg=${!colors[0]},bg=${powerbg},nobold,nounderscore,noitalics]${right_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script " + else + tmux set-option -ga status-right "#{?#{==:$script,},,#[fg=${!colors[0]},nobold,nounderscore,noitalics]${right_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script }" + fi powerbg=${!colors[0]} else - tmux set-option -ga status-right "#[fg=${!colors[1]},bg=${!colors[0]}] $script " + if $show_empty_plugins; then + tmux set-option -ga status-right "#[fg=${!colors[1]},bg=${!colors[0]}] $script " + else + tmux set-option -ga status-right "#{?#{==:$script,},,#[fg=${!colors[1]},bg=${!colors[0]}] $script }" + fi fi done From e057d06c0d272cbf80397094554cfdfd2f94be3e Mon Sep 17 00:00:00 2001 From: Bryan Hoang Date: Mon, 7 Nov 2022 11:32:43 -0500 Subject: [PATCH 16/46] fix(dracula.sh): fix execution errors Resolves an issue cause by a syntax error and a removed executable bit introduced by dracula/tmux#153. The syntax/permissions issue stops the plugin from running properly when I ran into the issue earlier today. The missing executable bit is likely what's causing dracula/tmux#178 given that `man bash` has the following excerpt: > If a command is found but is not executable, the return status is 126. --- scripts/dracula.sh | 1 + 1 file changed, 1 insertion(+) mode change 100644 => 100755 scripts/dracula.sh diff --git a/scripts/dracula.sh b/scripts/dracula.sh old mode 100644 new mode 100755 index 5cd4124..49ddcef --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -172,6 +172,7 @@ main() if [ $plugin = "spotify-tui" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray") script="#($current_dir/spotify-tui.sh)" + fi if [ $plugin = "kubernetes-context" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray") From e2dd7c83f8ed095daede8c23b9de94349051db59 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Fri, 28 Oct 2022 01:42:26 -0400 Subject: [PATCH 17/46] Reject unrecognized plugins in config Prevents duplication of preceding recognized plugin for each unrecognized plugin --- scripts/dracula.sh | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 49ddcef..394bd84 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -131,55 +131,45 @@ main() if [ $plugin = "git" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray") script="#($current_dir/git.sh)" - fi - if [ $plugin = "battery" ]; then + elif [ $plugin = "battery" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-battery-colors" "pink dark_gray") script="#($current_dir/battery.sh)" - fi - if [ $plugin = "gpu-usage" ]; then + elif [ $plugin = "gpu-usage" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-usage-colors" "pink dark_gray") script="#($current_dir/gpu_usage.sh)" - fi - if [ $plugin = "cpu-usage" ]; then + elif [ $plugin = "cpu-usage" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cpu-usage-colors" "orange dark_gray") script="#($current_dir/cpu_info.sh)" - fi - if [ $plugin = "ram-usage" ]; then + elif [ $plugin = "ram-usage" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-ram-usage-colors" "cyan dark_gray") script="#($current_dir/ram_info.sh)" - fi - if [ $plugin = "network" ]; then + elif [ $plugin = "network" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-colors" "cyan dark_gray") script="#($current_dir/network.sh)" - fi - if [ $plugin = "network-bandwidth" ]; then + elif [ $plugin = "network-bandwidth" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-bandwidth-colors" "cyan dark_gray") tmux set-option -g status-right-length 250 script="#($current_dir/network_bandwidth.sh)" - fi - if [ $plugin = "network-ping" ]; then + elif [ $plugin = "network-ping" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray") script="#($current_dir/network_ping.sh)" - fi - if [ $plugin = "spotify-tui" ]; then + elif [ $plugin = "spotify-tui" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray") script="#($current_dir/spotify-tui.sh)" - fi - if [ $plugin = "kubernetes-context" ]; then + elif [ $plugin = "kubernetes-context" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray") script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)" - fi - if [ $plugin = "weather" ]; then + elif [ $plugin = "weather" ]; then # wait unit $datafile exists just to avoid errors # this should almost never need to wait unless something unexpected occurs while [ ! -f $datafile ]; do @@ -188,9 +178,8 @@ main() IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray") script="#(cat $datafile)" - fi - if [ $plugin = "time" ]; then + elif [ $plugin = "time" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white") if $show_day_month && $show_military ; then # military time and dd/mm script="%a %d/%m %R ${timezone} " @@ -201,6 +190,9 @@ main() else script="%a %m/%d %I:%M %p ${timezone} " fi + + else + continue fi if $show_powerline; then From ac95b3e0699548255411cb304f0885ebbca98229 Mon Sep 17 00:00:00 2001 From: Adrien Kara Date: Fri, 6 Jan 2023 00:42:01 +0100 Subject: [PATCH 18/46] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(network=5Fb?= =?UTF-8?q?andwidth):=20more=20flexibility=20and=20less=20spaghetti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use the internationally recommended unit symbol - Commentary for next contributor - Remove spaghetti code - More flexible for future evolution Signed-off-by: Adrien Kara --- scripts/network_bandwidth.sh | 100 +++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 41 deletions(-) diff --git a/scripts/network_bandwidth.sh b/scripts/network_bandwidth.sh index d9b5f70..4d9e782 100755 --- a/scripts/network_bandwidth.sh +++ b/scripts/network_bandwidth.sh @@ -1,51 +1,69 @@ #!/usr/bin/env bash -INTERVAL="1" # update interval in seconds +# INTERVAL is equal to 1s because we want to express the bandwidth in sec +readonly INTERVAL=1 + +# UPLOAD and DOWNLOAD index +readonly UPLOAD=0 +readonly DOWNLOAD=1 + +# SIZE index are the multiple of the unit byte and value the internationally recommended unit symbol in sec +readonly SIZE=( + [1]='B/s' + [1024]='kB/s' + [1048576]='MB/s' + [1073741824]='GB/s' +) network_name=$(tmux show-option -gqv "@dracula-network-bandwidth") +# interface_bytes give interface name and signal tx/rx return Bytes +interface_bytes() { + cat "/sys/class/net/$1/statistics/$2_bytes" +} + +# get_bandwidth return the number of bytes exchanged for tx and rx +get_bandwidth() { + upload="$(interface_bytes "$network_name" "tx")" + download="$(interface_bytes "$network_name" "rx")" + + #wait the interval for Wait for interval to calculate the difference + sleep "$INTERVAL" + + upload="$(bc <<<"$(interface_bytes "$network_name" "tx") - $upload")" + download="$(bc <<<"$(interface_bytes "$network_name" "rx") - $download")" + + #set to 0 by default useful for non-existent interface + echo "${upload:-0} ${download:-0}" +} + +# bandwidth_to_unit convert bytes into its highest unit and add unit symbol in sec +bandwidth_to_unit() { + local size=1 + for i in "${!SIZE[@]}"; do + if (($1 < i)); then + break + fi + + size="$i" + done + + local result="0.00" + if (($1 != 0)); then + result="$(bc <<<"scale=2; $1 / $size")" + fi + + echo "$result ${SIZE[$size]}" +} + main() { - while true - do - output_download="" - output_upload="" - output_download_unit="" - output_upload_unit="" + bandwidth=() - initial_download=$(cat /sys/class/net/$network_name/statistics/rx_bytes) - initial_upload=$(cat /sys/class/net/$network_name/statistics/tx_bytes) - - sleep $INTERVAL - - final_download=$(cat /sys/class/net/$network_name/statistics/rx_bytes) - final_upload=$(cat /sys/class/net/$network_name/statistics/tx_bytes) - - total_download_bps=$(expr $final_download - $initial_download) - total_upload_bps=$(expr $final_upload - $initial_upload) - - if [ $total_download_bps -gt 1073741824 ]; then - output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2 * $2)}') - output_download_unit="gB/s" - elif [ $total_download_bps -gt 1048576 ]; then - output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2)}') - output_download_unit="mB/s" - else - output_download=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/$2}') - output_download_unit="kB/s" - fi - - if [ $total_upload_bps -gt 1073741824 ]; then - output_upload=$(echo "$total_download_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2 * $2)}') - output_upload_unit="gB/s" - elif [ $total_upload_bps -gt 1048576 ]; then - output_upload=$(echo "$total_upload_bps 1024" | awk '{printf "%.2f \n", $1/($2 * $2)}') - output_upload_unit="mB/s" - else - output_upload=$(echo "$total_upload_bps 1024" | awk '{printf "%.2f \n", $1/$2}') - output_upload_unit="kB/s" - fi - - echo "↓ $output_download $output_download_unit • ↑ $output_upload $output_upload_unit" + while true; do + IFS=" " read -ra bandwidth <<<"$(get_bandwidth)" + echo "↓ $(bandwidth_to_unit "${bandwidth[$DOWNLOAD]}") • ↑ $(bandwidth_to_unit "${bandwidth[$UPLOAD]}")" done } + +#run main driver main From 4bb5e56053f5292493fd84207f1f3626feae42d4 Mon Sep 17 00:00:00 2001 From: Adrien Kara Date: Fri, 6 Jan 2023 19:46:04 +0100 Subject: [PATCH 19/46] =?UTF-8?q?=E2=9C=A8=20feat(network=5Fbandwidth):=20?= =?UTF-8?q?add=20more=20configuration=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Can auto detect used interface (only with linux ip for now) - Can show the name of used interface - A waiting interval can be set between each update Signed-off-by: Adrien Kara --- INSTALL.md | 12 ++++++++++ scripts/network_bandwidth.sh | 46 +++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ebeae4e..4143845 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -152,6 +152,18 @@ Customize label set -g @dracula-ram-usage-label "RAM" ``` +#### network-bandwidth + +You can configure which network interface you want to view the bandwidth, +Displaying of the interface name, The interval between each bandwidth update. +The most common interfaces name are `eth0` for a wired connection and `wlan0` for a wireless connection. + +```bash +set -g @dracula-network-bandwidth eth0 +set -g @dracula-network-bandwidth-interval 0 +set -g @dracula-network-bandwidth-show-interface true +``` + #### network-ping options You can configure which server (hostname, IP) you want to ping and at which rate (in seconds). Default is google.com at every 5 seconds. diff --git a/scripts/network_bandwidth.sh b/scripts/network_bandwidth.sh index 4d9e782..6427bdd 100755 --- a/scripts/network_bandwidth.sh +++ b/scripts/network_bandwidth.sh @@ -15,7 +15,22 @@ readonly SIZE=( [1073741824]='GB/s' ) -network_name=$(tmux show-option -gqv "@dracula-network-bandwidth") +# interface_get try to automaticaly get the used interface if network_name is empty +interface_get() { + name="$(tmux show-option -gqv "@dracula-network-bandwidth")" + + if [[ -z $name ]]; then + case "$(uname -s)" in + Linux) + if type ip >/dev/null; then + name="$(ip -o route get 192.168.0.0 | awk '{print $5}')" + fi + ;; + esac + fi + + echo "$name" +} # interface_bytes give interface name and signal tx/rx return Bytes interface_bytes() { @@ -24,14 +39,14 @@ interface_bytes() { # get_bandwidth return the number of bytes exchanged for tx and rx get_bandwidth() { - upload="$(interface_bytes "$network_name" "tx")" - download="$(interface_bytes "$network_name" "rx")" + upload="$(interface_bytes "$1" "tx")" + download="$(interface_bytes "$1" "rx")" #wait the interval for Wait for interval to calculate the difference sleep "$INTERVAL" - upload="$(bc <<<"$(interface_bytes "$network_name" "tx") - $upload")" - download="$(bc <<<"$(interface_bytes "$network_name" "rx") - $download")" + upload="$(bc <<<"$(interface_bytes "$1" "tx") - $upload")" + download="$(bc <<<"$(interface_bytes "$1" "rx") - $download")" #set to 0 by default useful for non-existent interface echo "${upload:-0} ${download:-0}" @@ -57,11 +72,30 @@ bandwidth_to_unit() { } main() { + counter=0 bandwidth=() + network_name="" + show_interface="$(tmux show-option -gqv "@dracula-network-bandwidth-show-interface")" + interval_update="$(tmux show-option -gqv "@dracula-network-bandwidth-interval")" + + if [[ -z $interval_update ]]; then + interval_update=0 + fi + while true; do - IFS=" " read -ra bandwidth <<<"$(get_bandwidth)" + if ((counter == 0)); then + counter=60 + network_name="$(interface_get)" + fi + + IFS=" " read -ra bandwidth <<<"$(get_bandwidth "$network_name")" + + if [[ $show_interface == "true" ]]; then echo -n "[$network_name] "; fi echo "↓ $(bandwidth_to_unit "${bandwidth[$DOWNLOAD]}") • ↑ $(bandwidth_to_unit "${bandwidth[$UPLOAD]}")" + + ((counter = counter - 1)) + sleep "$interval_update" done } From a960a12af1ebb6a2150ce05f2900454d22230398 Mon Sep 17 00:00:00 2001 From: Adrien Kara Date: Sat, 7 Jan 2023 16:55:14 +0100 Subject: [PATCH 20/46] =?UTF-8?q?=F0=9F=90=9B=20fix(#180):=20set=20network?= =?UTF-8?q?=5Fping=20as=20executable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Kara --- scripts/network_ping.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/network_ping.sh diff --git a/scripts/network_ping.sh b/scripts/network_ping.sh old mode 100644 new mode 100755 From beb6085ad78e4691879d0911897e71ffd3543d64 Mon Sep 17 00:00:00 2001 From: Adrien Kara Date: Sat, 7 Jan 2023 18:36:14 +0100 Subject: [PATCH 21/46] =?UTF-8?q?=F0=9F=90=9B=20fix(#165):=20is=20no=20lon?= =?UTF-8?q?ger=20based=20on=20word=20matching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Kara --- scripts/ram_info.sh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 97d61b6..ab983d5 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -9,20 +9,11 @@ get_percent() { case $(uname -s) in Linux) - total_mem_gb=$(free -g | awk '/^Mem/ {print $2}') - used_mem=$(free -g | awk '/^Mem/ {print $3}') - total_mem=$(free -h | awk '/^Mem/ {print $2}') - if (( $total_mem_gb == 0)); then - memory_usage=$(free -m | awk '/^Mem/ {print $3}') - total_mem_mb=$(free -m | awk '/^Mem/ {print $2}') - echo $memory_usage\M\B/$total_mem_mb\M\B - elif (( $used_mem == 0 )); then - memory_usage=$(free -m | awk '/^Mem/ {print $3}') - echo $memory_usage\M\B/$total_mem_gb\G\B - else - memory_usage=$(free -g | awk '/^Mem/ {print $3}') - echo $memory_usage\G\B/$total_mem_gb\G\B - fi + usage="$(free -h | awk 'NR==2 {print $3}')" + total="$(free -h | awk 'NR==2 {print $2}')" + formated="${usage}/${total}" + + echo "${formated//i/B}" ;; Darwin) From 1d3d07c3d251e6f70524934f7eab8273a58456f4 Mon Sep 17 00:00:00 2001 From: Adrien Kara Date: Sat, 7 Jan 2023 23:58:58 +0100 Subject: [PATCH 22/46] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(ram=5Finfo)?= =?UTF-8?q?:=20cleanup=20and=20follow=20bash=20recommendations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove the sleep rate, controled by show_refresh in dracula.sh Signed-off-by: Adrien Kara --- scripts/ram_info.sh | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index ab983d5..00af64a 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -5,7 +5,7 @@ export LC_ALL=en_US.UTF-8 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $current_dir/utils.sh -get_percent() +get_ratio() { case $(uname -s) in Linux) @@ -20,11 +20,11 @@ get_percent() # Get used memory blocks with vm_stat, multiply by page size to get size in bytes, then convert to MiB used_mem=$(vm_stat | grep ' active\|wired ' | sed 's/[^0-9]//g' | paste -sd ' ' - | awk -v pagesize=$(pagesize) '{printf "%d\n", ($1+$2) * pagesize / 1048576}') total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}') - if (( $used_mem < 1024 )); then - echo $used_mem\M\B/$total_mem + if ((used_mem < 1024 )); then + echo "${used_mem}MB/$total_mem" else - memory=$(($used_mem/1024)) - echo $memory\G\B/$total_mem + memory=$((used_mem/1024)) + echo "${memory}GB/$total_mem" fi ;; @@ -39,11 +39,11 @@ get_percent() total_mem=$(($(sysctl -n hw.physmem) / 1024 / 1024)) used_mem=$((total_mem - free_mem)) echo $used_mem - if (( $used_mem < 1024 )); then - echo $used_mem\M\B/$total_mem + if ((used_mem < 1024 )); then + echo "${used_mem}MB/$total_mem" else - memory=$(($used_mem/1024)) - echo $memory\G\B/$total_mem + memory=$((used_mem/1024)) + echo "${memory}GB/$total_mem" fi ;; @@ -55,12 +55,9 @@ get_percent() main() { - # storing the refresh rate in the variable RATE, default is 5 - RATE=$(get_tmux_option "@dracula-refresh-rate" 5) ram_label=$(get_tmux_option "@dracula-ram-usage-label" "RAM") - ram_percent=$(get_percent) - echo "$ram_label $ram_percent" - sleep $RATE + ram_ratio=$(get_ratio) + echo "$ram_label $ram_ratio" } #run main driver From 83a05e1a36835f77a2b0bee2dea040ad4659c567 Mon Sep 17 00:00:00 2001 From: Darko Grozdanovski Date: Wed, 22 Mar 2023 13:23:19 +0100 Subject: [PATCH 23/46] fix gpu reporting issue #195 --- scripts/gpu_usage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 9ffc647..552ed2b 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -27,7 +27,7 @@ get_gpu() { gpu=$(get_platform) if [[ "$gpu" == NVIDIA ]]; then - usage=$(nvidia-smi | grep '%' | awk '{ sum += $13 } END { printf("%d%%\n", sum / NR) }') + usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | awk '{ sum += $0 } END { printf("%d%%\n", sum / NR) }') else usage='unknown' fi From 09c57506561b8a4b6d18ce03de9ad8a7cf062854 Mon Sep 17 00:00:00 2001 From: jonathanforhan Date: Fri, 7 Apr 2023 20:40:53 -0400 Subject: [PATCH 24/46] Add cwd.sh to display the tmux pane's current working directory, updated README to reflect change --- README.md | 1 + scripts/cwd.sh | 30 ++++++++++++++++++++++++++++++ scripts/dracula.sh | 6 ++++++ 3 files changed, 37 insertions(+) create mode 100755 scripts/cwd.sh diff --git a/README.md b/README.md index a6536d0..fb80867 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature - Spotify playback (needs the tool spotify-tui installed) - Current kubernetes context +- Current working directory of tmux pane ## Compatibility diff --git a/scripts/cwd.sh b/scripts/cwd.sh new file mode 100755 index 0000000..cfae694 --- /dev/null +++ b/scripts/cwd.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# return current working directory of tmux pane +getPaneDir() +{ + nextone="false" + for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); + do + if [ "$nextone" == "true" ]; then + echo $i + return + fi + if [ "$i" == "1" ]; then + nextone="true" + fi + done +} + +main() +{ + path=$(getPaneDir) + + # change '/home/user' to '~' + cwd=$(echo $path | sed "s;$HOME;~;g") + + echo $cwd +} + +#run main driver program +main diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 3e1bc1b..1054563 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -128,6 +128,12 @@ main() for plugin in "${plugins[@]}"; do + if [ $plugin = "cwd" ]; then + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cwd-colors" "dark_gray white") + tmux set-option -g status-right-length 250 + script="#($current_dir/cwd.sh)" + fi + if [ $plugin = "git" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-git-colors" "green dark_gray") tmux set-option -g status-right-length 250 From c43100532fb84e5da868b81c7b9caec8c697db72 Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Sat, 8 Apr 2023 14:18:42 -0400 Subject: [PATCH 25/46] add gpu driver disclaimer --- INSTALL.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 2e34d7c..21e30d4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -138,6 +138,8 @@ set -g @dracula-battery-label "Battery" #### gpu-usage options +Note, currently only the Linux NVIDIA Proprietary drivers are supported. Nouveau and AMD Graphics Cards support are still under development. + Customize label ```bash @@ -248,4 +250,31 @@ Hide your location ```bash set -g @dracula-show-location false + +set -g @dracula-plugins "cpu-usage ram-usage network network-bandwidth time" +set -g @dracula-network-bandwidth enp5s0 +set -g @dracula-show-powerline true +set -g @dracula-show-flags false +set -g @dracula-refresh-rate 5 +set -g @dracula-show-left-icon session +set -g @dracula-border-contrast true +set -g @dracula-military-time true +set -g @dracula-show-location false +set -g @dracula-show-timezone false +set -g @dracula-show-weather false + + + +# set -g @dracula-border-contrast true +# set -g @dracula-cpu-usage true +# set -g @dracula-military-time true +# set -g @dracula-ram-usage true +# set -g @dracula-refresh-rate 5 +# set -g @dracula-show-battery true +# set -g @dracula-show-flags true +# set -g @dracula-show-left-icon session +# set -g @dracula-show-network false +# set -g @dracula-show-powerline false +# set -g @dracula-show-powerline true +# set -g @dracula-show-weather false ``` From 42deb775706d2efb12a122b04d86eb2033bc40d9 Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Sat, 8 Apr 2023 14:56:40 -0400 Subject: [PATCH 26/46] fix documentation errors --- INSTALL.md | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 51d943b..8264019 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -111,6 +111,12 @@ Enable high contrast pane border set -g @dracula-border-contrast true ``` +Hide empty plugins + +```bash +set -g @dracula-show-empty-plugins false +``` + #### cpu-usage options Customize label @@ -250,36 +256,8 @@ Hide your location ```bash set -g @dracula-show-location false - -set -g @dracula-plugins "cpu-usage ram-usage network network-bandwidth time" -set -g @dracula-network-bandwidth enp5s0 -set -g @dracula-show-powerline true -set -g @dracula-show-flags false -set -g @dracula-refresh-rate 5 -set -g @dracula-show-left-icon session -set -g @dracula-border-contrast true -set -g @dracula-military-time true -set -g @dracula-show-location false -set -g @dracula-show-timezone false -set -g @dracula-show-weather false - - - -# set -g @dracula-border-contrast true -# set -g @dracula-cpu-usage true -# set -g @dracula-military-time true -# set -g @dracula-ram-usage true -# set -g @dracula-refresh-rate 5 -# set -g @dracula-show-battery true -# set -g @dracula-show-flags true -# set -g @dracula-show-left-icon session -# set -g @dracula-show-network false -# set -g @dracula-show-powerline false -# set -g @dracula-show-powerline true -# set -g @dracula-show-weather false ``` - #### attached-clients options Set the minimum number of clients to show (otherwise, show nothing) From 8eacce7ee4d0bcdcc89d8f18c74a4b3cc032512f Mon Sep 17 00:00:00 2001 From: Ethan Edwards Date: Sat, 8 Apr 2023 15:12:22 -0400 Subject: [PATCH 27/46] add only Darwin support --- scripts/network_vpn.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/network_vpn.sh b/scripts/network_vpn.sh index 468445e..74b1eea 100755 --- a/scripts/network_vpn.sh +++ b/scripts/network_vpn.sh @@ -7,7 +7,11 @@ source $current_dir/utils.sh vpn_function() { case $(uname -s) in - Linux | Darwin) + Linux) + # TODO + ;; + + Darwin) vpn=$(scutil --nc list | grep Connected) if [ -z $vpn ]; then From 643d51c00cd0d45704aa8245a08b54caf21d3a95 Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Thu, 20 Apr 2023 14:59:54 +0300 Subject: [PATCH 28/46] fix weather script --- scripts/dracula.sh | 15 +----------- scripts/sleep_weather.sh | 48 -------------------------------------- scripts/weather_wrapper.sh | 31 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 62 deletions(-) delete mode 100755 scripts/sleep_weather.sh create mode 100755 scripts/weather_wrapper.sh diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 43f8b8f..deb7721 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -7,8 +7,6 @@ source $current_dir/utils.sh main() { - datafile=/tmp/.dracula-tmux-data - # set configuration option variables show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true) show_location=$(get_tmux_option "@dracula-show-location" true) @@ -67,11 +65,6 @@ main() left_sep="$show_left_sep" fi - # start weather script in background - if [[ "${plugins[@]}" =~ "weather" ]]; then - $current_dir/sleep_weather.sh $show_fahrenheit $show_location $fixed_location & - fi - # Set timezone unless hidden by configuration case $show_timezone in false) @@ -186,14 +179,8 @@ main() script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)" elif [ $plugin = "weather" ]; then - # wait unit $datafile exists just to avoid errors - # this should almost never need to wait unless something unexpected occurs - while [ ! -f $datafile ]; do - sleep 0.01 - done - IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray") - script="#(cat $datafile)" + script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location $fixed_location)" elif [ $plugin = "time" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white") diff --git a/scripts/sleep_weather.sh b/scripts/sleep_weather.sh deleted file mode 100755 index 869b3d8..0000000 --- a/scripts/sleep_weather.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env bash -# setting the locale, some users have issues with different locales, this forces the correct one -export LC_ALL=en_US.UTF-8 - -#wrapper script for running weather on interval - -fahrenheit=$1 -location=$2 -fixedlocation=$3 - -LOCKFILE=/tmp/.dracula-tmux-weather.lock -DATAFILE=/tmp/.dracula-tmux-data - -ensure_single_process() -{ - # check for another running instance of this script and terminate it if found - [ -f $LOCKFILE ] && ps -p "$(cat $LOCKFILE)" -o cmd= | grep -F " ${BASH_SOURCE[0]}" && kill "$(cat $LOCKFILE)" - echo $$ > $LOCKFILE -} - -main() -{ - ensure_single_process - - current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - - if [ ! -f $DATAFILE ]; then - printf "Loading..." > $DATAFILE - fi - - $current_dir/weather.sh > $DATAFILE - - while tmux has-session &> /dev/null - do - $current_dir/weather.sh $fahrenheit $location $fixedlocation > $DATAFILE - if tmux has-session &> /dev/null - then - sleep 1200 - else - break - fi - done - - rm $LOCKFILE -} - -#run main driver function -main diff --git a/scripts/weather_wrapper.sh b/scripts/weather_wrapper.sh new file mode 100755 index 0000000..75dc1f3 --- /dev/null +++ b/scripts/weather_wrapper.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +#wrapper script for running weather on interval + +fahrenheit=$1 +location=$2 +fixedlocation=$3 + +DATAFILE=/tmp/.dracula-tmux-data +LAST_EXEC_FILE="/tmp/.dracula-tmux-weather-last-exec" +RUN_EACH=1200 +TIME_NOW=$(date +%s) +TIME_LAST=$(cat "${LAST_EXEC_FILE}" 2>/dev/null || echo "0") + +main() +{ + current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + + if [ "$(expr ${TIME_LAST} + ${RUN_EACH})" -lt "${TIME_NOW}" ]; then + # Run weather script here + $current_dir/weather.sh $fahrenheit $location $fixedlocation > "${DATAFILE}" + echo "${TIME_NOW}" > "${LAST_EXEC_FILE}" + fi + + cat "${DATAFILE}" +} + +#run main driver function +main From 92a9a471c432ce1f495cbacbc459c8ae6ca85d28 Mon Sep 17 00:00:00 2001 From: Mykhailo Nikiforov Date: Sat, 22 Apr 2023 12:55:21 +0300 Subject: [PATCH 29/46] fix: default value for the time format should be empty --- scripts/dracula.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 43f8b8f..d344c42 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -24,7 +24,7 @@ main() show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false) show_day_month=$(get_tmux_option "@dracula-day-month" false) show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5) - time_format=$(get_tmux_option "@dracula-time-format" "%Y-%m-%d(%a) %H:%M") + time_format=$(get_tmux_option "@dracula-time-format" "") show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "") IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather") show_empty_plugins=$(get_tmux_option "@dracula-show-empty-plugins" true) From 49a1c3f6c37946a3bfd125e7db1b6143be4163cc Mon Sep 17 00:00:00 2001 From: Guido Kraemer Date: Wed, 26 Apr 2023 13:31:03 +0200 Subject: [PATCH 30/46] add gpu ram info plugin --- scripts/dracula.sh | 4 ++++ scripts/gpu_ram_info.sh | 48 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 scripts/gpu_ram_info.sh diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 08980e4..e841aa5 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -141,6 +141,10 @@ main() IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-usage-colors" "pink dark_gray") script="#($current_dir/gpu_usage.sh)" + elif [ $plugin = "gpu-ram-usage" ]; then + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-ram-usage-colors" "pink dark_gray") + script="#($current_dir/gpu_ram_info.sh)" + elif [ $plugin = "cpu-usage" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cpu-usage-colors" "orange dark_gray") script="#($current_dir/cpu_info.sh)" diff --git a/scripts/gpu_ram_info.sh b/scripts/gpu_ram_info.sh new file mode 100755 index 0000000..f04d895 --- /dev/null +++ b/scripts/gpu_ram_info.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +get_platform() +{ + case $(uname -s) in + Linux) + gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}') + echo $gpu + ;; + + Darwin) + # TODO - Darwin/Mac compatability + ;; + + CYGWIN*|MINGW32*|MSYS*|MINGW*) + # TODO - windows compatability + ;; + esac +} + +get_gpu() +{ + gpu=$(get_platform) + if [[ "$gpu" == NVIDIA ]]; then + usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk '{ used += $0; total +=$2 } END { printf("%dGB / %dGB\n", used / 1024, total / 1024) }') + else + usage='unknown' + fi + normalize_percent_len $usage +} + +main() +{ + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "GPU RAM") + gpu_usage=$(get_gpu) + echo "$gpu_label $gpu_usage" + sleep $RATE +} + +# run the main driver +main From a588a9d5179ff11b0b3a8e6eefde011884f2109b Mon Sep 17 00:00:00 2001 From: Guido Kraemer Date: Wed, 26 Apr 2023 13:44:09 +0200 Subject: [PATCH 31/46] fix gpu memory --- scripts/dracula.sh | 2 +- scripts/gpu_ram_info.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index e841aa5..b5b02d5 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -142,7 +142,7 @@ main() script="#($current_dir/gpu_usage.sh)" elif [ $plugin = "gpu-ram-usage" ]; then - IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-ram-usage-colors" "pink dark_gray") + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-ram-usage-colors" "cyan dark_gray") script="#($current_dir/gpu_ram_info.sh)" elif [ $plugin = "cpu-usage" ]; then diff --git a/scripts/gpu_ram_info.sh b/scripts/gpu_ram_info.sh index f04d895..07de6df 100755 --- a/scripts/gpu_ram_info.sh +++ b/scripts/gpu_ram_info.sh @@ -27,7 +27,7 @@ get_gpu() { gpu=$(get_platform) if [[ "$gpu" == NVIDIA ]]; then - usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk '{ used += $0; total +=$2 } END { printf("%dGB / %dGB\n", used / 1024, total / 1024) }') + usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk '{ used += $0; total +=$2 } END { printf("%dGB/%dGB\n", used / 1024, total / 1024) }') else usage='unknown' fi @@ -38,7 +38,7 @@ main() { # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) - gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "GPU RAM") + gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "VRAM") gpu_usage=$(get_gpu) echo "$gpu_label $gpu_usage" sleep $RATE From 0f345b2deddeb0d3efd193dc2bf2f013225de91a Mon Sep 17 00:00:00 2001 From: Guido Kraemer Date: Wed, 26 Apr 2023 16:16:55 +0200 Subject: [PATCH 32/46] add gpu power usage monitor --- scripts/dracula.sh | 4 ++++ scripts/gpu_power.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100755 scripts/gpu_power.sh diff --git a/scripts/dracula.sh b/scripts/dracula.sh index b5b02d5..7ded8a7 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -145,6 +145,10 @@ main() IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-ram-usage-colors" "cyan dark_gray") script="#($current_dir/gpu_ram_info.sh)" + elif [ $plugin = "gpu-power-draw" ]; then + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-power-draw-colors" "green dark_gray") + script="#($current_dir/gpu_power.sh)" + elif [ $plugin = "cpu-usage" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cpu-usage-colors" "orange dark_gray") script="#($current_dir/cpu_info.sh)" diff --git a/scripts/gpu_power.sh b/scripts/gpu_power.sh new file mode 100755 index 0000000..8ea5d13 --- /dev/null +++ b/scripts/gpu_power.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +get_platform() +{ + case $(uname -s) in + Linux) + gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}') + echo $gpu + ;; + + Darwin) + # TODO - Darwin/Mac compatability + ;; + + CYGWIN*|MINGW32*|MSYS*|MINGW*) + # TODO - windows compatability + ;; + esac +} + +get_gpu() +{ + gpu=$(get_platform) + if [[ "$gpu" == NVIDIA ]]; then + usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,no header,nounits | awk '{ draw += $0; max +=$2 } END { printf("%dW/%dW\n", draw, max) }') + + else + usage='unknown' + fi + normalize_percent_len $usage +} + +main() +{ + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "GPU") + gpu_usage=$(get_gpu) + echo "$gpu_label $gpu_usage" + sleep $RATE +} + +# run the main driver +main From d7fce8ee744538e723cbaf8b81ee9c993c356048 Mon Sep 17 00:00:00 2001 From: Guido Kraemer Date: Wed, 26 Apr 2023 16:21:38 +0200 Subject: [PATCH 33/46] fix gpu power monitor --- scripts/gpu_power.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gpu_power.sh b/scripts/gpu_power.sh index 8ea5d13..c97e6ee 100755 --- a/scripts/gpu_power.sh +++ b/scripts/gpu_power.sh @@ -27,7 +27,7 @@ get_gpu() { gpu=$(get_platform) if [[ "$gpu" == NVIDIA ]]; then - usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,no header,nounits | awk '{ draw += $0; max +=$2 } END { printf("%dW/%dW\n", draw, max) }') + usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,noheader,nounits | awk '{ draw += $0; max +=$2 } END { printf("%dW/%dW\n", draw, max) }') else usage='unknown' From d1e93ccc3a662ca08038ffcc7fe47d410dd6149b Mon Sep 17 00:00:00 2001 From: Guido Kraemer Date: Wed, 26 Apr 2023 16:52:25 +0200 Subject: [PATCH 34/46] add new features to README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fb80867..110a2b6 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - CPU usage (percentage or load average) - RAM usage - GPU usage +- GPU VRAM usage +- GPU power draw - Color code based on if prefix is active or not - List of windows with current window highlighted - When prefix is enabled smiley face turns from green to yellow From 8ee569dd6aa5db3837b3f491ea4d1cc2d7190e3d Mon Sep 17 00:00:00 2001 From: Jumscrafteur Date: Wed, 26 Apr 2023 17:08:06 +0200 Subject: [PATCH 35/46] Add dracula-spotify-tui-format --- scripts/spotify-tui.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/spotify-tui.sh b/scripts/spotify-tui.sh index dc07206..61352ef 100755 --- a/scripts/spotify-tui.sh +++ b/scripts/spotify-tui.sh @@ -15,7 +15,8 @@ main() exit 1 fi - spotify_playback=$(spt playback) + FORMAT=$(get_tmux_option "@dracula-spotify-tui-format" "%t - %a") + spotify_playback=$(spt playback -f "${FORMAT}") echo ${spotify_playback} } From 15ce3968c861ec5ce1a79d3581dd5f49eadd460b Mon Sep 17 00:00:00 2001 From: Jumscrafteur Date: Wed, 26 Apr 2023 17:21:32 +0200 Subject: [PATCH 36/46] Change default format to spt's default --- scripts/spotify-tui.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/spotify-tui.sh b/scripts/spotify-tui.sh index 61352ef..33ff32f 100755 --- a/scripts/spotify-tui.sh +++ b/scripts/spotify-tui.sh @@ -15,7 +15,7 @@ main() exit 1 fi - FORMAT=$(get_tmux_option "@dracula-spotify-tui-format" "%t - %a") + FORMAT=$(get_tmux_option "@dracula-spotify-tui-format" "%f %s %t - %a") spotify_playback=$(spt playback -f "${FORMAT}") echo ${spotify_playback} From eca1ca2827b83c67c514e991cf23fb72ee90033e Mon Sep 17 00:00:00 2001 From: Daniel Riedl <107212962+danriedl@users.noreply.github.com> Date: Thu, 4 May 2023 11:20:15 +0200 Subject: [PATCH 37/46] doc(Install): Add missing plugins. [#193] - spotify-tui - kubernetes-context --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index c2d1bb7..16fcbbd 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, The order that you define the plugins will be the order on the status bar left to right. ```bash -# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` From d4080e434ea2133b2156cba0035429b25f6b6f56 Mon Sep 17 00:00:00 2001 From: Dor Munis <5811812+dormunis@users.noreply.github.com> Date: Fri, 12 May 2023 19:02:51 +0300 Subject: [PATCH 38/46] Added terraform workspace support --- scripts/dracula.sh | 5 +++++ scripts/terraform.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100755 scripts/terraform.sh diff --git a/scripts/dracula.sh b/scripts/dracula.sh index a2bff10..af0b222 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -8,6 +8,7 @@ source $current_dir/utils.sh main() { # set configuration option variables + terraform_label=$(get_tmux_option "@dracula-terraform-label" "") show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true) show_location=$(get_tmux_option "@dracula-show-location" true) fixed_location=$(get_tmux_option "@dracula-fixed-location") @@ -197,6 +198,10 @@ main() IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray") script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)" + elif [ $plugin = "terraform" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray") + script="#($current_dir/terraform.sh $terraform_label)" + elif [ $plugin = "weather" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray") script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location $fixed_location)" diff --git a/scripts/terraform.sh b/scripts/terraform.sh new file mode 100755 index 0000000..72e144c --- /dev/null +++ b/scripts/terraform.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +label=$1 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +main() { + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + OUTPUT_STRING="N/A" + terraform_dir="$(tmux display-message -p '#{pane_current_path}')/.terraform" + if [ -d $terraform_dir ]; then + current_workspace=$(terraform workspace show 2>/dev/null) + OUTPUT_STRING="${current_workspace}" + fi + if [ "$label" = "" ] + then + echo "⚙️ ${OUTPUT_STRING}" + else + echo "⚙️ ${label} ${OUTPUT_STRING}" + fi + + sleep $RATE +} + +# run the main driver +main From 6fe855290f2d92ed91c165d2e6f925c12d21f901 Mon Sep 17 00:00:00 2001 From: jonathanforhan Date: Fri, 12 May 2023 13:35:49 -0400 Subject: [PATCH 39/46] fix bug with multi-word cwd --- scripts/cwd.sh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/scripts/cwd.sh b/scripts/cwd.sh index cfae694..5da448c 100755 --- a/scripts/cwd.sh +++ b/scripts/cwd.sh @@ -1,29 +1,24 @@ #!/usr/bin/env bash # return current working directory of tmux pane -getPaneDir() -{ +getPaneDir() { nextone="false" - for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); - do - if [ "$nextone" == "true" ]; then - echo $i - return - fi - if [ "$i" == "1" ]; then - nextone="true" - fi + ret="" + for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); do + [ "$i" == "1" ] && nextone="true" && continue + [ "$i" == "0" ] && nextone="false" + [ "$nextone" == "true" ] && ret+="$i " done + echo "${ret%?}" } -main() -{ +main() { path=$(getPaneDir) # change '/home/user' to '~' - cwd=$(echo $path | sed "s;$HOME;~;g") + cwd="${path/"$HOME"/'~'}" - echo $cwd + echo "$cwd" } #run main driver program From 311da18dc2a5f5b4260ec3e952bbd49c16b0f70c Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Thu, 10 Nov 2022 22:31:24 -0500 Subject: [PATCH 40/46] Add tmux-ram-usage plugin --- INSTALL.md | 10 ++++- scripts/dracula.sh | 4 ++ scripts/tmux_ram_info.sh | 84 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100755 scripts/tmux_ram_info.sh diff --git a/INSTALL.md b/INSTALL.md index 16fcbbd..b54049e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, The order that you define the plugins will be the order on the status bar left to right. ```bash -# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, tmux-ram-usage, network, network-bandwidth, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` @@ -161,6 +161,14 @@ Customize label set -g @dracula-ram-usage-label "RAM" ``` +#### tmux-ram-usage options + +Customize label + +```bash +set -g @dracula-tmux-ram-usage-label "MEM" +``` + #### network-bandwidth You can configure which network interface you want to view the bandwidth, diff --git a/scripts/dracula.sh b/scripts/dracula.sh index af0b222..a46f664 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -169,6 +169,10 @@ main() IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-ram-usage-colors" "cyan dark_gray") script="#($current_dir/ram_info.sh)" + elif [ $plugin = "tmux-ram-usage" ]; then + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-tmux-ram-usage-colors" "cyan dark_gray") + script="#($current_dir/tmux_ram_info.sh)" + elif [ $plugin = "network" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-colors" "cyan dark_gray") script="#($current_dir/network.sh)" diff --git a/scripts/tmux_ram_info.sh b/scripts/tmux_ram_info.sh new file mode 100755 index 0000000..8bdd2fe --- /dev/null +++ b/scripts/tmux_ram_info.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +# setting the locale, some users have issues with different locales, this forces the correct one +export LC_ALL=en_US.UTF-8 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +kb_to_mb() { + if [ $# == 0 ]; then + read num + else + num="$1" + fi + bc <<< "scale=3;$num/1024" +} + +kb_to_gb() { + if [ $# == 0 ]; then + read num + else + num="$1" + fi + bc <<< "scale=6;$num/1048576" +} + +round() { + if [ $# == 1 ]; then + read num + scale="$1" + elif [ $# == 2 ]; then + num="$1" + scale="$2" + fi + printf "%.${scale}f" "${num}" +} + +get_tmux_ram_usage() +{ + local pid="$(tmux display-message -pF '#{pid}')" + local total_mem_kb=0 + case $(uname -s) in + Linux) + local pids="$(pstree -p $pid | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')" + total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ | bc)" + ;; + + Darwin) + local pids="$(pstree $pid | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)" + ;; + + FreeBSD) + # TODO check FreeBSD compatibility + local pids="$(pstree $pid | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)" + ;; + + CYGWIN*|MINGW32*|MSYS*|MINGW*) + # TODO - windows compatability + ;; + esac + local total_mem_mb=$(echo "$total_mem_kb" | kb_to_mb | round 0) + local total_mem_gb=$(echo "$total_mem_kb" | kb_to_gb | round 0) + + if (( $total_mem_gb > 0)); then + echo "${total_mem_gb}GB" + elif (( $total_mem_mb > 0 )); then + echo "${total_mem_mb}MB" + else + echo "${total_mem_kb}kB" + fi +} + +main() +{ + # storing the refresh rate in the variable RATE, default is 5 + RATE=$(get_tmux_option "@dracula-refresh-rate" 5) + ram_label=$(get_tmux_option "@dracula-tmux-ram-usage-label" "MEM") + ram_usage=$(get_tmux_ram_usage) + echo "$ram_label $ram_usage" +} + +#run main driver +main From 487db8f50cc148e7ce7dab5f398e24856183553b Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Sat, 17 Jun 2023 17:17:43 -0400 Subject: [PATCH 41/46] Add tmux-ram-usage feature to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 630f72e..bbafc3a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - Battery percentage and AC power connection status - Refresh rate control - CPU usage (percentage or load average) -- RAM usage +- RAM usage (system and/or tmux server) - GPU usage - Custom status texts from external scripts - GPU VRAM usage From 83416ad3f890d8d9dcd77e1f1231fb10046f5dc4 Mon Sep 17 00:00:00 2001 From: Christopher Thompson Date: Tue, 4 Jul 2023 07:26:04 -0500 Subject: [PATCH 42/46] Add mercurial script --- INSTALL.md | 19 ++++++ scripts/dracula.sh | 5 ++ scripts/hg.sh | 163 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 187 insertions(+) create mode 100755 scripts/hg.sh diff --git a/INSTALL.md b/INSTALL.md index 16fcbbd..19b587a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -239,6 +239,25 @@ Show remote tracking branch together with diverge/sync state set -g @dracula-git-show-remote-status true ``` +#### mercurial options + +Hide details of hg changes +```bash +set -g @dracula-hg-disable-status true +``` + +Set symbol or message to use when the current pane has no hg repo +```bash +# default is unicode no message +set -g @dracula-hg-no-repo-message "" +``` + +Hide untracked files from being displayed as local changes +```bash +# default is false +set -g @dracula-hg-no-untracked-files true +``` + #### weather options Switch from default fahrenheit to celsius diff --git a/scripts/dracula.sh b/scripts/dracula.sh index af0b222..fc8ebfd 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -145,6 +145,11 @@ main() tmux set-option -g status-right-length 250 script="#($current_dir/git.sh)" + elif [ $plugin = "hg" ]; then + IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-hg-colors" "green dark_gray") + tmux set-option -g status-right-length 250 + script="#($current_dir/hg.sh)" + elif [ $plugin = "battery" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-battery-colors" "pink dark_gray") script="#($current_dir/battery.sh)" diff --git a/scripts/hg.sh b/scripts/hg.sh new file mode 100755 index 0000000..c787d1b --- /dev/null +++ b/scripts/hg.sh @@ -0,0 +1,163 @@ +#!/usr/bin/env bash + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +IFS=' ' read -r -a hide_status <<< $(get_tmux_option "@dracula-hg-disable-status" "false") +IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-hg-show-current-symbol" "✓") +IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-hg-show-diff-symbol" "!") +IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-hg-no-repo-message" "") +IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-hg-no-untracked-files" "false") + +# Get added, modified, and removed files from hg status +getChanges() +{ + declare -i added=0; + declare -i deleted=0; + declare -i modified=0; + declare -i removed=0; + declare -i untracked=0; + +for i in $(hg -R $path status -admru) + do + case $i in + 'A') + added+=1 + ;; + 'D') + deleted+=1 + ;; + 'M') + modified+=1 + ;; + 'R') + removed+=1 + ;; + '?') + untracked+=1 + ;; + + esac + done + + output="" + [ $added -gt 0 ] && output+="${added}A" + [ $modified -gt 0 ] && output+=" ${modified}M" + [ $deleted -gt 0 ] && output+=" ${deleted}D" + [ $removed -gt 0 ] && output+=" ${removed}R" + [ $no_untracked_files == "false" -a $untracked -gt 0 ] && output+=" ${untracked}?" + + echo $output +} + + +# getting the #{pane_current_path} from dracula.sh is no longer possible +getPaneDir() +{ + nextone="false" + for i in $(tmux list-panes -F "#{pane_active} #{pane_current_path}"); + do + if [ "$nextone" == "true" ]; then + echo $i + return + fi + if [ "$i" == "1" ]; then + nextone="true" + fi + done +} + + +# check if the current or diff symbol is empty to remove ugly padding +checkEmptySymbol() +{ + symbol=$1 + if [ "$symbol" == "" ]; then + echo "true" + else + echo "false" + fi +} + +# check to see if the current repo is not up to date with HEAD +checkForChanges() +{ + [ $no_untracked_files == "false" ] && no_untracked="-u" || no_untracked="" + if [ "$(checkForHgDir)" == "true" ]; then + if [ "$(hg -R $path status -admr $no_untracked)" != "" ]; then + echo "true" + else + echo "false" + fi + else + echo "false" + fi +} + +# check if a hg repo exists in the directory +checkForHgDir() +{ + if [ "$(hg -R $path branch)" != "" ]; then + echo "true" + else + echo "false" + fi +} + +# return branch name if there is one +getBranch() +{ + if [ $(checkForHgDir) == "true" ]; then + echo $(hg -R $path branch) + else + echo $no_repo_message + fi +} + +# return the final message for the status bar +getMessage() +{ + if [ $(checkForHgDir) == "true" ]; then + branch="$(getBranch)" + output="" + + if [ $(checkForChanges) == "true" ]; then + + changes="$(getChanges)" + + if [ "${hide_status}" == "false" ]; then + if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then + output=$(echo "${changes} $branch") + else + output=$(echo "$diff_symbol ${changes} $branch") + fi + else + if [ $(checkEmptySymbol $diff_symbol) == "true" ]; then + output=$(echo "$branch") + else + output=$(echo "$diff_symbol $branch") + fi + fi + + else + if [ $(checkEmptySymbol $current_symbol) == "true" ]; then + output=$(echo "$branch") + else + output=$(echo "$current_symbol $branch") + fi + fi + + echo "$output" + else + echo $no_repo_message + fi +} + +main() +{ + path=$(getPaneDir) + getMessage +} + +#run main driver program +main From 601696fd7fed6064897d55ddfbbefca5949befbc Mon Sep 17 00:00:00 2001 From: Christopher Thompson Date: Tue, 4 Jul 2023 07:35:30 -0500 Subject: [PATCH 43/46] Fix symbol for deleted files --- scripts/hg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/hg.sh b/scripts/hg.sh index c787d1b..966e110 100755 --- a/scripts/hg.sh +++ b/scripts/hg.sh @@ -24,7 +24,7 @@ for i in $(hg -R $path status -admru) 'A') added+=1 ;; - 'D') + '!') deleted+=1 ;; 'M') From a6aaf65856e85b02c711177f2ec4b68d51cc249d Mon Sep 17 00:00:00 2001 From: Christopher Thompson Date: Sat, 8 Jul 2023 19:04:42 -0500 Subject: [PATCH 44/46] Add missing flags to INSTALL.md --- INSTALL.md | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 19b587a..f8c7d55 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -239,23 +239,35 @@ Show remote tracking branch together with diverge/sync state set -g @dracula-git-show-remote-status true ``` -#### mercurial options +#### hg options Hide details of hg changes ```bash set -g @dracula-hg-disable-status true ``` +Set symbol to use for when branch is up to date with HEAD +```bash +#default is ✓.Avoid using non unicode characters that bash uses like $, * and ! +set -g @dracula-hg-show-current-symbol ✓ +``` + +Set symbol to use for when branch diverges from HEAD +```bash +#default is unicode !.Avoid bash special characters +set -g @dracula-hg-show-diff-symbol ! +``` + Set symbol or message to use when the current pane has no hg repo ```bash -# default is unicode no message +#default is unicode no message set -g @dracula-hg-no-repo-message "" ``` Hide untracked files from being displayed as local changes ```bash -# default is false -set -g @dracula-hg-no-untracked-files true +#default is false +set -g @dracula-hg-no-untracked-files false ``` #### weather options @@ -292,3 +304,4 @@ Set the label when there is one client, or more than one client set -g @dracula-clients-singular client set -g @dracula-clients-plural clients ``` + From b6fe033952bf10c199118370d83185f0afbf373f Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Sat, 8 Jul 2023 20:51:11 -0400 Subject: [PATCH 45/46] Add fallback for tmux-ram-usage without pstree --- scripts/tmux_ram_info.sh | 44 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/scripts/tmux_ram_info.sh b/scripts/tmux_ram_info.sh index 8bdd2fe..b349d2e 100755 --- a/scripts/tmux_ram_info.sh +++ b/scripts/tmux_ram_info.sh @@ -5,6 +5,28 @@ export LC_ALL=en_US.UTF-8 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $current_dir/utils.sh +get_cpids_linux() { + local ppid="$1" + local cpids + cpids="$(pgrep -P "$ppid")" + local cpid + echo "$ppid" + for cpid in $cpids; do + get_cpids_linux "$cpid" + done +} + +get_cpids_unix() { + local ppid="$1" + local cpids + cpids="$(pgrep -aP "$ppid")" + local cpid + echo "$ppid" + for cpid in $cpids; do + get_cpids_unix "$cpid" + done +} + kb_to_mb() { if [ $# == 0 ]; then read num @@ -36,22 +58,36 @@ round() { get_tmux_ram_usage() { - local pid="$(tmux display-message -pF '#{pid}')" + local pid + pid="$(tmux display-message -pF '#{pid}')" + local pids local total_mem_kb=0 case $(uname -s) in Linux) - local pids="$(pstree -p $pid | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')" + if command -v pstree > /dev/null; then + pids="$(pstree -p "$pid" | tr -d '\n' | sed -rn -e 's/[^()]*\(([0-9]+)\)[^()]*/\1,/g' -e 's/,$//p')" + else + pids="$(get_cpids_linux "$pid" | tr '\n' ',')" + fi total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ | bc)" ;; Darwin) - local pids="$(pstree $pid | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + if command -v pstree > /dev/null; then + pids="$(pstree "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + else + pids="$(get_cpids_unix "$pid" | tr '\n' ',')" + fi total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)" ;; FreeBSD) # TODO check FreeBSD compatibility - local pids="$(pstree $pid | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + if command -v pstree > /dev/null; then + pids="$(pstree "$pid" | sed -En 's/[^0-9]+([0-9]+) .*/\1/p' | tr '\n' ',')" + else + pids="$(get_cpids_unix "$pid" | tr '\n' ',')" + fi total_mem_kb="$(ps -o rss= -p "$pids" | paste -sd+ - | bc)" ;; From 640eb4c809c5db54129a68fac72f61a3b89a3c47 Mon Sep 17 00:00:00 2001 From: Aaron Kollasch Date: Sun, 9 Jul 2023 00:51:44 -0400 Subject: [PATCH 46/46] Fix shellcheck warnings --- scripts/tmux_ram_info.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/tmux_ram_info.sh b/scripts/tmux_ram_info.sh index b349d2e..63d4cf0 100755 --- a/scripts/tmux_ram_info.sh +++ b/scripts/tmux_ram_info.sh @@ -3,14 +3,14 @@ export LC_ALL=en_US.UTF-8 current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $current_dir/utils.sh +source "$current_dir/utils.sh" get_cpids_linux() { local ppid="$1" local cpids - cpids="$(pgrep -P "$ppid")" local cpid echo "$ppid" + cpids="$(pgrep -P "$ppid")" for cpid in $cpids; do get_cpids_linux "$cpid" done @@ -19,9 +19,9 @@ get_cpids_linux() { get_cpids_unix() { local ppid="$1" local cpids - cpids="$(pgrep -aP "$ppid")" local cpid echo "$ppid" + cpids="$(pgrep -aP "$ppid")" for cpid in $cpids; do get_cpids_unix "$cpid" done @@ -29,7 +29,7 @@ get_cpids_unix() { kb_to_mb() { if [ $# == 0 ]; then - read num + read -r num else num="$1" fi @@ -38,7 +38,7 @@ kb_to_mb() { kb_to_gb() { if [ $# == 0 ]; then - read num + read -r num else num="$1" fi @@ -47,7 +47,7 @@ kb_to_gb() { round() { if [ $# == 1 ]; then - read num + read -r num scale="$1" elif [ $# == 2 ]; then num="$1" @@ -59,9 +59,11 @@ round() { get_tmux_ram_usage() { local pid - pid="$(tmux display-message -pF '#{pid}')" local pids local total_mem_kb=0 + local total_mem_mb=0 + local total_mem_gb=0 + pid="$(tmux display-message -pF '#{pid}')" case $(uname -s) in Linux) if command -v pstree > /dev/null; then @@ -95,12 +97,12 @@ get_tmux_ram_usage() # TODO - windows compatability ;; esac - local total_mem_mb=$(echo "$total_mem_kb" | kb_to_mb | round 0) - local total_mem_gb=$(echo "$total_mem_kb" | kb_to_gb | round 0) + total_mem_mb=$(kb_to_mb "$total_mem_kb" | round 0) + total_mem_gb=$(kb_to_gb "$total_mem_kb" | round 0) - if (( $total_mem_gb > 0)); then + if (( total_mem_gb > 0)); then echo "${total_mem_gb}GB" - elif (( $total_mem_mb > 0 )); then + elif (( total_mem_mb > 0 )); then echo "${total_mem_mb}MB" else echo "${total_mem_kb}kB" @@ -109,8 +111,6 @@ get_tmux_ram_usage() main() { - # storing the refresh rate in the variable RATE, default is 5 - RATE=$(get_tmux_option "@dracula-refresh-rate" 5) ram_label=$(get_tmux_option "@dracula-tmux-ram-usage-label" "MEM") ram_usage=$(get_tmux_ram_usage) echo "$ram_label $ram_usage"