7 ms·
GNU Screen - A Hacker's Ideal Terminal
- dryicerx 17y agoI don't think I can live without it anymore. There is no reason why you shouldn't use screen when ssh'ing in and working on remote machines, it will save you tons of time in case the connection goes down, plus allows your to keep a persistent working environment on remote boxes. ssh -t user@host screen -rx That will drop you immediately to a running screen on connect
- mooism2 17y agoMy remote `.bash_profile` ends screen -d -R logout On the rare occasions that I don't want to run under screen, I run `ssh -t user@host bash`.
- wglb 17y agoHighly valuable. See http://renesd.blogspot.com/2009/09/screen-for-ghetto-servers-and-startup.html http://renesd.blogspot.com/2009/09/screen-for-ghetto-servers... for more pointers.
- elbenshira 17y agoScreen uses C-a as its "command" character. Unfortunately, C-a means "go to start of line" in emacs and terminals. The solution? In your .screenrc file: escape ^Ww This will default C-w as the command character.
- cschep 17y agoIsn't C-w kill-region in emacs? I recently came up against this problem too, but what else to change it to .. ?
- deleted 17y ago[deleted]
- jherdman 17y agoI'm using C-z, but it's sort of an awkward key to use.
- sjs 17y agoChanging caps lock to control helps. Switching to dvorak helps even more. I kid.
- tomjen2 17y agoYou may be kidding, but you are right on both counts. Emacs is so much better when your control key is next to 'a'. Your hands prefer it when 'aoeu' is right under your left hand. You will prefer it when your colleagues can't figure out how to type on you computer.
- sjs 17y agoI was serious in that Ctrl-Z is easier to hit with dvorak, and with caps lock as control it becomes even easier, but I don't expect anyone to switch for that reason.
- sjs 17y agoYou could try C-o (open-line by default) or C-z (suspend/minimize by default). I use C-z as a personal command prefix. Emacs really puts those ctrl shortcuts to work, it's damn near impossible to find one that I don't use at least semi-regularly. edit: You could maybe try C-9 or use a symbol. I was only thinking in letters.
- btw0 17y agoI recently found BSD implementation -- tmux better than GNU screen.
- tome 17y agoBetter in what way?
- silentbicycle 17y agoFor starters, it has built-in dwm/XMonad-style layouts, while screen has taken ages to even get vertically split windows.
- pyre 17y agoIn general, one should probably know their way around GNU screen in addition to tmux just because you'll probably encounter it on more installations. Much in the same way that it's really to your benefit to know a bit about vi even if you are an Emacs user.
- silentbicycle 17y agoAgreed. They're both incredibly handy, and even if you only learn the common feature subset, it's still a huge win.
- JeremyChase 17y agoScreen is an amazingly useful tool. If you aren't using it or something like it, you are really making life more difficult for yourself. If you want something that isn't GNU or GPL'd, take a look at `tmux`.
- e1ven 17y agoI'm just curious- Why would you want to specifically avoid the GPL?
- steveklabnik 17y agoIf you look at it through the eyes of the GNU people, you're making an active choice any time you use software. By using GNU software, you're supporting the FSF and the GNU project. Some people would rather support the BSD license instead. Other people just don't care at all.
- pyre 17y agoThe same way there are people that want their entire software usage to be GPL/MIT/BSD/etc, there are people that want everything to be non-GPL. Unless you are going to be hacking on GNU Screen and feel the need to do something that the GPL forbids, there's really no reason to stop yourself from using a software package just because it's GPL-licensed.
- tedunangst 17y agoI think it's ironic that your argument is remarkably similar to "nothing stops you from using a closed source program unless you planned to start hacking on the source." Sometimes you don't know when you start using something what amount of hacking may be required.
- pyre 17y agoYes, but you can contribute to GPL-licensed projects. It's just specific things that you are limited in. We're talking orders of magnitude. 'closed-source and GPL' and 'MIT/BSD and GPL' aren't even in the same ballpark.
- tome 17y agoAll my rxvts run screen automatically. This means if I then leave my workstation and need to access one of the terminals remotely I can just duplicate it with screen -x. [Edited for clarity]
- hugothefrog 17y agoI've been using Screen for a number of years now, but I've recently come across Ubuntu's repackaging of it - https://help.ubuntu.com/9.04/serverguide/C/screen-profiles.html https://help.ubuntu.com/9.04/serverguide/C/screen-profiles.h.... This seems like a fantastic way to introduce screen to new users, who are probably intimidated by screen's default bare-bones config.
- Keyframe 17y agoI use screen for bazillion of years already. When doing stuff with django I like to C-a c to make a new screen, then C-a :resize 10 so that I have two screens on one (you can switch between them with C-a TAB). So in the smaller one I run server and in larger whatever I need to. Excellent when having two or more monitors with one being dedicated to full screen terminal setup like that.
- silentbicycle 17y agoYou might want to consider tmux (http://tmux.sourceforge.net/ http://tmux.sourceforge.net/) as an alternative. Its cleaner (and, incidentally, BSD-licensed) codebase means that it's getting features that have been gathering dust on screen's to-do list for ages. Most notably, its dwm/XMonad-style layouts (http://tmux.sourceforge.net/tmux6.png http://tmux.sourceforge.net/tmux6.png) are really nice. AFAICT, screen doesn't even officially have vertically split windows yet, it's still an unofficial patch. Either way, if you use Unix, learn to use screen or tmux. They're tremendouslyuseful. (Also: Noisy wireless connections are the new flaky dialup, when it comes to resuming shell sessions.)
- pyre 17y agoNo offense, but how does it's BSD-licensed codebase mean that it 'gets more features'?
- silentbicycle 17y agoI rephrased my comment - I think it's the cleaner codebase that makes the big difference. Its BSD license has some perks, though - for one thing, it's part of the OpenBSD base system now, which means security auditing and excellent maintainers. That will probably also lead to more features in the long run. OpenBSD man page: http://www.openbsd.org/cgi-bin/man.cgi?query=tmux http://www.openbsd.org/cgi-bin/man.cgi?query=tmux
- soundphed 17y agoThanks, I will look at that, looks rad! I just thought the article covered some really key points about multiplexing terminals in general...
- noonespecial 17y agoMany thanks for posting this. This is exactly the kind of thing I come to HN to find. I use screen on occasion but never really had it in my mind that I should be using it as a productivity tool. I have once again found minor enlightenment and am already more productive because of it. Its nice when procrastinating on HN turns into a net win!
- tlrobinson 17y agoI've been satisfied with just using multiple tabs in Terminal.app in OS X, but I'm curious if anyone has switched from that solution to screen and wouldn't go back? (for local use in particular)
- potatolicious 17y agoI use screen constantly and would never go back. The detachability is incredibly useful. Say I had to go to a meeting - I shut my laptop and it goes to sleep. This would normally kill any SSH session (and thus leave vim swap files lying about in my case)... but with screen I can just pick up where I left off last time. It's also great if you want to run something big - say a job that would take 5 hours. I'm free to do whatever I want without fear that killing my ssh session will also kill the job.
- silentbicycle 17y ago> run something big - say a job that would take 5 hours The monitor function can also notify you when there's activity or 30 sec. silence in a window, too. :)
- scott_s 17y agoYour second scenario can be handled with nohup from within a vanilla ssh session.
- graywh 17y agoThere's also disown, for that matter, but how can you re-connect to the process?
- sjs 17y agoYou can copy and paste between terminals with the keyboard. This alone should be reason enough.
- EAMiller 17y agoI got frustrated with tabs in Terminal.app because of the keyboard shortcuts : Shift+Apple+arrows In screen I use ^a, " to get a list of screens, then j/k to pick a screen. That may not seem like a win, but it keeps my fingers on the home keys, and feels smoother. That and the fact that I split windows in screen fairly often means I won't go back to terminal tabs...
- bdotdub 17y agoanyone care to share their screenrc? heres mine: http://github.com/bdotdub/dotfiles/blob/master/screenrc http://github.com/bdotdub/dotfiles/blob/master/screenrc
- DannoHung 17y agoI keep mine pretty simple too: http://github.com/DannoHung/my-config-files/blob/master/.screenrc http://github.com/DannoHung/my-config-files/blob/master/.scr...
- silentbicycle 17y agoThe most notable part of mine is # Set up my status line at the bottom of every frame caption always "%{gb} %{ck}%m-%d %C %{gb} %{gb}%?%-Lw%?%{ck}%n*%f %t%?(%u)%?%{gb}%?%+Lw%?" I use tmux now, though. (it has a statusbar similar to the above by default)
- surki 17y agoI posted my config sometime back. http://news.ycombinator.com/item?id=843630 http://news.ycombinator.com/item?id=843630
- jazzychad 17y agoI use screen every day for administering multiple remote servers. I don't know how I functioned before I used screen. One of the coolest things are "backtick" commands you can put in the caption string. Here is a pastie of my screenrc and one of the backtick files which displays the free RAM of the system in the caption line, updating every 30 seconds (ymmv on the free RAM command depending on how your distro's `free` command displays its output) http://pastie.org/633808 http://pastie.org/633808
- mcantor 17y agoI often use idiosyncratic screen setups with very specifically-purposed windows. I support this behavior with a special config file that launches screen with certain windows pre-loaded for certain uses: source /home/mcantor/.screenrc chdir $SANDBOX/src screen 0:svn screen 1:lib screen 2:nosetests stuff "activate_environment\015" screen 3:ipython stuff "activate_environment\015ipython\015" screen 4: select 0 I use stuff because it's the most straightforward way to send commands with carriage returns (015 in octal) to a window. I make this even more effortless by using a special alias in my .bashrc: alias scd='screen -c /home/mcantor/.screenrc-dev' I also use a few other aliases to support common uses: alias scr='screen -rd' alias scx='screen -x' alias lsc='screen -list' Also, don't forget the very useful -S switch: screen -S someproject Or, you can use Ctrl-a :sessionname, if you're already within a session, to rename it. That way, screen -list and screen -r can use your sessionnames, and you don't have to parse or remember the process ID's.
- TallGuyShort 17y agoThis IS a hacker's ideal Terminal - a while ago I set out to write my own shell with all the features I wanted. A huge portion of the functionality I intended to implement is accomplished with GNU Screen. Since I found Screen - I haven't felt enough need to keep developing my own shell!
- garply 17y agoIn the same vein, if you use a repl on a remote machine you should check out detachtty if you're not already using it. It's particularly nice for use within emacs because it doesn't eat the whole screen and it doesn't eat ^A.
- mdakin 17y agoIt also gives OSX RS-232 terminal emulation capability. As far as I know OSX ships with no other such program. Once you get your USB dongle's driver situation under control you just: screen device baud ex: screen /dev/tty.usbserial-FTDPZOEJ 115200 Very useful for embedded system hackers and others who still need to speak RS-232.
- blasdel 17y agoI have not used a single other serial console since I accidentally discovered this feature in screen a few years ago. Hyperterminal, minicom, gtkterm, et. al. were the bane of my existence.
- mmagin 17y agoActually, OS X includes "cu" -- not that feature-rich, but it's been sufficient for me.
- soundphed 17y agoI found this link on how to patch/compile Screen 4.0.3 on Snow Leopard...the one out of the box is kind of buggy, and does not support 256 colors... http://trac.macports.org/ticket/20862 http://trac.macports.org/ticket/20862
- Luyt 17y ago'dtach' is a nice utility too, a kind of lightweight-screen. It's in the BSD ports.
- barrkel 17y agoThe difficulty of scrolling back in the buffer (C-a ESC PgUp is a longer and more tedious key sequence than Shift+PgUp), and lack of full terminal support (e.g. man, less, etc. don't restore screen contents on exit) mean I strictly only use screen on ssh connections. Perhaps the terminal support issue could be worked out with better termcap etc. settings, but I haven't found the answers. I asked questions here: http://superuser.com/questions/23144/how-to-make-screen-terminal-emulation-act-more-like-xterm-or-rxvt-for-init-uninit http://superuser.com/questions/23144/how-to-make-screen-term... ... but no luck.
- decklin 17y agotry "altscreen on". (see also the -a option, and http://www.gnu.org/software/screen/manual/html_node/Window-Termcap.html http://www.gnu.org/software/screen/manual/html_node/Window-T...).
- barrkel 17y agoThe -a option didn't work, but altscreen on in my ~/.screenrc seems to have worked. Thanks!
- pyre 17y ago> (C-a ESC PgUp is a longer and more tedious key sequence than Shift+PgUp) Try entering Copy Mode ('C-a ['). Once in Copy Mode you can page up and down without any modifiers. Just hit ']' to exit Copy Mode. You can also use the up and down arrows in Copy Mode. It's mostly meant for selecting regions of text to yank, but I find it's the easiest way to access the scrollback buffer.
- barrkel 17y agoC-a ESC is copy mode, as far as I am aware. At least that's what it says down the bottom of the screen when I do it. To be clear, C-a ESC puts me in a mode where I can then freely page through the scrollback buffer with PgUp and PgDn, but the problem is that's 4 key presses required for something that only needs 2 in a normal terminal, and Ctrl (with A), Esc, and PgUp are about as far apart as you can get on a keyboard, which doesn't make for efficiency.
- chwahoo 17y agoScreen is great. I wish there were an analogous tool that let me group several running X apps into a long-running session that I could connect to/disconnect from locations. Any idea if this is possible today?
- fhars 17y agoNX is supposedly able to do this, but last time I looked (which, admittedly, was two or three years ago) you had to expect serious problems if the set of available fonts on the different display servers was different (i.e. in all realistic scenarios). Oh, and it only worked on x86-32.
- abhijithoskeri 17y agohttp://partiwm.org/wiki/xpra http://partiwm.org/wiki/xpra
- pyre 17y agoI realize that this is really old, but I came back searching for something in the comments, and I now have something to add to this. I came across something (that is no longer maintained) called xmove which was describe as 'screen for X11'. http://en.wikipedia.org/wiki/Xmove http://en.wikipedia.org/wiki/Xmove
- apotheon 17y agoI prefer tmux.
- lanaer 17y agoI installed tmux, but have not yet played with it. I know I want to, simply because it supports vertical splits…
- deleted 17y ago[deleted]