This here is what I have now, I tested it and it's working:
#!/bin/sh if [[ -n "$TMUX" ]]; then echo "CRITICAL - ALREADY INSIDE TMUX!" echo "Dropping you into /bin/sh..." /bin/sh -i echo "Exiting with /bin/sh exit code..." exit $? fi SESSION="$(whoami)-$(basename $(tty))"; # Start tmux server if it isn't already running echo "Starting tmux server..." /usr/bin/tmux start-server echo "tmux server started." # Create the session if it doesn't exist echo "Checking for tty session..." if /usr/bin/tmux has-session -t "$SESSION" 2> /dev/null; then echo "tty session already present, will spawn new window later." else echo "Creating tty session..." /usr/bin/tmux new-session -d -s "$SESSION" -n "$SESSION-dummywindow" /bin/bash echo "tty session created." fi # Create a new session that shares the windows of the existing (or new) session echo "Starting fbterm and tmux..." ( sleep 1; /usr/bin/tmux kill-window -t "$SESSION-dummywindow" ) & /usr/bin/fbterm -- /usr/bin/tmux new-session -t "$SESSION" \; new-window /bin/bash;
Put this into some file, make it executable, then run it from your .profile
(or .bash_profile
). The original intention was to directly use this script as your login shell, but that is currently unstable (works for my account, doesn't work for a newly-created dummy test account).