chore(starship, nvim, tmux): removing starship, navigation between tmux and nvim, updated environment configs and scripts
This commit is contained in:
1 parent
c9b2a67939
commit
89d37946cf
19 files changed
+354
-405
No files matched your search
Submodule tmux/.config/tmux/plugins/tpm deleted from e261deb1b4.
Submodule tmux/.config/tmux/plugins/vim-tmux-navigator deleted from e41c431a0c.
+10
-23
@@ -1,46 +1,33 @@
|
||||
set -g prefix C-Space
|
||||
bind C-Space send-prefix
|
||||
|
||||
set -g default-shell $SHELL
|
||||
set -s escape-time 0
|
||||
set -g focus-events on
|
||||
set -s theme terminal
|
||||
set -g set-clipboard on
|
||||
set -g detach-on-destroy off
|
||||
set -g status off
|
||||
|
||||
set -g default-terminal "tmux-256color"
|
||||
set -ga terminal-features ',xterm-ghostty:RGB'
|
||||
set -as terminal-overrides ',xterm*:Tc,ghostty:RGB'
|
||||
|
||||
set -g base-index 1
|
||||
set -g pane-base-index 1
|
||||
set -g renumber-windows on
|
||||
|
||||
set -g status off
|
||||
set -g status-position top
|
||||
set -g status-justify centre
|
||||
set -g status-style bg=default
|
||||
|
||||
set -g status-left-length 40
|
||||
set -g status-left "#{?client_prefix,#[fg=colour234]#[bg=colour6]#[bold] #S #[bg=default]#[nobold],#[fg=color242]#[bg=default]#S }"
|
||||
set -g status-right ""
|
||||
|
||||
set -g window-status-separator " "
|
||||
set -g window-status-format "#[fg=color242]#I:#W"
|
||||
set -g window-status-current-format "#[fg=colour3 bold]#I:#W"
|
||||
|
||||
set -g message-style 'fg=colour3 bg=default bold'
|
||||
bind -r v display-popup -E -w 80% -h 80% "~/.local/bin/tmux-sessionizer"
|
||||
|
||||
bind-key h previous-window
|
||||
bind-key l next-window
|
||||
bind-key z resize-pane -Z
|
||||
bind-key b set-option -g status
|
||||
bind -r v run-shell "tmux neww ~/.local/bin/tmux-sessionizer"
|
||||
bind -n C-S-h resize-pane -L 5
|
||||
bind -n C-S-j resize-pane -D 5
|
||||
bind -n C-S-k resize-pane -U 5
|
||||
bind -n C-S-l resize-pane -R 5
|
||||
|
||||
set -g @plugin 'tmux-plugins/tpm'
|
||||
# set -g @plugin 'christoomey/vim-tmux-navigator'
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' | grep -iqE '^[^TXZ ]+ +([^ ]+/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
|
||||
|
||||
run '$HOME/.config/tmux/plugins/tpm/tpm'
|
||||
bind -n C-h if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
|
||||
bind -n C-j if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
|
||||
bind -n C-k if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
|
||||
bind -n C-l if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
|
||||
|
||||
bind I source-file ~/.config/tmux/tmux.conf \; display-message "tmux.conf reloaded!"
|
||||
@@ -1,188 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
|
||||
# Ensure Homebrew and standard paths are accessible inside fzf's preview subshell
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
|
||||
|
||||
# Tabs definition
|
||||
TABS=("All" "Projects" "Dotfiles" "Blank Session")
|
||||
TOTAL=${#TABS[@]}
|
||||
ACTIVE_TAB=0
|
||||
list_sessions() {
|
||||
tmux list-sessions -F '#{session_name}' 2>/dev/null | sed 's/^/@/'
|
||||
}
|
||||
|
||||
# Terminal Palette Colors for the Tab Header (Ghostty palette 12 and 8)
|
||||
CLR_ACTIVE=$(printf '\033[1;38;5;12m')
|
||||
CLR_INACTIVE=$(printf '\033[38;5;8m')
|
||||
CLR_RESET=$(printf '\033[0m')
|
||||
list_dirs() {
|
||||
fd --type d --min-depth 1 --max-depth 2 . \
|
||||
"$HOME/personal/Projects" "$HOME/personal/Projects_Testing" 2>/dev/null
|
||||
fd --type d --max-depth 1 . "$HOME/dotfiles" 2>/dev/null
|
||||
fd --type d --hidden --no-ignore --max-depth 3 \
|
||||
--full-path '.*/\.config/[^/]+$' "$HOME/dotfiles" 2>/dev/null
|
||||
fd --type d --max-depth 1 . "$HOME/.config" 2>/dev/null
|
||||
printf '%s\n' "$HOME"
|
||||
}
|
||||
|
||||
# Dynamic Previewer (Restored exact working structure from your original script)
|
||||
preview_cmd='
|
||||
if [ "{}" = "[Create Blank Session in ~]" ]; then
|
||||
echo "Will spawn an empty session in ~/"
|
||||
elif [ -d {} ]; then
|
||||
if command -v eza >/dev/null 2>&1; then
|
||||
eza --tree --level=2 --icons --color=always --git-ignore -I "node_modules|build|dist|target|.cache" {}
|
||||
elif command -v tree >/dev/null 2>&1; then
|
||||
tree -C -L 2 --gitignore -I "node_modules|build|dist|target|.cache" {}
|
||||
else
|
||||
ls -la --color=always {}
|
||||
fi
|
||||
preview='
|
||||
p={}
|
||||
case "$p" in
|
||||
@*) tmux list-windows -t "${p#@}" 2>/dev/null ;;
|
||||
*) eza --tree --group-directories-first --level=2 --icons --color=always --git-ignore \
|
||||
-I "node_modules|build|dist|target|.cache" "$p" 2>/dev/null \
|
||||
|| ls -la "$p" ;;
|
||||
esac
|
||||
'
|
||||
|
||||
out=$(
|
||||
{ list_sessions; list_dirs; } |
|
||||
awk '!seen[$0]++' |
|
||||
fzf --ansi --reverse --height=100% --border=rounded \
|
||||
--prompt=' ' \
|
||||
--header='enter: open ctrl-b: new blank session esc: cancel' \
|
||||
--preview="$preview" --preview-window='right:55%:border-left' \
|
||||
--color='hl:#7fb4ca,hl+:#7fb4ca,prompt:#7fb4ca,border:#2d3139,header:#5C6066' \
|
||||
--expect=ctrl-b
|
||||
)
|
||||
|
||||
[[ -z $out ]] && exit 0
|
||||
|
||||
key=$(sed -n '1p' <<<"$out")
|
||||
selected=$(sed -n '2p' <<<"$out")
|
||||
|
||||
if [[ $key == ctrl-b || -z $selected ]]; then
|
||||
idx=1
|
||||
while tmux has-session -t "=blank-$idx" 2>/dev/null; do ((idx++)); done
|
||||
session_name="blank-$idx"
|
||||
tmux new-session -d -s "$session_name" -c "$HOME"
|
||||
elif [[ $selected == @* ]]; then
|
||||
session_name=${selected#@}
|
||||
else
|
||||
tmux list-windows -t {} 2>/dev/null || echo "Session or path: {}"
|
||||
fi'
|
||||
|
||||
get_projects() {
|
||||
if command -v fd &>/dev/null; then
|
||||
[ -d "$HOME/Projects" ] && fd --type d --max-depth 2 . "$HOME/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects_Testing" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects_Testing" 2>/dev/null | sed 's:/*$::'
|
||||
else
|
||||
if [ -d "$HOME/Projects" ]; then
|
||||
find "$HOME/Projects" -mindepth 1 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects" ]; then
|
||||
find "$HOME/personal/Projects" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects_Testing" ]; then
|
||||
find "$HOME/personal/Projects_Testing" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_dotfiles() {
|
||||
if command -v fd &>/dev/null; then
|
||||
# 1. Standard ~/.config/<app>
|
||||
[ -d "$HOME/.config" ] && fd --type d --max-depth 1 . "$HOME/.config" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# 2. ~/dotfiles direct packages (e.g. ~/dotfiles/nvim, ~/dotfiles/tmux)
|
||||
# and stow structures (e.g. ~/dotfiles/nvim/.config/nvim or ~/dotfiles/.config/*)
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Top-level dotfile modules (depth 1)
|
||||
fd --type d --max-depth 1 . "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# Unhide and drill down specifically into any .config folders inside dotfiles
|
||||
fd --type d --hidden --no-ignore --max-depth 4 \
|
||||
--full-path '.*/\.config/[^/]+$' "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
else
|
||||
# Fallback using find
|
||||
if [ -d "$HOME/.config" ]; then
|
||||
find "$HOME/.config" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Dotfiles packages + nested .config targets up to 4 levels deep
|
||||
find "$HOME/dotfiles" -mindepth 1 -maxdepth 4 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | grep -E '(dotfiles/[^/]+$|/\.config/[^/]+$)' | sed 's:/*$::'
|
||||
fi
|
||||
fi | sort -u
|
||||
}
|
||||
|
||||
get_items_for_tab() {
|
||||
local tab_idx=$1
|
||||
case "$tab_idx" in
|
||||
1) # Projects only
|
||||
get_projects
|
||||
;;
|
||||
2) # Dotfiles only
|
||||
get_dotfiles
|
||||
;;
|
||||
3) # Blank Session
|
||||
echo "[Create Blank Session in ~]"
|
||||
;;
|
||||
*) # All: tmux sessions + projects + dotfiles + top-level home dirs
|
||||
tmux list-sessions -F "#S" 2>/dev/null
|
||||
get_projects
|
||||
get_dotfiles
|
||||
find "$HOME" -maxdepth 1 -mindepth 1 -type d ! -name "Library" 2>/dev/null | sed 's:/*$::'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
render_header() {
|
||||
local active=$1
|
||||
local out=""
|
||||
for i in "${!TABS[@]}"; do
|
||||
local name="${TABS[$i]}"
|
||||
if [ "$i" -eq "$active" ]; then
|
||||
out+="${CLR_ACTIVE}[▶ ${name}]${CLR_RESET} "
|
||||
else
|
||||
out+="${CLR_INACTIVE} ${name} ${CLR_RESET} "
|
||||
fi
|
||||
done
|
||||
printf "%s\n" "$out"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Tab Navigation Loop
|
||||
# ---------------------------------------------------------
|
||||
selected=""
|
||||
while true; do
|
||||
fzf_output=$( { render_header "$ACTIVE_TAB"; get_items_for_tab "$ACTIVE_TAB" | grep -v '^$'; } | fzf \
|
||||
--ansi \
|
||||
--header-lines=1 \
|
||||
--expect=tab,btab \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--margin=15 \
|
||||
--padding=0 \
|
||||
--height=100% \
|
||||
--prompt=" " \
|
||||
--color="bg:#090E13,bg+:#22262D,fg:#c5c9c7,fg+:#ffffff" \
|
||||
--color="hl:#7fb4ca,hl+:#7fb4ca,prompt:#7fb4ca,pointer:#22262D" \
|
||||
--color="info:#5C6066,spinner:#5C6066,header:#5C6066,border:#2d3139" \
|
||||
--color="label:#7fb4ca" \
|
||||
--preview="$preview_cmd" \
|
||||
--preview-window="right:55%:border-left")
|
||||
|
||||
fzf_status=$?
|
||||
# Cancelled via Escape or Ctrl-C
|
||||
[[ $fzf_status -ne 0 && $fzf_status -ne 1 ]] && exit 0
|
||||
|
||||
key=$(echo "$fzf_output" | head -n 1)
|
||||
selection=$(echo "$fzf_output" | tail -n +2)
|
||||
|
||||
if [ "$key" = "tab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB + 1) % TOTAL ))
|
||||
elif [ "$key" = "btab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB - 1 + TOTAL) % TOTAL ))
|
||||
else
|
||||
selected="$selection"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -z "$selected" ]] && exit 0
|
||||
|
||||
# Strip trailing slash if present
|
||||
selected="${selected%/}"
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Handle Session Creation / Switching
|
||||
# ---------------------------------------------------------
|
||||
if [[ "$selected" == "[Create Blank Session in ~]" ]]; then
|
||||
idx=1
|
||||
while tmux has-session -t "=blank-$idx" 2>/dev/null; do
|
||||
((idx++))
|
||||
done
|
||||
session_name="blank-$idx"
|
||||
tmux new-session -d -s "$session_name" -c "$HOME"
|
||||
elif [[ -d "$selected" ]]; then
|
||||
if [[ $selected == "$HOME" ]]; then
|
||||
session_name=home
|
||||
else
|
||||
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
|
||||
session_name="$selected"
|
||||
fi
|
||||
if ! tmux has-session -t "=$session_name" 2>/dev/null; then
|
||||
tmux new-session -d -s "$session_name" -c "$selected"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
exec tmux attach-session -t "$session_name"
|
||||
if [[ -z ${TMUX:-} ]]; then
|
||||
exec tmux attach-session -t "$session_name"
|
||||
else
|
||||
tmux switch-client -t "$session_name"
|
||||
tmux switch-client -t "$session_name"
|
||||
fi
|
||||
|
||||
Executable
+188
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Ensure Homebrew and standard paths are accessible inside fzf's preview subshell
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
|
||||
|
||||
# Tabs definition
|
||||
TABS=("All" "Projects" "Dotfiles" "Blank Session")
|
||||
TOTAL=${#TABS[@]}
|
||||
ACTIVE_TAB=0
|
||||
|
||||
# Terminal Palette Colors for the Tab Header (Ghostty palette 12 and 8)
|
||||
CLR_ACTIVE=$(printf '\033[1;38;5;12m')
|
||||
CLR_INACTIVE=$(printf '\033[38;5;8m')
|
||||
CLR_RESET=$(printf '\033[0m')
|
||||
|
||||
# Dynamic Previewer (Restored exact working structure from your original script)
|
||||
preview_cmd='
|
||||
if [ "{}" = "[Create Blank Session in ~]" ]; then
|
||||
echo "Will spawn an empty session in ~/"
|
||||
elif [ -d {} ]; then
|
||||
if command -v eza >/dev/null 2>&1; then
|
||||
eza --tree --level=2 --icons --color=always --git-ignore -I "node_modules|build|dist|target|.cache" {}
|
||||
elif command -v tree >/dev/null 2>&1; then
|
||||
tree -C -L 2 --gitignore -I "node_modules|build|dist|target|.cache" {}
|
||||
else
|
||||
ls -la --color=always {}
|
||||
fi
|
||||
else
|
||||
tmux list-windows -t {} 2>/dev/null || echo "Session or path: {}"
|
||||
fi'
|
||||
|
||||
get_projects() {
|
||||
if command -v fd &>/dev/null; then
|
||||
[ -d "$HOME/Projects" ] && fd --type d --max-depth 2 . "$HOME/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects_Testing" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects_Testing" 2>/dev/null | sed 's:/*$::'
|
||||
else
|
||||
if [ -d "$HOME/Projects" ]; then
|
||||
find "$HOME/Projects" -mindepth 1 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects" ]; then
|
||||
find "$HOME/personal/Projects" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects_Testing" ]; then
|
||||
find "$HOME/personal/Projects_Testing" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_dotfiles() {
|
||||
if command -v fd &>/dev/null; then
|
||||
# 1. Standard ~/.config/<app>
|
||||
[ -d "$HOME/.config" ] && fd --type d --max-depth 1 . "$HOME/.config" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# 2. ~/dotfiles direct packages (e.g. ~/dotfiles/nvim, ~/dotfiles/tmux)
|
||||
# and stow structures (e.g. ~/dotfiles/nvim/.config/nvim or ~/dotfiles/.config/*)
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Top-level dotfile modules (depth 1)
|
||||
fd --type d --max-depth 1 . "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# Unhide and drill down specifically into any .config folders inside dotfiles
|
||||
fd --type d --hidden --no-ignore --max-depth 4 \
|
||||
--full-path '.*/\.config/[^/]+$' "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
else
|
||||
# Fallback using find
|
||||
if [ -d "$HOME/.config" ]; then
|
||||
find "$HOME/.config" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Dotfiles packages + nested .config targets up to 4 levels deep
|
||||
find "$HOME/dotfiles" -mindepth 1 -maxdepth 4 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | grep -E '(dotfiles/[^/]+$|/\.config/[^/]+$)' | sed 's:/*$::'
|
||||
fi
|
||||
fi | sort -u
|
||||
}
|
||||
|
||||
get_items_for_tab() {
|
||||
local tab_idx=$1
|
||||
case "$tab_idx" in
|
||||
1) # Projects only
|
||||
get_projects
|
||||
;;
|
||||
2) # Dotfiles only
|
||||
get_dotfiles
|
||||
;;
|
||||
3) # Blank Session
|
||||
echo "[Create Blank Session in ~]"
|
||||
;;
|
||||
*) # All: tmux sessions + projects + dotfiles + top-level home dirs
|
||||
tmux list-sessions -F "#S" 2>/dev/null
|
||||
get_projects
|
||||
get_dotfiles
|
||||
find "$HOME" -maxdepth 1 -mindepth 1 -type d ! -name "Library" 2>/dev/null | sed 's:/*$::'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
render_header() {
|
||||
local active=$1
|
||||
local out=""
|
||||
for i in "${!TABS[@]}"; do
|
||||
local name="${TABS[$i]}"
|
||||
if [ "$i" -eq "$active" ]; then
|
||||
out+="${CLR_ACTIVE}[▶ ${name}]${CLR_RESET} "
|
||||
else
|
||||
out+="${CLR_INACTIVE} ${name} ${CLR_RESET} "
|
||||
fi
|
||||
done
|
||||
printf "%s\n" "$out"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Tab Navigation Loop
|
||||
# ---------------------------------------------------------
|
||||
selected=""
|
||||
while true; do
|
||||
fzf_output=$( { render_header "$ACTIVE_TAB"; get_items_for_tab "$ACTIVE_TAB" | grep -v '^$'; } | fzf \
|
||||
--ansi \
|
||||
--header-lines=1 \
|
||||
--expect=tab,btab \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--margin=15 \
|
||||
--padding=0 \
|
||||
--height=100% \
|
||||
--prompt=" " \
|
||||
--color="bg:#090E13,bg+:#22262D,fg:#c5c9c7,fg+:#ffffff" \
|
||||
--color="hl:#7fb4ca,hl+:#7fb4ca,prompt:#7fb4ca,pointer:#22262D" \
|
||||
--color="info:#5C6066,spinner:#5C6066,header:#5C6066,border:#2d3139" \
|
||||
--color="label:#7fb4ca" \
|
||||
--preview="$preview_cmd" \
|
||||
--preview-window="right:55%:border-left")
|
||||
|
||||
fzf_status=$?
|
||||
# Cancelled via Escape or Ctrl-C
|
||||
[[ $fzf_status -ne 0 && $fzf_status -ne 1 ]] && exit 0
|
||||
|
||||
key=$(echo "$fzf_output" | head -n 1)
|
||||
selection=$(echo "$fzf_output" | tail -n +2)
|
||||
|
||||
if [ "$key" = "tab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB + 1) % TOTAL ))
|
||||
elif [ "$key" = "btab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB - 1 + TOTAL) % TOTAL ))
|
||||
else
|
||||
selected="$selection"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -z "$selected" ]] && exit 0
|
||||
|
||||
# Strip trailing slash if present
|
||||
selected="${selected%/}"
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Handle Session Creation / Switching
|
||||
# ---------------------------------------------------------
|
||||
if [[ "$selected" == "[Create Blank Session in ~]" ]]; then
|
||||
idx=1
|
||||
while tmux has-session -t "=blank-$idx" 2>/dev/null; do
|
||||
((idx++))
|
||||
done
|
||||
session_name="blank-$idx"
|
||||
tmux new-session -d -s "$session_name" -c "$HOME"
|
||||
elif [[ -d "$selected" ]]; then
|
||||
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
|
||||
session_name="$selected"
|
||||
fi
|
||||
|
||||
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