Display big numbers in terminal - linux

tmux can display big time like the picture below,
is there any way to display big numbers like that,
for example I want to show number of users in real time.

To the extent of my knowledge, there is no such feature in tmux. You could use watch (part of the procps tools) and figlet to implement such a feature:
watch runs a command periodically and prints the output on the screen. It always clears the screen before running the command.
figlet renders a string in a ASCII-Art style font. There a several fonts availiable.
So for instance you could show the number of users on a system (at least on Linux) using the following command line:
watch "who | wc -l | figlet -f big"
Unfortunatly the text won't be centered, as it is with clock-mode.

Related

Automatically use desired monitor and the corresponding audio ouput

I'm using manjaro-linux-i3 with polybar and I'm currently working on my multiple monitor setup.
I have a TV which I normally use with the amplifier it is connected to. In addition I have my desk with a triple monitor setup which I normally use with my headphones for audio output. One of my screens is in portrait orientation which always messes up my login screen.
I'm able to change my audio ouput and my active monitor as I wish. But I want it to be more efficient. At the moment I'm using arandr to change my monitor and pavucontrol to change my audio output when needed.
I want that my login manager(lightdm) is always displayed correctly on my monitors(even on the portrait one).
It would be nice if anybody could give me way how to combine changing monitors and the audio output in one blow. So that I don't have to this every time manually.
I have similar setup and I got everything working what you might want if I understood you corretely.
If you setup everything right, then your loginmanager should always be displayed on the monitor which is active at boot and you can switch your monitors&sink with a simple keybind.
First, you can add a script to lightdm to config your monitors so that everything is displayed correctely. But be aware that a broken script can leed to the effect that your loginmanager won't be loaded correctly (blackscrren).
in /etc/lightdm/lightdm.conf you can define a script at #greeter-setup-script= . Simply uncomment the line and add the path to your script.
An easy way to config your monitors the way you want is to use arandr. Simply config your monitor the ways you want and save the setup. You will be saving an usual xrandr command, which can be used in your script.
Here is my script.
It is very basic and actually only checks if a monitor of my desk is active. If so, it initialises the monitors of my desk. If not, it initialises my tv. It also sets the audio output I use with those monitors.
To get a list of all active monitors use this command:
xrandr --listactivemonitors | awk '!/Monitors/ {print $4}'
To get a list off all sinks(audio output) use this command:
pacmd list-sinks | grep -e 'name:' -e 'index:' | awk '{print $2}'| awk '{print substr($0, 2, length($0) - 2)}'
Now you can change my commands (sink and monitor names) with the onces you need. You can execute the script in the terminal so get feedback of the choosen sink and monitor (for testing). Don't forget to make your script executable else it won't work.
I got a similar script to manually change between my tv and my desk (mirroring scrrens, duplicate, tv-only, ect)
It too changes the sink according to the selected monitors. As you are using polybar too, you might notice that I relaunch polybar with sh /home/lluks/.config/polybar/launch.sh This is the script.
It ensures that my applets are displayed on the main monitor as poylbar can only display them on one monitor. This is archieved by using a 2 diffrent bars for poylbar.
For this script to work, you need dmenu and rofi. If I remember corretely, you also need Font Awesome for the icons.

Get terminal contents [duplicate]

This question already has an answer here:
Read screen character from terminal
(1 answer)
Closed 2 years ago.
Is it possible to get a snapshot of the text contents of a Linux terminal?
Both tput and terminfo support "cup" mode (e.g. tput smcup to start alternate buffer mode) which implies they must save the screen state somewhere. Is it possible to get these contents?
You can save a snapshot of the text contents of a Linux terminal to
a file using GNU Screen
hardcopy
feature but only if you started screen beforehand. Apart from that,
you can restore terminal contents saved with tput smcup using
tput rmcup but this works only in xterm (not only in xterm
terminal emulator itself but also in other terminal emulators
providing that $TERM is set to xterm. It doesn't work in Linux TTY
though).
Four Methods to Take Screenshot Capture in Ubuntu Linux
Use Print Screen
This is the most common method to take screenshots. Pressing the “Print Screen” button will take the screenshot of the “Entire Visible Screen”.
When we want to take a particular window, we can use “Alt+Print Screen”. Alt+PrintScreen will take only the particular window which is currently active.
Use gnome-screenshot
gnome-screenshot utility is part of the GNOME Desktop Environment, which can also be used to take screenshot. It also has a command line mode (gnome-screenshot)
From the command-line, just type the command “gnome-screenshot” to do the same. The command will take a screenshot and provide a dialog to save it.
$ gnome-screenshot
Capture Only the Current Window:
From the UI, to take the screenshot of the current active window alone, select “Grab the Current Window” and click “Take Screenshot”.
From the command-line, use the -w option as follows to do the same.
$ gnome-screenshot -w
Take Screenshot After Some Delay:
From the UI, you can also set a delay before taking the screenshots. Set the “Grab after a delay” to the required number of seconds. This will be really helpful when we need to take screen shots of navigation.
From the command-line, use -d option to do the same. -d 2 is used for delaying the screenshot for 2 seconds. So within the 2 seconds, we can make the window which we want to take screenshot as active.
$ gnome-screenshot -w -d 2
Capture a Particular Area:
From the UI, if you want to take a particular rectangle area alone, then select “Grab a Particular area” and click “Take Screenshot”.
From the command-line, use the -a option to do the same. Once this command is entered, the mouse pointer will be changed, and you can drag and select which area to take screenshot.
$ gnome-screenshot -a
Take Screenshot Including or Excluding Window Border:
From the UI, you can also include or exclude the window border by selecting/deselecting “Include the Window Border” option.
Use ImageMagic’s Import Command
ImageMagick is an open source software suite for displaying, converting, and editing raster image files. It comes with various command line tools, and one of that is “import”. Now we will see, how we can use import to take screenshots. You can install it by using apt-get on debian/ubuntu as follows:
apt-get install imagemagick
Capture Entire Screen using -window root option
Use the “-window root” option to take screenshot of the complete screen. The screenshot will be saved in the file name provided in the command line.
$ import -window root Pictures/Image5.png
ImageMagick supports more that 100 file types. You can use any one of them to store the output.
Use GIMP
You can also take screenshot from gimp. Launch gimp, and click “File->Create->Screenshot”. A new dialog window will open with options similar to gnome-screenshot.

xterm dump of full scrollable window content

