added bmux

This commit is contained in:
Luxferre
2026-05-28 11:15:00 +03:00
parent 0b68fd237e
commit 88b0f52cc5
2 changed files with 24 additions and 0 deletions
+1
View File
@@ -8,3 +8,4 @@ For POSIX shell compatible scripts, see the [sh-goodies](https://codeberg.org/lu
* [YouStore](./ys): a way to securely store any set of files/directories inside a video
* [1DLife](./1dlife): Jon Millen's 1D Game of Life in pure Bash
* [bmux](./bmux): a simple, dmux-like session manager in Bash on top of just dtach
Executable
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# bmux: a simple terminal session switcher in Bash on top of dtach
# Created by Luxferre in 2026, released into the public domain
SDIR="$HOME/.dtsess"
SPFILE="$SDIR/.list"
mkdir -p "$SDIR"
touch "$SPFILE"
if [[ -z "$(ls -1 "$SDIR")" ]]; then
cat "$SPFILE" | while read -r sess; do
dtach -n "$SDIR/$sess" $SHELL
done
fi
PS3='Select a session: '
mapfile -t MENU < "$SPFILE"
while true; do
select sname in "${MENU[@]}" New Quit; do break; done
[[ "$sname" = 'Quit' ]] && printf '\033[0m' && break
[[ "$sname" = 'New' ]] && read -r -p 'New session name: ' sname
[[ -n "$sname" ]] && printf '\033[0m' && dtach -A "$SDIR/$sname" $SHELL
ls -1 "$SDIR" > "$SPFILE"
mapfile -t MENU < "$SPFILE"
done