Settings

Theme

My Development Environment, Part 1: GNU Screen

blog.anassina.com

31 points by BigCanOfTuna 15 years ago · 14 comments

Reader

barrkel 15 years ago

In ~/.screenrc:

    altscreen on
enables alternate screen, which is disabled by default, but is normally enabled in most terminals. It's the thing which prevents less, vi, etc. from clobbering the screen contents and leaving their gunk behind after exiting.

(A Google search seems to indicate that some people dislike this feature, but I found screen unusable until I discovered this option.)

  • jazzychad 15 years ago

    Thank you! I have been using screen for 2 years and wanted to know how to fix this, but never knew what phrase to google to see if there was a fix. Every time I would background emacs (^z) it would clobber all of my previous console output so I would have to re-grep things, for example.

    In return I give you my favorite screen hack that displays the available RAM on the server every 30 seconds in the caption:

    In ~/.screenrc

        backtick 2 30 30 $HOME/.screenrc.bt.2
        caption always "%{gk}plab001 %?%{wk}%-Lw%?%{yK}%n*%f %t%?(%u)%?%?%{wk}%+Lw%? %=%{yk}%2` %{gk}%c %{yk}%d/%M/%Y"
    
    in ~/.screenrc.bt.2

        free -m | xargs | awk '{print $17 "MB"}'
    
    The caption string above also prints the current window titles and the time/date, so this is also useful for keeping ssh sessions open indefinitely since there is activity at least once a minute when the time updates.
swah 15 years ago

Prediction: part 2 is vim and part 3 is about his pimped up bash prompt that shows the current Git branch. Or something like that.

zzzmarcus 15 years ago

Here's the mandatory "if you're using GNU Screen check out tmux" comment.

Really though, check it out. The main thing I like better in tmux is that it does both horizontal and vertical split terminal windows in a way that seems much more intuitive to me than screen.

alinajaf 15 years ago

This is absolutely uncanny. I've just started writing a similar blog post thread about my dev environment, and its similar to yours (i.e. screen (I'm moving to tmux though), vim, bash, etc.).

  • dylanz 15 years ago

    +1 for tmux. I switched from screen, and have been very happy with it.

    • skar 15 years ago

      Does tmux support tab/windows re-ordering like browser do with tabs? I miss it in screen.

daleharvey 15 years ago

I really wish there was a nice way to run nested screens, I like having screen run locally, but I always want to be able to easily attach and detach from screen sessions on my server. I know I can escape them with keyboard shortcuts, but its confusing and I have never managed to get used to it, so I generally do server screen sessions in a seperate terminal

  • skar 15 years ago

    I use backtick(`) as the meta key and that works till I'm 2 levels nested. I can do `+p or ``+p to go to the next screen window at the 1st or 2nd level this way. However, 3rd level doesn't work, unless I set a different meta key on the 3rd machine. Having some shortcut to select the current nesting level would be awesome :)

  • marktucker 15 years ago

    I just use a different prefix on the remote machine. Would that help?

adambyrtek 15 years ago

Thanks for a solution to the problem of missing bright/bold colors that I found in your .screenrc. This issue hadn't bothered me much, otherwise I'd have researched it before, but it's nice to have it fixed anyway.

For reference, the option is question is

   attrcolor b ".I"
joealba 15 years ago

Great post. Jon Druse created a Ruby gem recently that does something very similar -- but more project-oriented rather than global ~/.screenrc:

http://github.com/jondruse/screeninator

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection