-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try harder to attach to an existing tmux session
If in the course of an ssh/tmux session the tmux package is upgraded and the ssh connection broken, the next ssh attempt will encounter an error because of the tmux protocol version mismatch. The old tmux can be used to reattach by searching for the tmux process under /proc and using its reference to the old tmux executable. This change attempts to do that automatically if a first "tmux attach" attempt fails, but we can see that a previous session still exists.
- Loading branch information
Showing
2 changed files
with
29 additions
and
16 deletions.
There are no files selected for viewing
22 changes: 15 additions & 7 deletions
22
install_files/ansible-base/roles/common/files/bashrc_securedrop_additions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
# If not running interactively, do not do anything | ||
[[ $- != *i* ]] && return | ||
|
||
# Auto-launch tmux on login | ||
# https://wiki.archlinux.org/index.php/Tmux#Start_tmux_on_every_shell_login | ||
if which tmux >/dev/null 2>&1; then | ||
#if not inside a tmux session, and if no session is started, start a new session | ||
test -z "$TMUX" && (tmux attach || tmux new-session) | ||
fi | ||
which tmux >/dev/null 2>&1 || return | ||
|
||
function tmux_attach_via_proc() { | ||
pid=$(pgrep --newest tmux) | ||
if test -n "$pid" | ||
then | ||
/proc/$pid/exe attach | ||
fi | ||
return 1 | ||
} | ||
|
||
if test -z "$TMUX" | ||
then | ||
(tmux attach || tmux_attach_via_proc || tmux new-session) | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters