I prefer to use tmux rather than the default linux virtual console (i.e. what agetty
uses), so I put this in ~/.bashrc
so that tmux runs automatically when I log in to a TTY:
if [[ "$(tty)" == /dev/tty* ]]; then
tmux -u
fi
At first it seems like this works: tmux runs as soon as I login. However, when I exit tmux, tmux immediately runs a second time! Here is the complete behavior:
- ctrl+alt+f2
- Log in
- Default prompt briefly visible before tmux runs
- I'm in
tmux
- ctrl+d
- The text
[exited]
briefly flashes, and then I'm back intmux
again - ctrl+d
- Back in default terminal without
tmux
- ctrl+d
- Now I'm completely logged out
I can't track this down - I've tried logging all sorts of things, setting environment variables, looking at $SHLVL
. It actually looks like .bashrc
gets run like 7 times each time I log in!
I don't normally use tmux from within X (I just use Konsole), but I tried setting bashrc to have tmux run for all non-tmux sessions, and this double behavior did not happen in Konsole.
I'm using:
- Arch Linux (4.8.13-1)
- agetty
- tmux
- Bashish
- full
~/.bashrc
and other configs (no~/.bash_profile
file): https://gist.github.com/tobek/c8038c207f318528c3157b4a402aa2d9 (I tried removing bashish stuff, but behavior remained)
What on could be causing this?
agetty
does not produce virtual terminals. It uses terminal devices.