GNU screen: how to check current scrollback value? - gnu-screen

In GNU screen, I know that I can change the scrollback (buffer size) using this command:
<Ctrl-a>:scrollback 10000
as well as adding this line in .screenrc:
defscrollback 10000
But How do I check what the current value is? (For clarification, looking at the .screenrc file and locating the line with defscrollback is not the solution I'm looking for.)
Thanks!

As soon as you enter scrollback mode (CtrlA then Esc), you should see a status line like
Copy mode - Column 71 Line 25(+3000) (80,25)
The 3000 is the scrollback size. As long as you're in scrollback mode, you can use CtrlG to see a shorter version of that status line. If you're no longer at the bottom, the +3000 will be changed to show how far you've scrolled back. It tells how many lines are available above the currently displayed region, so +0 means you've scrolled back all the way.

You can also issue the command Ctrl-A i to get the value of the scrollback size currently set for that particular window.

Related

Can man pass an option to the roff formatter?

SYNOPSIS
From man(1):
-l
Format and display local manual files instead of
searching through the system's manual collection.
-t
Use groff -mandoc to format the manual page to stdout.
From groff_tmac(5):
papersize
This macro file is already loaded at start-up by troff so it
isn't necessary to call it explicitly. It provides an interface
to set the paper size on the command line with the option
-dpaper=size. Possible values for size are the same as
the predefined papersize values in the DESC file (only
lowercase; see groff_font(5) for more) except a7–d7.
An appended l (ell) character denotes landscape orientation.
Examples: a4, c3l, letterl.
Most output drivers need additional command-line switches -p
and -l to override the default paper length and orientation
as set in the driver-specific DESC file. For example, use the
following for PS output on A4 paper in landscape orientation:
sh# groff -Tps -dpaper=a4l -P-pa4 -P-l -ms foo.ms > foo.ps
THE PROBLEM
I would like to use these to format local and system man pages to print out, but want to switch the paper size from letter to A4. Unfortunately I couldn't find anything in man(1) about passing options to the underlying roff formatter.
Right now I can use
zcat `man -w man` | groff -tman -dpaper=a4 -P-pa4
to format man(1) on stdout, but that's kind of long and I'd rather have man build the pipeline for me if I can. In addition the above pipeline might need changing for more complicated man pages, and while I could use grog, even it doesn't detect things like accented characters (for groff's -k option), while man does (perhaps using locale settings).
The man command is typically intended only for searching for and displaying manual pages on a TTY device, not for producing typeset and paper printed output.
Depending on the host system, and/or the programs of interest, the a fully typeset printable form of a manual page can sometimes be generated when a program (or the whole system) is compiled. This is more common for system documents and less common for manual pages though.
Note that depending on which manual pages you are trying to print there may be additional steps required. Traditionally the following pipeline would be used to cover all the bases:
grap $MANFILE | pic | tbl | eqn /usr/pub/eqnchar | troff -tman -Tps | lpr -Pps
Your best solution for simplifying your command line would probably be to write a little tiny script which encapsulates what you're doing. Note that man -w might find several different filenames, so you would probably want to print each separately (or maybe only print the first one).

IntelliJ console output with multiple (source.java:line) links on a line

When my logging system outputs the source and line number in the proper format (name.java:linenumber), it appears in the output console like a link you can click on, taking you to the corresponding line number of that source code, which works great. Except my logging system prints like a stack trace, a series of source location on a single line, like this:
date/time - a logging statement - (Source1.java:123) (Source2.java:321) (Source5.java:11)
The thing is that IntelliJ only makes the first one a link. The remaining ones don't become clickable links.
Is there a way to configure IntelliJ to scan all source location for each line in the console output, and not just the first one for each line?
This feature is not available at the moment and the progress can be tracked at:
Highlight links with multiple (source.java:line) per line in the output console

How to increase the size of the scrollback buffer in GNU screen

How do I increase the number of lines that I can view in screen?
I want to view the lines from the point when I ran screen -S <screen_name> to the current operation. For example, how would I increase the buffer length to around 50000 lines?
I have already tried ^a :scrollback <number> but it does not increases the lines I can reach in my current terminal.
You cannot retroactively increase the scrollback buffer length in the current session in order to recover old lines that have already been discarded. However, if you change the current scrollback parameter setting (C-a :scrollback <number>), it will add more space for future terminal output. You can also set the defscrollback parameter to affect the initial scrollback setting for new windows.
If you want to set the default for all windows of all new screen sessions, make a ~/.screenrc file with
defscrollback 50000
or, if you only want a big scrollback sometimes, put it in a separate file, like ~/screenrc-50k-scrollback and invoke screen like this:
screen -S <screen_name> -c ~/screenrc-50k-scrollback
Check the current scrollback buffer capacity with C-a i (the info command).
(22,1)/(25,40)+50000 +flow G0[BBBB] 0(bash)
^^^^^
Reference: GNU Screen manual, Scrollback section
I don't know if I understood correctly what you asked, but if so I think you can just increase the value of Lines of scrollback property you can find on the Window menu item on the left of your Session configuration.

Copying the GNU screen scrollback buffer to a file (extended hardcopy)

How do I easily copy the GNU Screen scrollback buffer to a file? I.e., a more powerful version of the 'hardcopy' command?
In GNU screen, I can use "Ctrl + A Esc" to enter the scrollback
buffer. I could then mark the entire buffer and use "Ctrl + A Ctrl + ]" to paste it into an Emacs buffer, thus saving it to a file.
However, this is tedious. Is there a Screen command that'll simply copy the scrollback buffer to a file, like 'hardcopy' does for the visible portion of the screen?
To write the entire contents of the scrollback buffer to a file, type
Ctrl + A and :
to get to command mode, then
hardcopy -h <filename>
In older versions of screen, if you just do hardcopy -h, it just writes to the file -h. This was fixed in version 4.2.0, so hardcopy -h writes to hardcopy.N where N is the current window number.
Press Ctrl+A :bufferfile /tmp/somefile.txt ENTER, and then Ctrl+A >
This will write the current contents of the buffer to the named file.
TL;DR: ^A:writebuf <filename>
The OP seems to want a way to use the selected portion of the buffer you get when doing a ^A[ , selecting text using space as the start and finish, and then instead of using ^A] to paste, save the resulting selected portion of the buffer to a file.
This worked:
^A:writebuf <filename>
Note: one 'f' in writebuf
Try hardcopy -h to include the whole buffer.
This worked for me:
Enter edit mode (~) and type:
:hardcopy -h buff_file
It created a huge file, of which 98% was empty, but my logs were fully present in remaining 2%.
Ctrl + A, :, and issue the command 'log on'.
Or set it as the default in your .screenrc file as 'deflog on'.
Do Ctrl + A, H.
That saves the current screen into a hard copy file, e.g., hardcopy.0 for screen 0. It seems to be a quicker way than going Ctrl + A, : and typing the hardcopy command.

How do I display the current "session" name or "sockname" of a screen session in the status bar?

I run multiple screen sessions each created with 'screen -S name' and I would like to be able to display in the status bar the name I used to create the current screen session.
However, I cannot seem to accomplish this. Any ideas?
The easiest way to display the sessionname is
C-a :
sessionname
(without specifying a name after sessionname)
See the "CUSTOMIZATION" section in man screen
screen has two status bars, the caption bar and the hardstatus bar, both of which use the string escapes specified in the "STRING ESCAPES" section of man screen. Unfortunately, there is no escape that directly refers to the session name.
However, there is a hack that will allow you to do this.
screen passes the session name to the shell using the $STY variable. When the shell attempt to set the window title (using one of these methods) screen captures that attempt, and stores it in something it confusingly calls "the window hardstatus," which does have an escape that you can use: %h.
So if you have either the caption or hardstatus bar set to include %h and have the shell attempt to set the window title to $STY, then the %h will be replaced with the session name when the bar is displayed.
In current versions of screen, there is a flag %S for the hardstatus line.
MWE (.screenrc):
hardstatus on
hardstatus alwayslastline
hardstatus string "%S"
This displays the session name without the ID (like ${STY#*.}).
(Same answer to other questions here and here for completeness).
paraphrased from https://superuser.com/a/212520/151988, put this into your ~/.screenrc;
screen
screen $SHELL -c 'screen -X caption always "$STY"'
Super User has an answer to this that does not require $STY, instead using the backtick screen config command and screen -ls: https://superuser.com/a/212520
If nothing else works (as for me), as a workaround you can create a window with number 0 and set title to your screen name:
screen -S myscreen
C^a :title "myscreen"
As max_cantor says in the SuperUser Answer, an escape character for the session name should be added to version 4.1.0. It looks like the escape character function was added with a relatively small patch back in 2008. So if you're feeling brave, you can git yourself a copy of the development version 4.1.0 and try it out.
I'll try this with the development version when I get a chance.
"screen -X sessionname"
i'm using ssh,i thought this is a straight answer ,
sessionname will show at the screen bottom