cleaned up scripts and added repos script
This commit is contained in:
parent
9cd3e9f94e
commit
cbebbd136b
4 changed files with 85 additions and 12 deletions
|
|
@ -5,12 +5,12 @@ set -eu
|
|||
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:')"
|
||||
chosen="$(printf '%s\n' $configs | dmenu -i -c -vi -bw 3 -W 800 -l 30 -h 40 -F -fn "JetBrainsMono Nerd Font:size=16" -p 'configs:')"
|
||||
[ -n "$chosen" ] || exit 0
|
||||
|
||||
dir="$HOME/debian-dotfiles/$chosen"
|
||||
|
||||
# If inside tmux, just switch session (create it if missing)
|
||||
# If inside tmux: switch or create
|
||||
if [ "${TMUX-}" ]; then
|
||||
if tmux has-session -t "$chosen" 2>/dev/null; then
|
||||
exec tmux switch-client -t "$chosen"
|
||||
|
|
@ -19,9 +19,25 @@ if [ "${TMUX-}" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
# Outside tmux: open st, create or attach session running nvim
|
||||
# If there's an st client running tmux, switch that instead of opening a new one
|
||||
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
|
||||
if tmux has-session -t "$chosen" 2>/dev/null; then
|
||||
tmux switch-client -c "${client_tty}" -t "$chosen"
|
||||
else
|
||||
tmux new-session -s "$chosen" -c "$dir" "nvim ."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Otherwise, spawn a new st terminal
|
||||
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
|
||||
|
||||
|
|
|
|||
44
repos-dmenu.sh
Executable file
44
repos-dmenu.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Grab only directories inside ~/debian-dotfiles
|
||||
configs="$(ls -1d ~/tonybtw/repos/*/ 2>/dev/null | xargs -n1 basename)"
|
||||
[ -n "$configs" ] || exit 0
|
||||
|
||||
chosen="$(printf '%s\n' $configs | dmenu -i -c -vi -bw 3 -W 600 -l 30 -h 40 -F -fn "JetBrainsMono Nerd Font:size=16" -p 'repos:')"
|
||||
[ -n "$chosen" ] || exit 0
|
||||
|
||||
dir="$HOME/tonybtw/repos/$chosen"
|
||||
|
||||
# If inside tmux: switch or create
|
||||
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
|
||||
|
||||
# If there's an st client running tmux, switch that instead of opening a new one
|
||||
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
|
||||
if tmux has-session -t "$chosen" 2>/dev/null; then
|
||||
tmux switch-client -c "${client_tty}" -t "$chosen"
|
||||
else
|
||||
tmux new-session -s "$chosen" -c "$dir" "nvim ."
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Otherwise, spawn a new st terminal
|
||||
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
|
||||
|
||||
|
||||
9
temp.txt
Normal file
9
temp.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
one
|
||||
two
|
||||
three
|
||||
four
|
||||
five
|
||||
asdflkj
|
||||
asojii
|
||||
iiidd
|
||||
iqqq
|
||||
|
|
@ -4,16 +4,20 @@ 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:'
|
||||
# dmenu -i \
|
||||
# -c \
|
||||
# -vi \
|
||||
# -bw 3 \
|
||||
# -l 15 \
|
||||
# -h 40 \
|
||||
# -F \
|
||||
# -fn "JetBrainsMono Nerd Font:size=16" \
|
||||
# -p 'tmux sessions:'
|
||||
|
||||
dmenu -i -c -vi -bw 3 -W 800 -l 30 -h 40 -F -fn "JetBrainsMono Nerd Font:size=16" -p "tmux sessions:"
|
||||
|
||||
# dmenu -i -vi -c -bw 3 -l 10 -h 30 -F -p 'tmux sessions:'
|
||||
}
|
||||
chosen="$(printf '%s\n' "$sessions" | dmenu_pick_session)"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue