Skip to content

Commit 3b49773

Browse files
committed
init commit of fork
0 parents  commit 3b49773

17 files changed

+1110
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# JUnit reports
2+
**/report.xml
3+
venv/**

LICENSE.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License (MIT)
2+
3+
Copyright (c) 2018 Lógico Software <[email protected]>
4+
(https://logico.com.ar)
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Catppuccin Tmux
2+
3+
This repository is a fork of [tokyo-night-tmux](https://github.com/janoamaral/tokyo-night-tmux) by Logico. The license of that code was the MIT license, and is maintained in this repository through the `LICENSE.md` file. A huge thank you to their development efforts, whichout which this would not be possible.
4+
5+
The primary purpose of this repository is to take the visual outline of the tokyo-night-tmux plugin but change the colours and themes to be catppuccin. There is also the [tmux repository in the catppuccin organization](https://github.com/catppuccin/tmux) which you may also experiment with and decide on your preference.
6+

catppuccin.tmux

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3+
# title Catppuccin Tmux +
4+
# version 1.0.0 +
5+
# repository https://github.com/mark-pitblado/catppuccin-tmux +
6+
# author Mark Pitblado +
7+
8+
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+
10+
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+
SCRIPTS_PATH="$CURRENT_DIR/src"
12+
13+
source $SCRIPTS_PATH/themes.sh
14+
15+
tmux set -g status-left-length 80
16+
tmux set -g status-right-length 150
17+
18+
RESET="#[fg=${THEME[foreground]},bg=${THEME[background]},nobold,noitalics,nounderscore,nodim]"
19+
# Highlight colors
20+
tmux set -g mode-style "fg=${THEME[bgreen]},bg=${THEME[bblack]}"
21+
22+
tmux set -g message-style "bg=${THEME[blue]},fg=${THEME[background]}"
23+
tmux set -g message-command-style "fg=${THEME[white]},bg=${THEME[black]}"
24+
25+
tmux set -g pane-border-style "fg=${THEME[bblack]}"
26+
tmux set -g pane-active-border-style "fg=${THEME[blue]}"
27+
tmux set -g pane-border-status off
28+
29+
tmux set -g status-style bg="${THEME[background]}"
30+
31+
TMUX_VARS="$(tmux show -g)"
32+
33+
default_window_id_style="digital"
34+
default_pane_id_style="hsquare"
35+
default_zoom_id_style="dsquare"
36+
37+
window_id_style="$(echo "$TMUX_VARS" | grep '@tokyo-night-tmux_window_id_style' | cut -d" " -f2)"
38+
pane_id_style="$(echo "$TMUX_VARS" | grep '@tokyo-night-tmux_pane_id_style' | cut -d" " -f2)"
39+
zoom_id_style="$(echo "$TMUX_VARS" | grep '@tokyo-night-tmux_zoom_id_style' | cut -d" " -f2)"
40+
window_id_style="${window_id_style:-$default_window_id_style}"
41+
pane_id_style="${pane_id_style:-$default_pane_id_style}"
42+
zoom_id_style="${zoom_id_style:-$default_zoom_id_style}"
43+
44+
netspeed="#($SCRIPTS_PATH/netspeed.sh)"
45+
cmus_status="#($SCRIPTS_PATH/music-tmux-statusbar.sh)"
46+
git_status="#($SCRIPTS_PATH/git-status.sh #{pane_current_path})"
47+
wb_git_status="#($SCRIPTS_PATH/wb-git-status.sh #{pane_current_path} &)"
48+
window_number="#($SCRIPTS_PATH/custom-number.sh #I $window_id_style)"
49+
custom_pane="#($SCRIPTS_PATH/custom-number.sh #P $pane_id_style)"
50+
zoom_number="#($SCRIPTS_PATH/custom-number.sh #P $zoom_id_style)"
51+
date_and_time="$($SCRIPTS_PATH/datetime-widget.sh)"
52+
current_path="#($SCRIPTS_PATH/path-widget.sh #{pane_current_path})"
53+
battery_status="#($SCRIPTS_PATH/battery-widget.sh)"
54+
55+
#+--- Bars LEFT ---+
56+
# Session name
57+
tmux set -g status-left "#[fg=${THEME[bblack]},bg=${THEME[blue]},bold] #{?client_prefix,󰠠 ,#[dim]󰤂 }#[bold,nodim]#S "
58+
59+
#+--- Windows ---+
60+
# Focus
61+
tmux set -g window-status-current-format "$RESET#[fg=${THEME[green]},bg=${THEME[bblack]}] #{?#{==:#{pane_current_command},ssh},󰣀 , }#[fg=${THEME[foreground]},bold,nodim]$window_number#W#[nobold]#{?window_zoomed_flag, $zoom_number, $custom_pane}#{?window_last_flag, , }"
62+
# Unfocused
63+
tmux set -g window-status-format "$RESET#[fg=${THEME[foreground]}] #{?#{==:#{pane_current_command},ssh},󰣀 , }${RESET}$window_number#W#[nobold,dim]#{?window_zoomed_flag, $zoom_number, $custom_pane}#[fg=${THEME[yellow]}]#{?window_last_flag,󰁯 , }"
64+
65+
#+--- Bars RIGHT ---+
66+
tmux set -g status-right "$battery_status$current_path$cmus_status$netspeed$git_status$wb_git_status$date_and_time"
67+
tmux set -g window-status-separator ""

lib/coreutils-compat.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Compatibility functions for macOS
4+
if [[ "$(uname)" == "Darwin" ]]; then
5+
HOMEBREW_PREFIX="$(brew --prefix)"
6+
# Use GNU coreutils if available
7+
if [ -d "$HOMEBREW_PREFIX/opt/coreutils" ]; then
8+
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
9+
fi
10+
# Use GNU awk if available
11+
if [ -d "$HOMEBREW_PREFIX/opt/gawk" ]; then
12+
export PATH="$HOMEBREW_PREFIX/opt/gawk/libexec/gnubin:$PATH"
13+
fi
14+
# Use GNU sed if available
15+
if [ -d "$HOMEBREW_PREFIX/opt/gsed" ]; then
16+
export PATH="$HOMEBREW_PREFIX/opt/gsed/libexec/gnubin:$PATH"
17+
fi
18+
# Use Homebrew bc if available
19+
if [ -d "$HOMEBREW_PREFIX/opt/bc" ]; then
20+
export PATH="$HOMEBREW_PREFIX/opt/bc/bin:$PATH"
21+
fi
22+
fi

lib/netspeed.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
3+
# Get network transmit data
4+
function get_bytes() {
5+
local interface="$1"
6+
if [[ "$(uname)" == "Linux" ]]; then
7+
awk -v interface="$interface" '$1 == interface ":" {print $2, $10}' /proc/net/dev
8+
elif [[ "$(uname)" == "Darwin" ]]; then
9+
netstat -ib | awk -v interface="$interface" '/^'"${interface}"'/ {print $7, $10}' | head -n1
10+
else
11+
# Unsupported operating system
12+
exit 1
13+
fi
14+
}
15+
16+
# Convert into readable format
17+
function readable_format() {
18+
local bytes=$1
19+
local secs=${2:-1}
20+
21+
if [[ $bytes -lt 1048576 ]]; then
22+
echo "$(bc -l <<<"scale=1; $bytes / 1024 / $secs")KB/s"
23+
else
24+
echo "$(bc -l <<<"scale=1; $bytes / 1048576 / $secs")MB/s"
25+
fi
26+
}
27+
28+
# Auto-determine interface
29+
function find_interface() {
30+
local interface
31+
if [[ $(uname) == "Linux" ]]; then
32+
interface=$(awk '$2 == 00000000 {print $1}' /proc/net/route)
33+
elif [[ $(uname) == "Darwin" ]]; then
34+
interface=$(route get default 2>/dev/null | grep interface | awk '{print $2}')
35+
# If VPN, fallback to en0
36+
[[ ${interface:0:4} == "utun" ]] && interface="en0"
37+
fi
38+
echo "$interface"
39+
}
40+
41+
# Detect interface IPv4 and status
42+
function interface_ipv4() {
43+
local interface="$1"
44+
local ipv4_addr
45+
local status="up" # Default assumption
46+
if [[ $(uname) == "Darwin" ]]; then
47+
# Check for an IPv4 on macOS
48+
ipv4_addr=$(ipconfig getifaddr "$interface")
49+
[[ -z $ipv4_addr ]] && status="down"
50+
elif [[ $(uname) == "Linux" ]]; then
51+
# Use 'ip' command to check for IPv4 address
52+
if command -v ip >/dev/null 2>&1; then
53+
ipv4_addr=$(ip addr show dev "$interface" 2>/dev/null | grep "inet\b" | awk '{sub("/.*", "", $2); print $2}')
54+
[[ -z $ipv4_addr ]] && status="down"
55+
# Use 'ifconfig' command to check for IPv4 address
56+
elif command -v ifconfig >/dev/null 2>&1; then
57+
ipv4_addr=$(ifconfig "$interface" 2>/dev/null | grep "inet\b" | awk '{print $2}')
58+
[[ -z $ipv4_addr ]] && status="down"
59+
# Fallback to operstate on Linux
60+
elif [[ $(cat "/sys/class/net/$interface/operstate" 2>/dev/null) != "up" ]]; then
61+
status="down"
62+
fi
63+
fi
64+
echo "$ipv4_addr"
65+
[[ $status == "up" ]] && return 0 || return 1
66+
}

src/battery-widget.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/usr/bin/env bash
2+
3+
# Imports
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
5+
. "${ROOT_DIR}/lib/coreutils-compat.sh"
6+
7+
# Check if the battery widget is enabled
8+
SHOW_BATTERY_WIDGET=$(tmux show-option -gv @tokyo-night-tmux_show_battery_widget 2>/dev/null)
9+
if [ "${SHOW_BATTERY_WIDGET}" != "1" ]; then
10+
exit 0
11+
fi
12+
13+
# Get values from tmux config or set defaults
14+
BATTERY_NAME=$(tmux show-option -gv @tokyo-night-tmux_battery_name 2>/dev/null)
15+
BATTERY_LOW=$(tmux show-option -gv @tokyo-night-tmux_battery_low_threshold 2>/dev/null)
16+
RESET="#[fg=brightwhite,bg=#15161e,nobold,noitalics,nounderscore,nodim]"
17+
18+
DISCHARGING_ICONS=("󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹")
19+
CHARGING_ICONS=("󰢜" "󰂆" "󰂇" "󰂈" "󰢝" "󰂉" "󰢞" "󰂊" "󰂋" "󰂅")
20+
NOT_CHARGING_ICON="󰚥"
21+
NO_BATTERY_ICON="󱉝"
22+
DEFAULT_BATTERY_LOW=21
23+
24+
if [[ "$(uname)" == "Darwin" ]]; then
25+
default_battery_name="InternalBattery-0"
26+
else
27+
default_battery_name="BAT1"
28+
fi
29+
30+
BATTERY_NAME="${BATTERY_NAME:-$default_battery_name}"
31+
BATTERY_LOW="${BATTERY_LOW:-$DEFAULT_BATTERY_LOW}"
32+
33+
# Check if battery exists
34+
battery_exists() {
35+
case "$(uname)" in
36+
"Darwin")
37+
pmset -g batt | grep -q "$BATTERY_NAME"
38+
;;
39+
"Linux")
40+
[[ -d "/sys/class/power_supply/$BATTERY_NAME" ]]
41+
;;
42+
"CYGWIN" | "MINGW" | "MSYS" | "Windows_NT")
43+
WMIC PATH Win32_Battery Get EstimatedChargeRemaining 2>&1 | grep -q "EstimatedChargeRemaining"
44+
;;
45+
*)
46+
return 1
47+
;;
48+
esac
49+
}
50+
51+
# Exit if no battery is found
52+
if ! battery_exists; then
53+
exit 0
54+
fi
55+
56+
# Get battery stats for different OS
57+
get_battery_stats() {
58+
local battery_name=$1
59+
local battery_status=""
60+
local battery_percentage=""
61+
62+
case "$(uname)" in
63+
"Darwin")
64+
pmstat=$(pmset -g batt | grep "$battery_name")
65+
battery_status=$(echo "$pmstat" | awk '{print $4}' | sed 's/[^a-zA-Z]*//g')
66+
battery_percentage=$(echo "$pmstat" | awk '{print $3}' | sed 's/[^0-9]*//g')
67+
;;
68+
"Linux")
69+
if [[ -f "/sys/class/power_supply/${battery_name}/status" && -f "/sys/class/power_supply/${battery_name}/capacity" ]]; then
70+
battery_status=$(<"/sys/class/power_supply/${battery_name}/status")
71+
battery_percentage=$(<"/sys/class/power_supply/${battery_name}/capacity")
72+
else
73+
battery_status="Unknown"
74+
battery_percentage="0"
75+
fi
76+
;;
77+
"CYGWIN" | "MINGW" | "MSYS" | "Windows_NT")
78+
battery_percentage=$(WMIC PATH Win32_Battery Get EstimatedChargeRemaining | grep -Eo '[0-9]+')
79+
[[ -n $battery_percentage ]] && battery_status="Discharging" || battery_status="Unknown"
80+
;;
81+
*)
82+
battery_status="UnsupportedOS"
83+
battery_percentage=0
84+
;;
85+
esac
86+
87+
echo "$battery_status $battery_percentage"
88+
}
89+
90+
# Fetch the battery status and percentage
91+
read -r BATTERY_STATUS BATTERY_PERCENTAGE < <(get_battery_stats "$BATTERY_NAME")
92+
93+
# Ensure percentage is a number
94+
if ! [[ $BATTERY_PERCENTAGE =~ ^[0-9]+$ ]]; then
95+
BATTERY_PERCENTAGE=0
96+
fi
97+
98+
# Determine icon and color based on battery status and percentage
99+
case "$BATTERY_STATUS" in
100+
"Charging" | "Charged" | "charging" | "Charged")
101+
ICON="${CHARGING_ICONS[$((BATTERY_PERCENTAGE / 10))]}"
102+
;;
103+
"Discharging" | "discharging")
104+
ICON="${DISCHARGING_ICONS[$((BATTERY_PERCENTAGE / 10))]}"
105+
;;
106+
"Full" | "charged" | "full" | "AC")
107+
ICON="$NOT_CHARGING_ICON"
108+
;;
109+
*)
110+
ICON="$NO_BATTERY_ICON"
111+
;;
112+
esac
113+
114+
# Set color based on battery percentage
115+
if [[ $BATTERY_PERCENTAGE -lt $BATTERY_LOW ]]; then
116+
color="#[fg=red,bg=default,bold]"
117+
elif [[ $BATTERY_PERCENTAGE -ge 100 ]]; then
118+
color="#[fg=green,bg=default]"
119+
else
120+
color="#[fg=yellow,bg=default]"
121+
fi
122+
123+
# Print the battery status with some extra spaces for padding
124+
echo "${color}${ICON}${RESET} #[bg=default] ${BATTERY_PERCENTAGE}% "

