Unable to use Screen efficiently in Mac's Terminal

15,873

Solution 1

I usually solve the ctrl-a problem by setting my escape character to ctrl-z (which you generally don't need to use as often when you're running screen, since instead of backgrounding a process, you can just start up a new screen). In my .screenrc:

escape ^Zz

Scrolling using the touchpad just isn't going to work; screen is acting as a terminal emulator inside a terminal emulator, and it's just not possible for screen to switch the scrollback buffer in Terminal.app whenever you switch between screens. You're going to have to use screen's scrollback features. See this article for some tips on using screen's scrollback features.

Solution 2

In screenrc:

# Make xterm scrolling work properly with screen.
termcapinfo xterm-256color|xterm-color|xterm|xterms|xs|rxvt ti@:te@

Works for Terminal.app too.

Solution 3

Problem #3 might be solvable if you enable the alternate screen buffer. Use altscreen on in .screenrc

Solution 4

The default OS X Terminal app is weak. Get iTerm instead:

iTerm

If I'm not mistaken, iTerm solves all of these out of the box (my install is a couple years old, so I can't test that theory now).

Solution 5

Solution #1 which does not work

To be able to copy/paste in OSX put the following to your .screenrc

bind b eval "writebuf" "exec sh -c 'pbcopy < /tmp/screen-exchange'"

> Th[e] line - - sends that file to pbcopy - -.

The command is bound to C-a b (in my case, C-z b).

Solution #2 which works but is rather slow to type

Use Scrollback mode i.e. copy mode by

Coping

C-A [

Pasting

C-A ]

The solution is great, since it is the same in all terminal apps. It is similar to the clipboard as you use with your mouse.

Share:
15,873
Michal aka Miki
Author by

Michal aka Miki

Vacare.

Updated on June 03, 2022

Comments

  • Michal aka Miki
    Michal aka Miki almost 2 years

    The post summarizes problems in using Screen in Mac's terminal when you have the following in your .zshrc

    if [[ $STY = '' ]] then screen -xR; fi 
    
    1. Solution #1 is not working but Solution #2 works: Clipboard programs: pbcopy, pbpaste and xsel do not work at all
    2. Bug in Vim when used in Mac: Unable to have no scattered windows in Screen by .Xresources.
    3. Solved: Ctrl A stops working in terminal. This suggests me that Screen's keyboard bindings need to be changed slightly.
    4. Solved: The scrolling with touchpad does not work. By editing your .screenrc the scrollback works normally (including touchpad)
    5. Solved: Unable to have Dvorak keybindings for Screen for moving in Scrollback mod.
    6. How can you use pbcopy/pbpaste/xsel inside Screen?
  • Michal aka Miki
    Michal aka Miki about 15 years
    @staticsan: The next problem is to know how to do that. I did not find the result by Google.
  • Michal aka Miki
    Michal aka Miki about 15 years
    I do not know how you can use the command with pbcopy. I run unsuccessfully $ echo Masi | pbcopy C-z b.
  • Deva
    Deva about 15 years
    man screen will tell you where it will look for .screenrc. If it doesn't exist, create one. Incidentally, man screen is a wealth of information. I often find out something new every time I read it.
  • Jacob Gabrielson
    Jacob Gabrielson almost 15 years
    +1... I use ctrl-z too. It's really not a problem due to how infrequently you actually type ctrl-z relative to other stuff.
  • Michal aka Miki
    Michal aka Miki almost 15 years
    I put the line to my .zshrc. The command caused my Screen to duplicate screen buffers a lot (endless loop) such that I could access my terminal anymore. --- The loop starts again if I go to the buffer #0. --- It seeems that the code's purpose is to be used without Screen.
  • ACoolie
    ACoolie almost 15 years
    If you want it in your .zshrc then use this. if [[ $STY = '' ]] then env TERM=vt100 screen; fi
  • Alexandre L Telles
    Alexandre L Telles almost 14 years
    Wow! This is great! Work like a charm with Terminal.app.
  • jakev
    jakev almost 13 years
    Just what I was looking for!!
  • Glenn Maynard
    Glenn Maynard over 11 years
    Scrollback works just fine in Putty. It's Terminal that's broken, not screen.