Tmux sessionizer
This commit is contained in:
Vendored
BIN
Binary file not shown.
@@ -12,12 +12,34 @@ set -g status-justify left
|
||||
set -g status-style 'bg=default' # Completely transparent container
|
||||
|
||||
set -g status-left-length 100
|
||||
set -g status-left "#[fg=#090E13,bg=colour14,bold] #S "
|
||||
set -g status-left "#[fg=#090E13,bg=colour6,bold] #S "
|
||||
# palette = 0=#090E13
|
||||
# palette = 1=#c4746e
|
||||
# palette = 2=#8a9a7b
|
||||
# palette = 3=#c4b28a
|
||||
# palette = 4=#8ba4b0
|
||||
# palette = 5=#a292a3
|
||||
# palette = 6=#8ea4a2
|
||||
# palette = 7=#a4a7a4
|
||||
# palette = 8=#5C6066
|
||||
# palette = 9=#e46876
|
||||
# palette = 10=#87a987
|
||||
# palette = 11=#e6c384
|
||||
# palette = 12=#7fb4ca
|
||||
# palette = 13=#938aa9
|
||||
# palette = 14=#7aa89f
|
||||
# palette = 15=#c5c9c7
|
||||
#
|
||||
# background = #090E13
|
||||
# foreground = #c5c9c7
|
||||
# cursor-color = #c5c9c7
|
||||
# selection-background = #22262D
|
||||
# selection-foreground = #c5c9c7
|
||||
|
||||
set -g status-right ""
|
||||
|
||||
set -g window-status-current-format "#[fg=colour1,bg=default] #F#I:#W"
|
||||
set -g window-status-format "#[fg=colour7,bg=default] #I:#W"
|
||||
set -g window-status-current-format "#[fg=colour1,bg=default] #F#I:#W "
|
||||
set -g window-status-format "#[fg=colour7,bg=default] #I:#W "
|
||||
|
||||
set -g message-style 'fg=colour3 bg=default bold'
|
||||
|
||||
|
||||
Executable
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 1. Get active tmux sessions
|
||||
sessions=$(tmux list-sessions -F "#S" 2>/dev/null)
|
||||
|
||||
# 2. Get directories from key work paths
|
||||
dirs=$(find ~ ~/.config ~/Projects ~/dotfiles ~/personal \
|
||||
-mindepth 1 -maxdepth 4 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name ".cache" -o -name "Library" \) -prune \
|
||||
-o -type d -print 2>/dev/null)
|
||||
|
||||
# 3. Dynamic Previewer (Tree view for folders, Window list for sessions)
|
||||
preview_cmd='
|
||||
if [ -d {} ]; then
|
||||
if command -v eza &>/dev/null; then
|
||||
eza --tree --level=2 --icons --color=always {}
|
||||
elif command -v tree &>/dev/null; then
|
||||
tree -C -L 2 {}
|
||||
else
|
||||
ls -la --color=always {}
|
||||
fi
|
||||
else
|
||||
tmux list-windows -t {} 2>/dev/null
|
||||
fi'
|
||||
|
||||
# 4. Kanagawa Wave Themed FZF Selector
|
||||
selected=$(printf "%s\n%s" "$sessions" "$dirs" | grep -v '^$' | fzf \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--margin=1 \
|
||||
--padding=1 \
|
||||
--height=100% \
|
||||
--prompt=" " \
|
||||
--color="bg:#1F1F28,bg+:#223249,fg:#DCD7BA,fg+:#DCD7BA" \
|
||||
--color="hl:#2D4F67,hl+:#7E9CD8,prompt:#957FB8,pointer:#7E9CD8" \
|
||||
--color="info:#98BB6C,spinner:#957FB8,header:#7AA89F,border:#54546D" \
|
||||
--color="marker:#98BB6C" \
|
||||
--preview="$preview_cmd" \
|
||||
--preview-window="right:55%:border-left")
|
||||
|
||||
# Exit if fzf was cancelled
|
||||
[[ -z "$selected" ]] && exit 0
|
||||
|
||||
# 5. Handle Session Creation / Switching
|
||||
if [[ -d "$selected" ]]; then
|
||||
# Selection is a DIRECTORY -> Create session named after folder
|
||||
session_name=$(basename "$selected" | tr '.: ' '_')
|
||||
|
||||
if ! tmux has-session -t "=$session_name" 2>/dev/null; then
|
||||
tmux new-session -d -s "$session_name" -c "$selected"
|
||||
fi
|
||||
else
|
||||
# Selection is an EXISTING SESSION -> Connect directly
|
||||
session_name="$selected"
|
||||
fi
|
||||
|
||||
# 6. Attach or Switch
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
exec tmux attach-session -t "$session_name"
|
||||
else
|
||||
tmux switch-client -t "$session_name"
|
||||
fi
|
||||
Reference in New Issue
Block a user