Jul72010
dtach
Filed under: screen dtach tmuxI'm not a big fan of screen or tmux because they have a lot of features I don't use and get in the way some things I actually do use (namely requiring bizarre key chords for scrollback and copy/paste). Instead I prefer dtach.
However, dtach requires passing too many arguments for my taste and level of laziness. Here's my shell function (placed in ~/.bashrc) for simplifying my dtach session management. It's nothing special but just one of those little things that makes daily life a bit simpler:
dtach () {
case "$1" in
-ls)
# ls -1A ~/.dtach/
ls -lrt1A ~/.dtach/ | awk '{print $9, "--", $6, $7, $8}'
;;
*)
name=$*
if [ "$name" == "" ]; then name="default"; fi
mkdir -p ~/.dtach/
/usr/bin/dtach -A ~/.dtach/"$name" -z /bin/bash
;;
esac
}
Now I can arbitrarily name my sessions, "dtach -ls" shows me a list of sessions, and plain old "dtach" starts or attaches to the "default" session.






