initial commit
This commit is contained in:
commit
9cd3e9f94e
4 changed files with 148 additions and 0 deletions
46
bk-tmux-dmenu
Executable file
46
bk-tmux-dmenu
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
# dmenu-driven tmux session switcher/attacher for dwm + st
|
||||
# deps: tmux, dmenu, st
|
||||
|
||||
set -eu
|
||||
|
||||
# List available sessions (quiet if no server/sessions)
|
||||
sessions="$(tmux list-sessions -F '#S' 2>/dev/null || true)"
|
||||
[ -n "${sessions}" ] || exit 0
|
||||
|
||||
# prefer rofi, fall back to dmenu
|
||||
pick_session() {
|
||||
if command -v rofi >/dev/null 2>&1; then
|
||||
rofi -dmenu -i -p 'tmux sessions:' -lines 10 \
|
||||
-kb-row-down "Down,Control+n,j" -kb-row-up "Up,Control+p,k"
|
||||
else
|
||||
dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'
|
||||
fi
|
||||
}
|
||||
chosen="$(printf '%s\n' "$sessions" | pick_session)"
|
||||
|
||||
# DMENU="dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'"
|
||||
# chosen="$(printf '%s\n' "$sessions" | eval "$DMENU")"
|
||||
|
||||
[ -n "$chosen" ] || exit 0
|
||||
|
||||
# 1) If this script is run from inside a tmux client, switch in-place.
|
||||
if [ "${TMUX-}" ]; then
|
||||
exec tmux switch-client -t "${chosen}"
|
||||
fi
|
||||
|
||||
# 2) If any st-based tmux client exists, switch that client to the chosen session.
|
||||
# (client_termname is usually 'st-256color' for st)
|
||||
client_tty="$(
|
||||
tmux list-clients -F '#{client_tty} #{client_termname}' 2>/dev/null \
|
||||
| awk '$2 ~ /^st/ { print $1; exit }' || true
|
||||
)"
|
||||
|
||||
if [ -n "${client_tty}" ]; then
|
||||
# switch that client to the chosen session
|
||||
tmux switch-client -c "${client_tty}" -t "${chosen}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3) Fallback: launch a new st and attach.
|
||||
exec st -e tmux attach -t "${chosen}"
|
||||
27
configs-dmenu.sh
Executable file
27
configs-dmenu.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Grab only directories inside ~/debian-dotfiles
|
||||
configs="$(ls -1d ~/debian-dotfiles/*/ 2>/dev/null | xargs -n1 basename)"
|
||||
[ -n "$configs" ] || exit 0
|
||||
|
||||
chosen="$(printf '%s\n' $configs | dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'configs:')"
|
||||
[ -n "$chosen" ] || exit 0
|
||||
|
||||
dir="$HOME/debian-dotfiles/$chosen"
|
||||
|
||||
# If inside tmux, just switch session (create it if missing)
|
||||
if [ "${TMUX-}" ]; then
|
||||
if tmux has-session -t "$chosen" 2>/dev/null; then
|
||||
exec tmux switch-client -t "$chosen"
|
||||
else
|
||||
exec tmux new-session -s "$chosen" -c "$dir" "nvim ."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Outside tmux: open st, create or attach session running nvim
|
||||
if tmux has-session -t "$chosen" 2>/dev/null; then
|
||||
exec st -e tmux attach -t "$chosen"
|
||||
else
|
||||
exec st -e tmux new-session -s "$chosen" -c "$dir" "nvim ."
|
||||
fi
|
||||
37
tmux-dmenu.sh
Executable file
37
tmux-dmenu.sh
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
sessions="$(tmux list-sessions -F '#S' 2>/dev/null || true)"
|
||||
[ -n "${sessions}" ] || exit 0
|
||||
|
||||
rofi_pick_session() {
|
||||
if command -v rofi >/dev/null 2>&1; then
|
||||
rofi -dmenu -i -p 'tmux sessions:' -lines 10 \
|
||||
-kb-row-down "Down,Control+n,j" -kb-row-up "Up,Control+p,k"
|
||||
else
|
||||
dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'
|
||||
fi
|
||||
}
|
||||
dmenu_pick_session() {
|
||||
dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'
|
||||
}
|
||||
chosen="$(printf '%s\n' "$sessions" | dmenu_pick_session)"
|
||||
|
||||
[ -n "$chosen" ] || exit 0
|
||||
|
||||
if [ "${TMUX-}" ]; then
|
||||
exec tmux switch-client -t "${chosen}"
|
||||
fi
|
||||
|
||||
client_tty="$(
|
||||
tmux list-clients -F '#{client_tty} #{client_termname}' 2>/dev/null \
|
||||
| awk '$2 ~ /^st/ { print $1; exit }' || true
|
||||
)"
|
||||
|
||||
if [ -n "${client_tty}" ]; then
|
||||
# switch that client to the chosen session
|
||||
tmux switch-client -c "${client_tty}" -t "${chosen}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec st -e tmux attach -t "${chosen}"
|
||||
38
tmux-rofi.sh
Executable file
38
tmux-rofi.sh
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
sessions="$(tmux list-sessions -F '#S' 2>/dev/null || true)"
|
||||
[ -n "${sessions}" ] || exit 0
|
||||
|
||||
rofi_pick_session() {
|
||||
if command -v rofi >/dev/null 2>&1; then
|
||||
rofi -dmenu -i -p 'tmux sessions:' -lines 10 \
|
||||
-kb-row-down "Down,Control+n,j" -kb-row-up "Up,Control+p,k"
|
||||
else
|
||||
dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'
|
||||
fi
|
||||
}
|
||||
dmenu_pick_session() {
|
||||
dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'
|
||||
}
|
||||
chosen="$(printf '%s\n' "$sessions" | rofi_pick_session)"
|
||||
|
||||
[ -n "$chosen" ] || exit 0
|
||||
|
||||
if [ "${TMUX-}" ]; then
|
||||
exec tmux switch-client -t "${chosen}"
|
||||
fi
|
||||
|
||||
client_tty="$(
|
||||
tmux list-clients -F '#{client_tty} #{client_termname}' 2>/dev/null \
|
||||
| awk '$2 ~ /^st/ { print $1; exit }' || true
|
||||
)"
|
||||
|
||||
if [ -n "${client_tty}" ]; then
|
||||
# switch that client to the chosen session
|
||||
tmux switch-client -c "${client_tty}" -t "${chosen}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exec st -e tmux attach -t "${chosen}"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue