From 16aa5f080cc515d6ec6c33150f2899d93164a305 Mon Sep 17 00:00:00 2001 From: xiao0yy Date: Wed, 13 Oct 2021 16:56:34 +0800 Subject: [PATCH 01/17] Support for top version procps-ng --- scripts/cpu_info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index 04d3037..b96e69e 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -9,7 +9,7 @@ get_percent() { case $(uname -s) in Linux) - percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') + percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -p 1 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') normalize_percent_len $percent ;; From 7592fdd0fd573406b350b36c6ee79ce327eaf99e Mon Sep 17 00:00:00 2001 From: xiao0yy Date: Fri, 15 Oct 2021 16:56:54 +0800 Subject: [PATCH 02/17] Reduce the execution time of top command --- scripts/cpu_info.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index b96e69e..0cd396b 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -9,7 +9,7 @@ get_percent() { case $(uname -s) in Linux) - percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -p 1 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') + percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -d 0.01 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') normalize_percent_len $percent ;; From 9b2cadc8e1e0873757cf8119a1c6b388f752ccb5 Mon Sep 17 00:00:00 2001 From: Andrew Lechowicz Date: Sat, 16 Oct 2021 20:29:28 -0400 Subject: [PATCH 03/17] Add battery icon option --- scripts/battery.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index 24012fa..c9d96d7 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -108,15 +108,16 @@ battery_status() main() { + bat_label=$(get_tmux_option "@dracula-battery-label" "♥") bat_stat=$(battery_status) bat_perc=$(battery_percent) if [ -z "$bat_stat" ]; then # Test if status is empty or not - echo "♥ $bat_perc" + echo "$bat_label $bat_perc" elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power - echo "♥ $bat_stat" + echo "$bat_label $bat_stat" else - echo "♥ $bat_stat $bat_perc" + echo "$bat_label $bat_stat $bat_perc" fi } From b06419366c9b24d2e1a3f9d89e2c6b110538ba4d Mon Sep 17 00:00:00 2001 From: adrianmihalko Date: Fri, 3 Dec 2021 18:49:34 +0100 Subject: [PATCH 04/17] Enable custom location for weather plugin --- scripts/dracula.sh | 3 ++- scripts/sleep_weather.sh | 3 ++- scripts/weather.sh | 7 +++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index f530187..5637bf6 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -12,6 +12,7 @@ main() # set configuration option variables 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") show_powerline=$(get_tmux_option "@dracula-show-powerline" false) show_flags=$(get_tmux_option "@dracula-show-flags" false) show_left_icon=$(get_tmux_option "@dracula-show-left-icon" smiley) @@ -65,7 +66,7 @@ main() # start weather script in background if [[ "${plugins[@]}" =~ "weather" ]]; then - $current_dir/sleep_weather.sh $show_fahrenheit $show_location & + $current_dir/sleep_weather.sh $show_fahrenheit $show_location $fixed_location & fi # Set timezone unless hidden by configuration diff --git a/scripts/sleep_weather.sh b/scripts/sleep_weather.sh index 276c25c..869b3d8 100755 --- a/scripts/sleep_weather.sh +++ b/scripts/sleep_weather.sh @@ -6,6 +6,7 @@ export LC_ALL=en_US.UTF-8 fahrenheit=$1 location=$2 +fixedlocation=$3 LOCKFILE=/tmp/.dracula-tmux-weather.lock DATAFILE=/tmp/.dracula-tmux-data @@ -31,7 +32,7 @@ main() while tmux has-session &> /dev/null do - $current_dir/weather.sh $fahrenheit $location > $DATAFILE + $current_dir/weather.sh $fahrenheit $location $fixedlocation > $DATAFILE if tmux has-session &> /dev/null then sleep 1200 diff --git a/scripts/weather.sh b/scripts/weather.sh index 2254a69..6debde5 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -4,10 +4,13 @@ export LC_ALL=en_US.UTF-8 fahrenheit=$1 location=$2 +fixedlocation=$3 display_location() { - if $location; then + if $location && [[ ! -z "$fixedlocation" ]]; then + echo " $fixedlocation" + elif $location; then city=$(curl -s https://ipinfo.io/city 2> /dev/null) region=$(curl -s https://ipinfo.io/region 2> /dev/null) echo " $city, $region" @@ -20,7 +23,7 @@ fetch_weather_information() { display_weather=$1 # it gets the weather condition textual name (%C), and the temperature (%t) - curl -sL wttr.in\?format="%C+%t$display_weather" + curl -sL wttr.in/$fixedlocation\?format="%C+%t$display_weather" } #get weather display From 2dbd75cadfc68ff656bf42d3c91304a64be37d61 Mon Sep 17 00:00:00 2001 From: adrianmihalko Date: Wed, 22 Dec 2021 23:11:09 +0100 Subject: [PATCH 05/17] Add load average support --- INSTALL.md | 6 ++++++ README.md | 2 +- scripts/cpu_info.sh | 27 ++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f6e915e..c216db3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -119,6 +119,12 @@ Customize label set -g @dracula-cpu-usage-label "CPU" ``` +Show load average instead of percentage + +```bash +set -g @dracula-cpu-display-load true +``` + #### gpu-usage options Customize label diff --git a/README.md b/README.md index eef0aaa..f4b3c51 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul * Git branch and status * Battery percentage and AC power connection status * Refresh rate control -* CPU usage +* CPU usage (percentage or load average) * RAM usage * GPU usage * Color code based on if prefix is active or not diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index 0cd396b..41b49c1 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -27,13 +27,30 @@ get_percent() esac } -main() -{ +get_load() { + case $(uname -s) in + Linux | Darwin) + loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g') + echo $loadavg + ;; + + CYGWIN* | MINGW32* | MSYS* | MINGW*) + # TODO - windows compatability + ;; + esac +} + +main() { # storing the refresh rate in the variable RATE, default is 5 RATE=$(get_tmux_option "@dracula-refresh-rate" 5) - cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU") - cpu_percent=$(get_percent) - echo "$cpu_label $cpu_percent" + cpu_load=$(get_tmux_option "@dracula-cpu-display-load" false) + if [ "$cpu_load" = true ]; then + echo "$(get_load)" + else + cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU") + cpu_percent=$(get_percent) + echo "$cpu_label $cpu_percent" + fi sleep $RATE } From 55352703972d3e74050b95c4a340cb3a1631469c Mon Sep 17 00:00:00 2001 From: adrianmihalko Date: Wed, 22 Dec 2021 23:32:41 +0100 Subject: [PATCH 06/17] Update docs Add detailed explanation --- INSTALL.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index c216db3..93615ea 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -119,12 +119,15 @@ Customize label set -g @dracula-cpu-usage-label "CPU" ``` -Show load average instead of percentage +Show system load average instead of CPU usage percentage (default) ```bash set -g @dracula-cpu-display-load true ``` +CPU usage percentage (default) - in percentage (output: %) +Load average – is the average system load calculated over a given period of time of 1, 5 and 15 minutes (output: x.x x.x x.x) + #### gpu-usage options Customize label From 41d32c0af3c91bf95e072e141b73aa44c07effe5 Mon Sep 17 00:00:00 2001 From: adrianmihalko Date: Thu, 23 Dec 2021 00:50:24 +0100 Subject: [PATCH 07/17] Ping plugin --- INSTALL.md | 11 ++++++++++- scripts/dracula.sh | 6 ++++++ scripts/network_ping.sh | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 scripts/network_ping.sh diff --git a/INSTALL.md b/INSTALL.md index 93615ea..e9d092b 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, weather, time +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ``` @@ -144,6 +144,15 @@ Customize label set -g @dracula-ram-usage-label "RAM" ``` +#### 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. + +```bash +set -g @dracula-ping-server "google.com" +set -g @dracula-ping-rate 5 +``` + #### time options Disable timezone diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 5637bf6..fb70c92 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -163,6 +163,12 @@ main() script="#($current_dir/network_bandwidth.sh)" fi + if [ $plugin = "network-ping" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray") + #tmux set-option -g status-right-length 250 + script="#($current_dir/network_ping.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_ping.sh b/scripts/network_ping.sh new file mode 100644 index 0000000..2cc17bf --- /dev/null +++ b/scripts/network_ping.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-ping-server "example.com" +# @dracula-ping-rate 5 + +current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source $current_dir/utils.sh + +ping_function() { + case $(uname -s) in + Linux | Darwin) + # storing the hostname/IP in the variable PINGSERVER, default is google.com + pingserver=$(get_tmux_option "@dracula-ping-server" "google.com") + pingtime=$(ping -c 1 "$pingserver" | tail -1 | awk '{print $4}' | cut -d '/' -f 2) + echo $pingtime + ;; + + CYGWIN* | MINGW32* | MSYS* | MINGW*) + # TODO - windows compatability + ;; + esac +} + +main() { + + echo $(ping_function) + RATE=$(get_tmux_option "@dracula-ping-rate" 5) + sleep $RATE +} + +# run main driver +main From 45ad8cdafdc53dbe0342123266f45a9f5e3123dc Mon Sep 17 00:00:00 2001 From: adrianmihalko Date: Thu, 23 Dec 2021 00:51:47 +0100 Subject: [PATCH 08/17] Update dracula.sh --- scripts/dracula.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index fb70c92..2b5e1f4 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -165,7 +165,6 @@ main() if [ $plugin = "network-ping" ]; then IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray") - #tmux set-option -g status-right-length 250 script="#($current_dir/network_ping.sh)" fi From a0987b8b963c9a3a213057f656d1a341b7fc6520 Mon Sep 17 00:00:00 2001 From: adrianmihalko Date: Thu, 23 Dec 2021 00:55:35 +0100 Subject: [PATCH 09/17] Update network_ping.sh --- scripts/network_ping.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/network_ping.sh b/scripts/network_ping.sh index 2cc17bf..442f6be 100644 --- a/scripts/network_ping.sh +++ b/scripts/network_ping.sh @@ -15,7 +15,7 @@ ping_function() { # storing the hostname/IP in the variable PINGSERVER, default is google.com pingserver=$(get_tmux_option "@dracula-ping-server" "google.com") pingtime=$(ping -c 1 "$pingserver" | tail -1 | awk '{print $4}' | cut -d '/' -f 2) - echo $pingtime + echo "$pingtime ms" ;; CYGWIN* | MINGW32* | MSYS* | MINGW*) From bb92bb5e645c05bdc4296cda1367bd5270751c97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20de=20Fran=C3=A7a?= Date: Sun, 20 Mar 2022 22:37:01 -0300 Subject: [PATCH 10/17] :memo: Update readme --- README.md | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f4b3c51..409e56e 100644 --- a/README.md +++ b/README.md @@ -14,21 +14,21 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul ## Features -* Support for powerline -* Day, date, time, timezone -* Current location based on network with temperature and forecast icon (if available) -* Network connection status, bandwidth and SSID -* Git branch and status -* Battery percentage and AC power connection status -* Refresh rate control -* CPU usage (percentage or load average) -* RAM usage -* GPU usage -* 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 -* When charging, 'AC' is displayed -* If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature +- Support for powerline +- Day, date, time, timezone +- Current location based on network with temperature and forecast icon (if available) +- Network connection status, bandwidth and SSID +- Git branch and status +- Battery percentage and AC power connection status +- Refresh rate control +- CPU usage (percentage or load average) +- RAM usage +- GPU usage +- 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 +- When charging, 'AC' is displayed +- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature ## Compatibility @@ -39,9 +39,15 @@ FreeBSD compatibility is in development This theme is maintained by the following person(s) and a bunch of [awesome contributors](https://github.com/dracula/tmux/graphs/contributors). -[![Dane Williams](https://avatars2.githubusercontent.com/u/22798229?s=70&v=4",)](https://github.com/danerwilliams) | [![Ethan Edwards](https://avatars1.githubusercontent.com/u/60861925?s=70&v=4)](https://github.com/ethancedwards8) | ---- | --- | -[Dane Williams](https://github.com/danerwilliams) | [Ethan Edwards](https://github.com/ethancedwards8) | +| [![Dane Williams](https://avatars2.githubusercontent.com/u/22798229?s=70&v=4",)](https://github.com/danerwilliams) | [![Ethan Edwards](https://avatars1.githubusercontent.com/u/60861925?s=70&v=4)](https://github.com/ethancedwards8) | +| ------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | +| [Dane Williams](https://github.com/danerwilliams) | [Ethan Edwards](https://github.com/ethancedwards8) | + +## Community + +- [Twitter](https://twitter.com/draculatheme) - Best for getting updates about themes and new stuff. +- [GitHub](https://github.com/dracula/dracula-theme/discussions) - Best for asking questions and discussing issues. +- [Discord](https://draculatheme.com/discord-invite) - Best for hanging out with the community. ## License From 77069707413597ca8aad1bb1ce10cab47646f284 Mon Sep 17 00:00:00 2001 From: Rojo Date: Sun, 27 Mar 2022 23:28:41 +0200 Subject: [PATCH 11/17] Update docs to include weather options --- INSTALL.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e9d092b..92cc66f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -201,9 +201,20 @@ set -g @dracula-git-no-repo-message "" #### weather options -Switch from default fahrenheit to celsius +Switch from default fahrenheit to celsius (default: Fahrenheit) ```bash set -g @dracula-show-fahrenheit false ``` +Set your location manually (default: it tries to guess your location with your IP) + +```bash +set -g @dracula-fixed-location "Some City" +``` + +Hide your location (default: true) + +```bash +set -g @dracula-show-location false +``` From 42eaf7a950511ed0f791ddf9435d82dca7d2a3f4 Mon Sep 17 00:00:00 2001 From: Rojo Date: Sun, 27 Mar 2022 23:31:33 +0200 Subject: [PATCH 12/17] No defaults --- INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 92cc66f..96f987c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -201,19 +201,19 @@ set -g @dracula-git-no-repo-message "" #### weather options -Switch from default fahrenheit to celsius (default: Fahrenheit) +Switch from default fahrenheit to celsius ```bash set -g @dracula-show-fahrenheit false ``` -Set your location manually (default: it tries to guess your location with your IP) +Set your location manually ```bash set -g @dracula-fixed-location "Some City" ``` -Hide your location (default: true) +Hide your location ```bash set -g @dracula-show-location false From 49f212207e05cf06f19598cbfc61d6c71e681f6b Mon Sep 17 00:00:00 2001 From: Pholawat <82935610+pholawat-tle@users.noreply.github.com> Date: Wed, 11 May 2022 15:53:37 +0700 Subject: [PATCH 13/17] import utils.sh in battery.sh --- scripts/battery.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/battery.sh b/scripts/battery.sh index c9d96d7..65211bf 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -2,6 +2,9 @@ # 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 + linux_acpi() { arg=$1 BAT=$(ls -d /sys/class/power_supply/BAT* | head -1) From 95d3aa81448894b1806905c98ef36f1974380e52 Mon Sep 17 00:00:00 2001 From: Pholawat <82935610+pholawat-tle@users.noreply.github.com> Date: Wed, 11 May 2022 15:58:58 +0700 Subject: [PATCH 14/17] include @dracula-battery-label option in INSTALL.md --- INSTALL.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index e9d092b..f62a08d 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -128,6 +128,14 @@ set -g @dracula-cpu-display-load true CPU usage percentage (default) - in percentage (output: %) Load average – is the average system load calculated over a given period of time of 1, 5 and 15 minutes (output: x.x x.x x.x) +#### battery options + +Customize label + +```bash +set -g @dracula-battery-label "Battery" +``` + #### gpu-usage options Customize label From 8012d2164a3a143e8ac9c8aecb2ff4b9d0d83784 Mon Sep 17 00:00:00 2001 From: Jihed Mastouri <25284659+jihedmastouri@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:14:17 +0100 Subject: [PATCH 15/17] Battery Status for Fedora 36 --- scripts/battery.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/battery.sh b/scripts/battery.sh index 65211bf..86b9ac0 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -89,10 +89,10 @@ battery_status() discharging|Discharging) echo '' ;; - high) + high|Full) echo '' ;; - charging) + charging|Charging) echo 'AC' ;; *) From 135637745daef7bd8f6f62e1a4c75aad4b0bbb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Mon, 5 Sep 2022 15:47:55 +0200 Subject: [PATCH 16/17] scripts: git: add option for untracked files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default 'git status' will look for untracked files and the script will always detect that the local tree has changes if untracked files are present. That is not always optimal since sometimes we might have, for example, some custom build scripts (for some project) that is always present and we don't want the status bar to always indicate changes. Hence, add an option to disable this behavior by adding the '-uno' flag to 'git status'. The default behavior is still maintained. Signed-off-by: Nuno Sá --- INSTALL.md | 5 +++++ scripts/git.sh | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e1b6587..ebeae4e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -206,6 +206,11 @@ Set symbol or message to use when the current pane has no git repo set -g @dracula-git-no-repo-message "" ``` +Hide untracked files from being displayed as local changes +```bash +# default is false +set -g @dracula-git-no-untracked-files true +``` #### weather options diff --git a/scripts/git.sh b/scripts/git.sh index 3dba4e9..5dd8a2f 100755 --- a/scripts/git.sh +++ b/scripts/git.sh @@ -7,6 +7,7 @@ IFS=' ' read -r -a hide_status <<< $(get_tmux_option "@dracula-git-disable-statu IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-git-show-current-symbol" "✓") 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") # Get added, modified, updated and deleted files from git status getChanges() @@ -77,8 +78,9 @@ checkEmptySymbol() # check to see if the current repo is not up to date with HEAD checkForChanges() { + [ $no_untracked_files == "false" ] && no_untracked="" || no_untracked="-uno" if [ "$(checkForGitDir)" == "true" ]; then - if [ "$(git -C $path status -s)" != "" ]; then + if [ "$(git -C $path status -s $no_untracked)" != "" ]; then echo "true" else echo "false" From e9f46f76ca4eff782d3883645971585741720efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Mon, 5 Sep 2022 15:57:11 +0200 Subject: [PATCH 17/17] scripts: git: add '--no-optional-locks' option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As stated in 'git status --help': "By default, git status will automatically refresh the index, updating the cached stat information from the working tree and writing out the result. Writing out the updated index is an optimization that isn’t strictly necessary (status computes the values for itself, but writing them out is just to save subsequent programs from repeating our computation). When status is run in the background, the lock held during the write may conflict with other simultaneous processes, causing them to fail. Scripts running status in the background should consider using git --no-optional-locks status (see git(1) for details)." This was actually happen during rebasing whith the following error: "error: Unable to create '/home/nsa/work/linux/.git/index.lock': File exists. Another git process seems to be running in this repository, e.g. an editor opened by 'git commit'. Please make sure all processes are terminated then try again. If it still fails, a git process may have crashed in this repository earlier: remove the file manually to continue." This change fixes the above... Signed-off-by: Nuno Sá --- scripts/git.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/git.sh b/scripts/git.sh index 5dd8a2f..235c44e 100755 --- a/scripts/git.sh +++ b/scripts/git.sh @@ -17,7 +17,7 @@ getChanges() declare -i updated=0; declare -i deleted=0; -for i in $(git -C $path status -s) +for i in $(git -C $path --no-optional-locks status -s) do case $i in @@ -80,7 +80,7 @@ checkForChanges() { [ $no_untracked_files == "false" ] && no_untracked="" || no_untracked="-uno" if [ "$(checkForGitDir)" == "true" ]; then - if [ "$(git -C $path status -s $no_untracked)" != "" ]; then + if [ "$(git -C $path --no-optional-locks status -s $no_untracked)" != "" ]; then echo "true" else echo "false"