diff --git a/INSTALL.md b/INSTALL.md index e9d092bb..32a6159c 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 @@ -198,6 +206,17 @@ 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 +``` + +Show remote tracking branch together with diverge/sync state +```bash +# default is false +set -g @dracula-git-show-remote-status true +``` #### weather options @@ -207,3 +226,14 @@ Switch from default fahrenheit to celsius set -g @dracula-show-fahrenheit false ``` +Set your location manually + +```bash +set -g @dracula-fixed-location "Some City" +``` + +Hide your location + +```bash +set -g @dracula-show-location false +``` diff --git a/README.md b/README.md index 243fb262..3367acc9 100644 --- a/README.md +++ b/README.md @@ -14,22 +14,24 @@ 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 -* System temperature on Raspberry PI +- 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 +- System temperature on Raspberry PI +- Spotify playback (needs the tool spotify-tui installed) +- Current kubernetes context ## Compatibility @@ -40,9 +42,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 diff --git a/scripts/battery.sh b/scripts/battery.sh index c9d96d7a..86b9ac05 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) @@ -86,10 +89,10 @@ battery_status() discharging|Discharging) echo '' ;; - high) + high|Full) echo '' ;; - charging) + charging|Charging) echo 'AC' ;; *) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index e83cd3e0..cda88edb 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 @@ -129,7 +130,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 @@ -168,6 +170,16 @@ 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 = "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/git.sh b/scripts/git.sh index 3dba4e9a..965d9eca 100755 --- a/scripts/git.sh +++ b/scripts/git.sh @@ -7,6 +7,8 @@ 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") +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() @@ -16,7 +18,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 @@ -77,8 +79,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 --no-optional-locks status -s $no_untracked)" != "" ]; then echo "true" else echo "false" @@ -108,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 diff --git a/scripts/kubernetes_context.sh b/scripts/kubernetes_context.sh new file mode 100755 index 00000000..ded14171 --- /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 diff --git a/scripts/spotify-tui.sh b/scripts/spotify-tui.sh new file mode 100755 index 00000000..dc07206a --- /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