Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
chauek authored Feb 23, 2023
2 parents 8fc9663 + b346d10 commit 9211489
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 31 deletions.
30 changes: 30 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
```
46 changes: 27 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
7 changes: 5 additions & 2 deletions scripts/battery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -86,10 +89,10 @@ battery_status()
discharging|Discharging)
echo ''
;;
high)
high|Full)
echo ''
;;
charging)
charging|Charging)
echo 'AC'
;;
*)
Expand Down
14 changes: 13 additions & 1 deletion scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
43 changes: 34 additions & 9 deletions scripts/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
51 changes: 51 additions & 0 deletions scripts/kubernetes_context.sh
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions scripts/spotify-tui.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9211489

Please sign in to comment.