I often start a long running command and then realise I didn't start tmux.
probably npm install. Or a long awaited apt update.
I remembered reading something before on "move current command to tmux".
Went looking for that and found this SO
ctrl z # pause the process
bg # resume it in the background
jobs -l
# get process number
disown PROCESS_NAME
tmux
reptyr pid
cannot test right now as I don't have repytr installed. More importanntly, I don't
want to remember that much. That's a lot of things to type every time.
Why not start tmux automatically when shell starts!
From SO
# warning this <mark>may</mark> now corrupt your Ubuntu logins
if [[ ! $TERM =~ screen ]]; then
exec tmux
fi
BUT, as they go on with:
However, there is a very small risk this can make bash behave in a way that other programs don't expect, since running bash can possibly cause it to turn into a tmux process, so it might be better to modify how you start your terminal emulator.
This does not sound good. So instead I will start auto-start tmux when launching the terminal emulator.
From Medium post
Navigate to “Preferences > Profiles > PROFILE >Command > Send text at start” and set it to:
tmux ls && read tmux_session && tmux attach -t ${tmux_session:-default} || tmux new -s ${tmux_session:-default}
This caused an error
Failed to execute tmux
PATH=/usr/bin:/bin:/usr/sbin:/sbin