Skip to content

Instantly share code, notes, and snippets.

@Tangent128
Created November 23, 2014 19:41
Show Gist options
  • Save Tangent128/90a21fbebb9a24f00c7c to your computer and use it in GitHub Desktop.
Save Tangent128/90a21fbebb9a24f00c7c to your computer and use it in GitHub Desktop.
Manage dtach sessions via a simplistic menu. (dtach is like screen, but much simpler for the 90% use case.)
#!/bin/sh
# Provides a listing of your ~/.dtach folder to
# remind you what sessions exist; enter the name
# of a session (sans .dtach suffix) to reconnect,
# or a new name to start a new session.
# If an executable exists in ~/.dtach with the same
# name as the session plus an .auto suffix, it will
# be run instead of the shell.
D=~/.dtach
cd ~
echo "Current Sessions:"
echo "================="
ls -la --color "$D"
echo ""
echo -n "Choice: "
read session
SOCKET=$D/$session.dtach
AUTO=$D/$session.auto
test -e "$AUTO" || AUTO=$SHELL
exec dtach -A "$SOCKET" "$AUTO"
#!/bin/sh
# Invoke menu.sh in a loop
# My usecase: SSHing into home computer via ConnectBot
# on my tablet. ConnectBot only supports one connection
# to a host at a time, and wifi can always drop. Setting
# ConnectBot to run this on every connection lets me easily
# multiplex shells and recover from connection drops.
# I have a vnc.auto script to launch x11vnc, since
# I remote-desktop a lot.
D=~/.dtach
cd "$D"
while true; do
./menu.sh
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment