Skip to content

Commit cc68c1e

Browse files
committed
config: 🛠️ tmux config modifications
1 parent 4978d9c commit cc68c1e

2 files changed

Lines changed: 125 additions & 22 deletions

File tree

tmux/scripts/git-status.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#!/usr/bin/env bash
2+
3+
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4+
source "$CURRENT_DIR/../lib/coreutils-compat.sh"
5+
source "$CURRENT_DIR/themes.sh"
6+
7+
cd "$1" || exit 1
8+
RESET="#[fg=${THEME[foreground]},bg=${THEME[background]},nobold,noitalics,nounderscore,nodim]"
9+
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
10+
STATUS=$(git status --porcelain 2>/dev/null | grep -cE "^(M| M)")
11+
12+
SYNC_MODE=0
13+
NEED_PUSH=0
14+
15+
if [[ ${#BRANCH} -gt 25 ]]; then
16+
BRANCH="${BRANCH:0:25}"
17+
fi
18+
19+
STATUS_CHANGED=""
20+
STATUS_INSERTIONS=""
21+
STATUS_DELETIONS=""
22+
STATUS_UNTRACKED=""
23+
24+
if [[ $STATUS -ne 0 ]]; then
25+
DIFF_COUNTS=($(git diff --numstat 2>/dev/null | awk 'NF==3 {changed+=1; ins+=$1; del+=$2} END {printf("%d %d %d", changed, ins, del)}'))
26+
CHANGED_COUNT=${DIFF_COUNTS[0]}
27+
INSERTIONS_COUNT=${DIFF_COUNTS[1]}
28+
DELETIONS_COUNT=${DIFF_COUNTS[2]}
29+
30+
SYNC_MODE=1
31+
fi
32+
33+
UNTRACKED_COUNT="$(git ls-files --other --directory --exclude-standard | wc -l | bc)"
34+
35+
if [[ $CHANGED_COUNT -gt 0 ]]; then
36+
STATUS_CHANGED="${RESET}#[fg=${THEME[yellow]},bg=${THEME[background]},bold] ${CHANGED_COUNT} "
37+
fi
38+
39+
if [[ $INSERTIONS_COUNT -gt 0 ]]; then
40+
STATUS_INSERTIONS="${RESET}#[fg=${THEME[green]},bg=${THEME[background]},bold] ${INSERTIONS_COUNT} "
41+
fi
42+
43+
if [[ $DELETIONS_COUNT -gt 0 ]]; then
44+
STATUS_DELETIONS="${RESET}#[fg=${THEME[red]},bg=${THEME[background]},bold] ${DELETIONS_COUNT} "
45+
fi
46+
47+
if [[ $UNTRACKED_COUNT -gt 0 ]]; then
48+
STATUS_UNTRACKED="${RESET}#[fg=${THEME[foreground]},bg=${THEME[background]},bold] ${UNTRACKED_COUNT} "
49+
fi
50+
51+
# Determine repository sync status
52+
if [[ $SYNC_MODE -eq 0 ]]; then
53+
NEED_PUSH=$(git log @{push}.. | wc -l | bc)
54+
if [[ $NEED_PUSH -gt 0 ]]; then
55+
SYNC_MODE=2
56+
else
57+
LAST_FETCH=$(stat -c %Y .git/FETCH_HEAD | bc)
58+
NOW=$(date +%s | bc)
59+
60+
# if 5 minutes have passed since the last fetch
61+
if [[ $((NOW - LAST_FETCH)) -gt 300 ]]; then
62+
git fetch --atomic origin --negotiation-tip=HEAD
63+
fi
64+
65+
# Check if the remote branch is ahead of the local branch
66+
REMOTE_DIFF="$(git diff --numstat "${BRANCH}" "origin/${BRANCH}" 2>/dev/null)"
67+
if [[ -n $REMOTE_DIFF ]]; then
68+
SYNC_MODE=3
69+
fi
70+
fi
71+
fi
72+
73+
# Set the status indicator based on the sync mode
74+
case "$SYNC_MODE" in
75+
1)
76+
REMOTE_STATUS="$RESET#[bg=${THEME[background]},fg=${THEME[bred]},bold]▒ 󱓎"
77+
;;
78+
2)
79+
REMOTE_STATUS="$RESET#[bg=${THEME[background]},fg=${THEME[red]},bold]▒ 󰛃"
80+
;;
81+
3)
82+
REMOTE_STATUS="$RESET#[bg=${THEME[background]},fg=${THEME[magenta]},bold]▒ 󰛀"
83+
;;
84+
*)
85+
REMOTE_STATUS="$RESET#[bg=${THEME[background]},fg=${THEME[green]},bold]▒ "
86+
;;
87+
esac
88+
89+
if [[ -n $BRANCH ]]; then
90+
echo "$REMOTE_STATUS $RESET$BRANCH $STATUS_CHANGED$STATUS_INSERTIONS$STATUS_DELETIONS$STATUS_UNTRACKED"
91+
fi

tmux/tmux.conf

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ set -ga update-environment FZF_DEFAULT_OPTS
7070
# Status Line and Theming
7171
#--------------------------------------------------------------------------
7272
# Define color variables
73-
thm_bg="default"
74-
thm_bg_dark="default"
75-
thm_fg="#c0caf5"
76-
thm_gray="#9499b8"
77-
thm_magenta="#bb9af7"
78-
thm_pink="#ff007c"
79-
thm_green="#9ece6a"
80-
thm_blue="#2ac3de"
81-
thm_black="#414868"
82-
thm_yellow="#e0af68"
83-
thm_selected="#364a82"
84-
thm_match="#3d59a1"
73+
thm_bg="default" # keep, uses terminal/bg
74+
thm_bg_dark="default" # same
75+
thm_fg="#c5c8c9" # light foreground (no-clown-fiesta fg1)
76+
thm_gray="#7c7f93" # muted gray
77+
thm_magenta="#b77ee0" # violet/purple accent
78+
thm_pink="#e46876" # wave red/pink accent
79+
thm_green="#87a35e" # autumn green
80+
thm_blue="#7aa89f" # wave aqua (soft teal-blue)
81+
thm_black="#1b1d26" # sumiInk background tone
82+
thm_yellow="#e6c384" # carp yellow
83+
thm_selected="#2d353b" # selection (sumiInk3)
84+
thm_match="#a3d4d5" # crystal aqua highlight
8585

8686
# Enable status line and position it
8787
set -g status "on"
@@ -91,20 +91,21 @@ set -g status-style 'fg=white'
9191

9292
# Window/pane border styles
9393
set -g pane-border-style "fg=#2c2f3d,bg=default"
94-
set -g pane-active-border-style "fg=${thm_match}"
94+
set -g pane-active-border-style "fg=${thm_gray}"
9595
set -gw pane-border-indicators 'colour'
9696
set -g window-status-activity-style "none"
9797
set-hook -g -w pane-focus-in "set-option -Fw pane-border-status '#{?#{e|>:#{window_panes},1},top,off}'"
98+
set -g pane-border-format "#H"
9899

99100

100101
# Status left: session name
101-
set -g status-left "#[fg=#{?client_prefix,${thm_yellow},${thm_fg}},bg=${thm_bg_dark}]#S#[fg=${thm_fg},bg=default] "
102+
set -g status-left " #[fg=#{?client_prefix,${thm_yellow},${thm_fg}},bg=${thm_bg_dark}]#S#[fg=${thm_fg},bg=default] "
102103

103104
# Status left length
104105
set -g status-left-length 30
105106

106107
# Status right: Disabled for now
107-
set -g status-right ""
108+
set -g status-right '#{?#{==:#{pane_current_command},nvim},#($HOME/.config/tmux/scripts/git-status.sh #{pane_current_path}),}'
108109

109110
# Update status interval
110111
set -g status-interval 1
@@ -207,10 +208,6 @@ bind y run -b "tmux show-buffer | pbcopy" \; display-message "copied tmux buffer
207208
bind-key B break-pane -d
208209
bind-key E command-prompt -p "join pane from: " "join-pane -h -s '%%'"
209210

210-
# Toggle tmux status bar top/bottom
211-
bind-key C-k run-shell "tmux set-option -g status-position top;"
212-
bind-key C-j run-shell "tmux set-option -g status-position bottom;"
213-
214211
# Opencode popup menu
215212
bind o popup -E -d "#{pane_current_path}" -w 90% -h 90% "opencode"
216213
bind O new-window -n " opencode" -c "#{pane_current_path}" "opencode"
@@ -219,7 +216,7 @@ bind O new-window -n " opencode" -c "#{pane_current_path}" "opencode"
219216
# Sesh Integration
220217
#--------------------------------------------------------------------------
221218
bind-key "T" run-shell "sesh connect \"$(
222-
sesh list --icons | fzf-tmux -p 55%,60% \
219+
sesh list --icons | fzf-tmux -p 80%,60% \
223220
--no-sort --ansi --border-label ' sesh ' --prompt '' \
224221
--header ' ^a all ^t tmux ^g configs ^x zoxide ^d tmux kill ^f find' \
225222
--bind 'tab:down,btab:up' \
@@ -229,14 +226,29 @@ bind-key "T" run-shell "sesh connect \"$(
229226
--bind 'ctrl-x:change-prompt(📁 )+reload(sesh list -z --icons)' \
230227
--bind 'ctrl-f:change-prompt(🔎 )+reload(fd -H -d 2 -t d -E .Trash . ~)' \
231228
--bind 'ctrl-d:execute(tmux kill-session -t {2..})+change-prompt(⚡ )+reload(sesh list --icons)' \
232-
--preview-window 'right:55%' \
229+
--preview-window 'right:0%' \
233230
--preview 'sesh preview {}'
234231
)\""
235232

233+
# Find and jump to window
234+
bind f display-popup -E "\
235+
tmux list-windows -F '#{window_index} #{window_name}' |\
236+
sed '/^$/d' |\
237+
fzf --reverse --header select-window |\
238+
cut -d ' ' -f 1 |\
239+
xargs tmux select-window -t"
240+
241+
# Find and jump to session
242+
bind e display-popup -E "\
243+
tmux list-sessions -F '#{?session_attached,,#{session_name}}' |\
244+
sed '/^$/d' |\
245+
fzf --reverse --header select-session |\
246+
xargs tmux switch-client -t"
247+
236248
#--------------------------------------------------------------------------
237249
# List Panes Integration
238250
# --------------------------------------------------------------------------
239-
bind-key f run-shell -b "$HOME/.config/tmux/scripts/list-panes.sh"
251+
# bind-key f run-shell -b "$HOME/.config/tmux/scripts/list-panes.sh"
240252

241253
#--------------------------------------------------------------------------
242254
# Plugins

0 commit comments

Comments
 (0)