~/.nf: bind X run-shell "~/.scripts/tmux-kill-session. Session_to_switch="$(tmux list-sessions | sed -n '/(attached)/!s/.*//p' | head -n 1)" Session_to_kill="$(tmux list-sessions | sed -n '/(attached)/s/.*//p')" ~/.scripts/tmux-kill-session.sh: #!/usr/bin/env bash If you are not currently running a tmux session (or not currently in tmux session) you attach by running tmux attach -t n (where -t stands for target session and n for that session number). Since I couldn't find anything I wrote a script that switches to the first other active session before killing the current one and I bound it to Leader X for quick access. I needed exactly this, as my workflow includes short-lived tmux sessions to jump between code projects that are killed at the end. Now tmux will not detach (close) when the session is destroyed, instead it will go to any other active session. To achieve this, use 'nohup' and 'disown' commands, which are usually builtin commands on most shells, i.e. Instead what you can do is ensure the command you were running continues to run after the disconnect. If you do not need this feature, you can use terminator instead of tmux. No, you cant recover a shell after a disconnection. In your ~/nf: set-option -g detach-on-destroy off For most people who use tmux, they usually close the terminal window instead of the tmux window in order to keep the process (ssh-client for example) running.And then, you can attach the origin tmux session in another terminal. Session tmux ls, list all sessions tmux detach (or prefix + d), detach currently session tmux kill-session -t mysession, kill existing session named.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |