Tag Info

Hot answers tagged

13

With GNU sed: sed -n '132 {/^#termcapinfo[[:space:]]*xterm Z0=/q}; $q1' How it works 132 {/^#termcapinfo[[:space:]]*xterm Z0=/q} On line 132, check for the regex ^#termcapinfo[[:space:]]*xterm Z0=. If found quit, q, with the default exit code of 0. The rest of the file is skipped. $q1 If we reach the last line, $, then quit with exit code 1: q1.


5

With POSIX toolchest: tail -n +132 </etc/screenrc | head -n 1 | grep -q pattern


3

You can do it in more efficiently in awk: exit as soon as you've hit the relevant line. awk 'NR==132 {if (/^#termcapinfo[[:space:]]*xterm Z0=/) found=1; exit} END {exit !found}' /etc/screenrc Alternatively, you can use GNU sed (but portable sed doesn't let you specify the exit code). Alternatively, you can use the Unix philosophy of combining tools ...


3

Note that screen is a terminal emulator. So your question is a bit like asking how can I start xterm from gnome-terminal and have what was last displayed in xterm visible in my gnome-terminal when xterm exits. Now the difference between xterm and screen is that while xterm uses the X protocol to draw its screen, screen uses a host terminal. By default, ...


2

If you just want to get rid of this screen session , you can do: kill 9667; screen -wipe


2

You can try -p to select the window, numbered from 0, eg screen -S SessionName -p 1 -X kill


2

To kill the nth SSH session, type <enter>, then 2^(n-1) ~, then .. (~~ sends the escape character; thus, two tildes will cause the first SSH to send it to the second SSH, which will then pick up the dot and die. Extrapolate as necessary for deeper nesting.) I have a similar situation; my solution is to have Mosh on the dev box, which doesn't pick up ...


2

Some alternatives with ed: ed -s infile <<\IN 132s/^#termcapinfo[[:space:]]*xterm Z0=/&/ q IN or sed+grep: sed '132!d;q' infile | grep -q '^#termcapinfo[[:space:]]*xterm Z0=' In both cases, if infile has less than 132 lines or if line 132 doesn't match the pattern, the exit code is 1. Both should be quite portable, ed will read the whole file ...


1

You could always use a couple of greps: grep -nm 1 "^#termcapinfo[[:space:]]*xterm Z0=" /etc/screenrc | grep -q '^132:' The -n adds the line number to each matched line in grep's output. For example: $ seq 11 15 | grep -n 5 5:15 The -m 1 (which, unlike the other two, is not defined by POSIX and might not be available in your grep implementation) makes ...


1

I know you said you didn't want to use perl. I think you're operating under a misconception about how 'lightweight' it is. You could do this: #!/usr/bin/env perl use strict; use warnings; open ( my $input_fh, '<', "/etc/screenrc" ) or die $!; while ( <$input_fh> ) { if ( $. == 132 and m/^#termcapinfo[[:space:]]*xterm Z0=/ ) { ...


1

You can try it this way: [ -z "$STY" ] && read && screen -Rd "work" It will postpone the screen attaching after you will press enter (or input something). If you enter Ctrl+D, screen will not be attached and you will end up in normal shell.


1

Remote GUI (X11) connections go through TCP port 6000+n where n is the display number┬╣. So the two messages refer to the same problem: some program tried to connect to display 12 and failed. Emacsclient doesn't make X11 connections, Emacs does. So if you see this message, it means Emacsclient managed to contact Emacs and tell it to open a new frame. ...


1

Terminals transmit characters┬╣, not keys. When you press a key or key combination like Ctrl+Alt+Enter, the terminal has to translate it to a character or character sequence. There aren't nearly enough characters to represent all keys, so most such combinations are transmitted as escape sequences: a sequence of characters starting with the escape character. ...


1

It looks like you're missing a few dependencies. That would be a bug in the configure script. You might want to file a bugreport to the screen maintainers.


1

I did itusing a bit of a hackier way: Using tcsh I put the following in my .cshrc # escape sequence to set the screen title alias stitle 'echo -n "^[k\!*^[\\"' # shorthand to set the screen title to the hostname alias H stitle `hostname -s` # shorthand to set the screen title to the filename, launch vim, and then set it back alias ...



Only top voted, non community-wiki answers of a minimum length are eligible