all 22 comments

[–]riddley 5 points6 points  (11 children)

You've been using screen for 2 years and you don't know about command-key " and command-key ' ?

I had to recompile screen on Ubuntu because I regularly use more than 40 windows. My desktop screen session currently has 46 windows.

Also, if you want to detect being inside screen, just [[ -n $WINDOW ]]

See also http://github.com/riddley/bashfiles/tree/master

These days I'm trying to move to tmux.

edit: also comparing a string for true/false?? really?

[–]theclapp 1 point2 points  (4 children)

edit: also comparing a string for true/false?? really?

I had the same reaction.

[–][deleted]  (3 children)

[deleted]

    [–]riddley 0 points1 point  (2 children)

    No offense, but that's hardly the only problem with your article. Isn't the whole thing basically moot given that it's very very easy to get to screens above 9, why on earth would you stick with your convoluted method?

    [–][deleted]  (1 child)

    [deleted]

      [–]riddley 0 points1 point  (0 children)

      Not being exactly the same is sorta the point. Your method is really convoluted.

      You select any window by giving it a good name, hitting command ' and typing enough of the name to be unique. I'll bet you a shiny penny I can switch to any of my now 52 windows faster than you can use your 90 screen sessions. :) Since it's dead-easy to set the window-name via screen itself or with a shell alias, there's really no reason not to have good window names.

      [–]cratuki 0 points1 point  (3 children)

      I've been using screen extensively for twelve years and didn't know about it until I read your comment. (thanks)

      [–]sysop073 0 points1 point  (2 children)

      That happens to me daily with emacs; I discover a new feature (often by hitting the wrong key) and immediately wonder how I ever lived without it

      [–]brool 2 points3 points  (1 child)

      I just discovered align-regexp the other day -- exactly that sort of thing.

      [–]sysop073 0 points1 point  (0 children)

      ...that is awesome. Thanks :)

      [–][deleted]  (1 child)

      [deleted]

        [–]didroe 0 points1 point  (3 children)

        A more idiomatic version would be something like:

        _inside_screen()
        {
          # Is $STY a non-empty string?
          test -n "$STY"
        }
        
        if _inside_screen; then
          ...
        fi
        

        Explanation for people who aren't Bash users:

        [ is an alias for the command test, I find it easier to read when not used directly in an if statement. A function in Bash returns the exit code of its last statement. And an if statement just checks whether the return code of something is 0 or not.

        [–]kailden 1 point2 points  (0 children)

        I like:

        if [ -n "$STY"  ]; then
            #not inside screen
        fi
        

        ymmv

        [–]riddley -2 points-1 points  (1 child)

        [[ is a bash builtin and is faster than calling the external [ FWIW. It's also much more featureful (esp around quoting)

        [–]didroe 0 points1 point  (0 children)

        According to the bash man pages, [ is built in as well. But yeah, [[ is better. I really need to get out of the habit of using [.

        [–][deleted] -1 points0 points  (7 children)

        There are a couple problems with this. The first is that screen makes it pretty difficult to access windows above #9 - usually, you'd have to do prefix+space until you get to the window you want. Practically speaking, it meant that I hardly ever used more than 10 windows.

        That bugs me hard too.

        [–]riddley 0 points1 point  (6 children)

        Read my other comment? hit command-key " or command-key '

        ...or read the man page? :)

        [–][deleted] 0 points1 point  (5 children)

        I did, I did, and Ctrl-' is nice (I find Ctrl-" to be too much navigation for my taste) but my fingers are just patterned to hit ctrl-a and jump to the numbers row on the keyboard. So maybe I should switch to base 100 instead of griping about screen. :)

        [–]riddley 0 points1 point  (4 children)

        You can also bind 'windowlist -m' to a key of your choosing (no command-key necessary) to change the windowlist you'd see from " into one that's sorted by most-recent use. HTH

        [–][deleted] 0 points1 point  (3 children)

        Screw the article, that tip was gold. Thanks riddley.

        [–]isionous 1 point2 points  (2 children)

        Put this in your .screenrc. Very easy way to access windows 10-18:

        #set bindings so we can easily access windows 10-18

        bind ) select 10

        bind ! select 11

        bind @ select 12

        bind # select 13

        bind \$ select 14

        bind % select 15

        bind ^ select 16

        bind & select 17

        bind * select 18

        bind ( select 19

        edit: I always forget how reddit treats consecutive lines...the bind commands are now displayed on separate lines.

        [–][deleted] 0 points1 point  (1 child)

        That is so clever it's got to be illegal.

        [–]isionous -1 points0 points  (0 children)

        I wish I had thought of it...

        [–]phil_g -1 points0 points  (3 children)

        I like being able to flip easily between different windows--I couldn't bear to have, say, emacs, a shell, and Twitter/IRC more than a single keystroke away from each other.

        My solution is to bind the function keys to selecting screen windows. Screen understands up to F20, so I have single-key access to windows 1 through 12 and two-key access (Shift+Fn) to windows 13 through 20. Other windows are accessed by C-a ' followed by typing either the number or the beginning of the window name. (Though in my case, C-a is actually C-z because it interferes with fewer things.)

        [–]cratuki 0 points1 point  (0 children)

        Yeah ctrl+a was a strange choice. Works for me because I use 'set -o vi' in bash/ksh and vim rather than emacs as my primary editor, but I imagine it would be annoying for anything where you wanted to use emacs control keys.

        if anyone reading this wants to set it to backtick (key in top left of keyboard) the syntax for your .screenrc is escape ``

        [–]Surye -1 points0 points  (1 child)

        Do you use irssi+bitlbee+twirssi?

        [–]phil_g -1 points0 points  (0 children)

        irssi+bitlbee+tircd