103

After modified screenrc, how to see the changes without restarting screen?

user9517
  • 114,104
  • 20
  • 206
  • 289
garconcn
  • 2,378
  • 7
  • 33
  • 46

4 Answers4

123

You could try Ctrl-a : source ~/.screenrc.

djd
  • 103
  • 3
Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
  • 7
    Sourcing the file should work. Detaching and reattaching will not. – Zed Oct 25 '10 at 19:35
  • 1
    @Zed: But it will re-apply the termcap/terminfo stuff which will not happen when you use `source`. – Dennis Williamson Oct 25 '10 at 19:36
  • @Dennis, I tried detaching and reattaching and it didn't work, hence I came to ask this question. Also, using source can open all windows from .screenrc, however it doesn't refresh the session, but creating duplicate windows in one session. Thanks. – garconcn Oct 25 '10 at 22:17
  • 3
    Using "source" is the correct (and only) way to have screen re-read the .screenrc in a running session. Yes, this means it will re-run any commands you have inside it, including commands that create windows or layouts. You could edit the file to comment out the commands that create thew new windows/layouts; source the file; and then un-comment those lines. Of course, if it's the window creation you're wanting to test, you don't have much choice here... – James Polley Oct 25 '10 at 22:46
  • @James, comment the opened window and source the screenrc file works fine for me. This solved my problem. Thank you. – garconcn Oct 25 '10 at 23:28
  • 10
    @garconcn: If this is something you might do frequently, put that stuff (non-screen-creation instructions) in a second file and `source` it from `.screenrc` (which will contain your screen creation instructions) for regular startup and when you need to `source` it again after `screen` has already started, just do "ctrl-a : source secondary-file" to skip the screen-creation stuff. – Dennis Williamson Oct 25 '10 at 23:53
  • @Dennis, yes, I need to refresh the screenrc very frequently, I will consider doing this. thanks for the tips. – garconcn Oct 26 '10 at 00:36
  • It said `permission denied` to ~/.screenrc when I have `.screenrc` as a symlink. Does any body face it? – FelikZ May 22 '15 at 12:20
  • @FelikZ:As a symlink to what? What are the permissions and ownership of that target file? – Dennis Williamson May 22 '15 at 12:47
  • @DennisWilliamson this is symlink to a file stored in other mounted volume. Permissions are full, so I think that screen unable to handle symlinks at all. – FelikZ May 22 '15 at 14:17
  • @FelikZ: Permissions on symlinks will be 777, what are the permissions and ownership on the target of the symlink? – Dennis Williamson May 22 '15 at 14:59
38

I tried the option mentioned here - Ctrl-a : source ~/.screenrc and it didn't work for me.

This is what worked for me - Ctrl-a : source $HOME/.screenrc

holydevil
  • 491
  • 4
  • 4
21

I have this in my .screenrc file:

bind R eval "source $HOME/.screenrc" "echo '.screenrc reloaded!'"

Which causes screen to reload the .screenrc file when Ctrl-AShift-R is pressed.

Of course, this only works if you've already got the line in your .screenrc file! To 'bootstrap' this sortcut on an existing screen session, add the line above line to your .screenrc file and then follow @Dennis Williamson's answer. After that, you'll be able to use the new keyboard shortcut.

ltn100
  • 311
  • 3
  • 4
  • 1
    This is brilliant. Is there anything that can be added to the command to stop the reload from opening additional windows? I have .screenrc configured to automatically start two shell windows on startup, so reloading .screenrc continually opens two new windows. – Jesse Schoff Nov 11 '19 at 16:19
0

The Ctrl-a : source ~/.screenrc (or variants) mentioned by others are indeed "the way to go".

But if you are using a frontend for screen (e.g. byobu), a bit of extra work is needed:

  • Open a new terminal
  • Attach the screen here too: screen -x
  • Run Ctrl-a : source ~/.screenrc (like everyone suggested)
  • Detach the screen: Ctrl-a d
  • Stop the new terminal: exit

The settings are now applied everywhere this screen is attached, no matter what frontend you are using. (Even when using no frontend at all)

Garo
  • 161
  • 1
  • 6