src/cmus-tmux-statusbar.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env bash
2+
3+
# Imports
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/.."
5+
. "${ROOT_DIR}/lib/coreutils-compat.sh"
6+
7+
ACCENT_COLOR="#7aa2f7"
8+
SECONDARY_COLOR="#24283B"
9+
BG_COLOR="#1F2335"
10+
BG_BAR="#15161e"
11+
TIME_COLOR="#414868"
12+
13+
if [[ $1 =~ ^[[:digit:]]+$ ]]; then
14+
MAX_TITLE_WIDTH=20
15+
else
16+
MAX_TITLE_WIDTH=$(($(tmux display -p '#{window_width}' 2>/dev/null || echo 120) - 130))
17+
fi
18+
19+
MAX_TITLE_WIDTH=25
20+
21+
if cmus-remote -Q >/dev/null 2>/dev/null; then
22+
CMUS_STATUS=$(cmus-remote -Q)
23+
STATUS=$(echo "$CMUS_STATUS" | grep status | head -n 1 | cut -d' ' -f2-)
24+
ARTIST=$(echo "$CMUS_STATUS" | grep 'tag artist' | head -n 1 | cut -d' ' -f3-)
25+
TITLE=$(echo "$CMUS_STATUS" | grep 'tag title' | cut -d' ' -f3-)
26+
DURATION=$(echo "$CMUS_STATUS" | grep 'duration' | cut -d' ' -f2-)
27+
POSITION=$(echo "$CMUS_STATUS" | grep 'position' | cut -d' ' -f2-)
28+
29+
P_MIN=$(printf '%02d' $((POSITION / 60)))
30+
P_SEC=$(printf '%02d' $((POSITION % 60)))
31+
32+
D_MIN=$(printf '%02d' $((DURATION / 60)))
33+
D_SEC=$(printf '%02d' $((DURATION % 60)))
34+
TIME="[$P_MIN:$P_SEC / $D_MIN:$D_SEC]"
35+
36+
if [ "$D_SEC" = "-1" ]; then
37+
TIME="[ $P_MIN:$P_SEC]"
38+
fi
39+
40+
if [ -n "$TITLE" ]; then
41+
if [ "$STATUS" = "playing" ]; then
42+
PLAY_STATE="$OUTPUT"
43+
else
44+
PLAY_STATE="$OUTPUT"
45+
fi
46+
OUTPUT="$PLAY_STATE $TITLE"
47+
48+
# Only show the song title if we are over $MAX_TITLE_WIDTH characters
49+
else
50+
OUTPUT=''
51+
fi
52+
fi
53+
54+
if [ "${#OUTPUT}" -ge $MAX_TITLE_WIDTH ]; then
55+
OUTPUT="$PLAY_STATE ${TITLE:0:$MAX_TITLE_WIDTH-1}"
56+
# Remove trailing spaces
57+
OUTPUT="${OUTPUT%"${OUTPUT##*[![:space:]]}"}"
58+
fi
59+
60+
if [ -z "$OUTPUT" ]; then
61+
echo "$OUTPUT #[fg=green,bg=default]"
62+
else
63+
OUT=" $OUTPUT $TIME "
64+
ONLY_OUT=" $OUTPUT "
65+
TIME_INDEX=${#ONLY_OUT}
66+
OUTPUT_LENGTH=${#OUT}
67+
PERCENT=$((POSITION * 100 / DURATION))
68+
PROGRESS=$((OUTPUT_LENGTH * PERCENT / 100))
69+
O=" $OUTPUT"
70+
71+
if [ $PROGRESS -le $TIME_INDEX ]; then
72+
echo "#[nobold,fg=$BG_COLOR,bg=$ACCENT_COLOR]${O:0:PROGRESS}#[fg=$ACCENT_COLOR,bg=$BG_BAR]${O:PROGRESS:TIME_INDEX} #[fg=$TIME_COLOR,bg=$BG_BAR]$TIME "
73+
else
74+
DIFF=$((PROGRESS - TIME_INDEX))
75+
echo "#[nobold,fg=$BG_COLOR,bg=$ACCENT_COLOR]${O:0:TIME_INDEX} #[fg=$BG_BAR,bg=$ACCENT_COLOR]${OUT:TIME_INDEX:DIFF}#[fg=$TIME_COLOR,bg=$BG_BAR]${OUT:PROGRESS}"
76+
fi
77+
fi

0 commit comments

Comments
 (0)