Isso aqui é o que eu tenho agora, testei e está funcionando:
#!/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;
Coloque isso em algum arquivo, torne-o executável e execute-o em .profile
(ou .bash_profile
). A intenção original era usar este script diretamente como seu shell de login, mas que atualmente é instável (funciona para minha conta, não funciona para uma nova conta de teste fictícia).