Based upon my days and days of researching this, I may be seeking the impossible.
I have my
.bashrcnicely configured to either spawn a new
tmuxon connect, or if one exists, attach to it.
I always hit Ctrl+D to exit a shell session. It's burned into my muscle memory. Unlearning it after thirty years of systems administration is also asking the impossible.
I want to be able to detach from
tmuxusing just Ctrl+D, rather than having it kill my shell.
My imperfect approach
I can bind Ctrl+D to
The problem is that I also have
emacs key-bindings burned into my muscle memory, so when I start editing a command line, I'll hit Ctrl+D to employ the GNU readline 'delete char under cursor'. Instead, the
tmux binding swallows the Ctrl+D, so I'm immediately detached. Same thing if I'm editing in
Another flawed approach
GNU readline will take the EOF on an empty line, and then exit the shell. So I've tried trapping exit in
trap "~/tmuxexit" EXIT
with the contents of
tmux detach-client -s main
Which initially seemed like it worked, as hitting Ctrl+D on an empty line would report:
[detached (from session main)]
tmux ls reports
no server running on […].