Jump to content

Screen: Difference between revisions

318 bytes removed ,  21 October 2011
→‎Reattaching Screen Automatically: talked about ~/.zlogin and ~/.bash_login
(→‎Reattaching Screen Automatically: talked about ~/.zlogin and ~/.bash_login)
Line 180: Line 180:
So, you've made your screen, configured it, and you happily type screen -dr '''every time''' you login to RedBrick. But wouldn't it be nice if whenever you login your screen would reattach '''itself'''??? It can be done :D
So, you've made your screen, configured it, and you happily type screen -dr '''every time''' you login to RedBrick. But wouldn't it be nice if whenever you login your screen would reattach '''itself'''??? It can be done :D


Simply use your favorite text editor to edit your ~/.zshrc (or ~/.[name_of_shell]rc) and paste the following code into it.
Simply use your favorite text editor to edit your ~/.zlogin if you're using zsh (if you haven't changed your login shell, this is the one you're using) or ~/.bash_login if you're using bash and put the following in it


  if [ -z "$STY" -a $TERM != "screen" ]
  screen -dr
then
    exec screen -dr
fi


That should do the job. However make sure to keep the spaces between the if statement, the brackets and the inside of the if statement (or it won't work).
That should do the job. It'll try to reattach a screen whenever you login on any redbrick server
 
In particular
 
$TERM != "screen"
 
is very important for that code segment to work, otherwise when connecting to another server (Carbon for instance), your shell will try to attach a screen session, fail and disconnect leaving you on the server you tried to connect from (Really quite annoying).


* Please note, if this in fact, does not work, you can edit it out by using winSCP and editing the file using it.
* Please note, if this in fact, does not work, you can edit it out by using winSCP and editing the file using it.
33

edits