I want to know if anyone does know a way to dump or copy the whole lot of viewable messages in a xterm window on linux. The very important thing is I don't want to know how to send a command out and kapture its output for stream 1 and 2 as well as the input, as this is well known to me.
I may explain for what this is needed. You do something and expect not any complications but than you got pages of msg's als err msg or normal output. To be able to see later after it you should be able to get them in a file and as long as you are able to scroll that all back and forther with your mouse it is sure the data is there some where. But the time may be not to scroll and screenshot and scroll ....
I would be glad to help me out in such cases and it would be fine to have the full view including all your own typing and all the msg's in same order as you watch it when you scroll it back.
I don't really know where this is stored and how you could get that saved. I know that I could dump the whole lot of Memory and search it for a part of the xterm window, but that is a bit over the top I think.
There is a control sequence, which I had forgotten. This question reminded me. In XTerm Control Sequences, it is noted "print all pages":
CSI ? Pm i
Media Copy (MC, DEC-specific).
Ps = 1 -> Print line containing cursor.
Ps = 4 -> Turn off autoprint mode.
Ps = 5 -> Turn on autoprint mode.
Ps = 1 0 -> Print composed display, ignores DECPEX.
Ps = 1 1 -> Print all pages.
That dates from 1999 (patch #119), so you likely have it in your xterm. You could do this in a shell command like this:
printf '\033[?11i'
A comment mentions the page Hidden gems of xterm, which uses the corresponding action print-everything (something that can be executed via the translations resource). It is in the manual page, of course. The same comment points to Extra characters in XTerm printerCommand output, which mentions the resource printAttributes. By default, the control sequences for the printer tell xterm to send extra control characters (to reconstruct video attributes). The resource can be modified (set to 0) to suppress that. That is even older (patch #74).
Without that — Conceivably one could construct an application which used the X SendEvent protocol to construct a series of events which would be interpreted as xterm actions to scroll back, select text and copy it chunk-by-chunk via the clipboard. You could even write it in Perl (there is a module for X protocol). But seriously, no.
If you want to capture text which was written to xterm, you can do this by preparing before the text is needed by different methods (see manual):
turn on the xterm logging feature (not that user-friendly because it generates the filename). This can be enabled using the "Log to File (logging)" menu entry.
use the printer control sequences to write lines as they are written (again, not that friendly, though there is a menu entry to turn it on and off, "Redirect to Printer (print-redir)")
use script to capture all output to the terminal. I use this, because it works with any terminal on any POSIX-like system (even Cygwin).
Each of these methods produces a file containing escape/control sequences, which requires filtering out. The hypothetical program using SendEvent could in principle eliminate that.

disable automatic line wrapping in Ubuntu terminal

I used some sql command to join two tables and the result was two terminal line long for each row of resulted table.
I dont want so ... i mean is there any way to get scroll bar at the bottom so that a row can be fit into a terminal line. and it will be a well structured and readable output
I hope you get my question.
There is no way on a standard terminal. You could use e.g. less as your pager for you sql-client.
I propose to pipe the output into the command less -S:
$ mysql-command-doing-the-SELECT | less -S
(To achieve this in the interactive mysql console, you can type pager less -S.)
Then all lines are displayed without being wrapped, and you can scroll sideways using the arrow keys. You can also use the command less (without the option -S) and then interactively type - S to achieve the non-wrapping. (Type again to toggle.)
If you need a real scroll bar, I propose to pipe the output into a real file and then use a more sophisticated program like gedit (which can be switched to a non-wrapping display) to display it with a decent scroll bar.
Another solution: copy the data from the terminal and paste it into your favorite editor. The copied text will not have any line breaks "\n".
(Offtopic: on a linux system you can just select the text with a mouse and mouse-middle-click in your editor. This will copy the text without filling out the main copy-paste buffer.)

Linux(Ubuntu) Terminal-how to view previous pages not visible anymore

When you scroll up, say to see a log, the first portion of it will not be visible since the terminal only supports a limited no. of lines. So if you want to scroll up and be able to see everything, at least a few pages up, how do you do it?
Use Shift+Page Up and Shift+Page Down.
Piping the output to a pager like the following is a better choice:
command | less
command | more
You can enable unlimited scroll back (or a huge amount if you want).
To do this, go to
File → Profile preferences → Scrolling [tab]
Then, check Unlimited, or set the number of lines desired. And of course, it only applies to the next typed lines.
Some tricks I use-
some terminal applications (gnome-terminal) allow you to increase the scroll-back buffer size
pipe output to a file:
command > file.log
pipe your command to less:
command | less
tail log and pipe to grep to reduce output
tail -f example.log | grep 'search text'
An alternative to screen is using tee to copy all output to a file while still printing it on the terminal:
yourcommand | tee output.txt
Try using the screen command, and set its scrollback buffer to a larger size.
screen has many other benefits and wonderful features.
If all you're doing is looking at a log, you could alternately use a pager such as less
If you want to scroll line by line, you can use
Control+Shift+Up/Down Arrows.
If you are using gnome-term (the default), then you can change your settings. Either set the no. of lines to unlimited, or to a much larger buffer size than the default.
Essentially seconding to #zerick's solution but if you're on gnome-terminal you can modify its config. See this.
If you are in tmux (can create multiple terminal sessions in a single terminal session, highly recommended), you can easily use your normal navigation keys to scroll around after you do Ctrl-b then [, for more details let's take a look at: How do I scroll in tmux?
None of these answer the original question. All answers are how to make new terminal windows (or current one) start behaving a certain way. The question is about how to see whats already scrolled away.
To answer this, each terminal session should have it's own "history" file (not to be confused with what command history is) containing all the stuff that relates to stdin/stdout displayed. I could be wrong but this may be different depending on the terminal emulator you use. Some just trash it when you close the window/ end the session.
I am trying to get this figured out myself so here is the more direct answer in a different thread.
https://unix.stackexchange.com/questions/145050/what-exactly-is-scrollback-and-scrollback-buffer
From what this tells me, I suspect best advice you can get is, for whatever terminal emulator you use, look for where it stores the scrollback buffer and that might be your only hope. It's what I am going to try right now. (and that is IF the session is currently still open, not closed terminal windows)

Resources