Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution for using iTerm2 'shell integration' and screen (over ssh)

Tags:

shell

iterm2

So when i ssh into a remote server i use 'screen -R myscreen' to prevent any running scripts/processes from being interrupted when the ssh connection disconnects, for whatever reason (bad wifi, etc).

However, when starting screen, iTerm2's shell integration doesn't work anymore.

Is there any workaround for this?

like image 459
Motsel Avatar asked Nov 12 '16 18:11

Motsel


1 Answers

fyi the solution i found is:

instead of 'screen' use 'tmux', by executing tmux -CC to open a tmux session (and using tmux -CC attach to re-attach after a disconnection.) This is also described here.

To make iTerm2 shell integration work in tmux, modify ~/.iterm2_shell_integration.bash and remove this part of the first line: "$TERM" != screen

So this

if [[ "$TERM" != screen && "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* ]]; then

becomes:

if [[ "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* ]]; then

like image 93
Motsel Avatar answered Nov 15 '22 10:11

Motsel