Hot answers tagged

66

You're seeing the escape sequences that tell the terminal to change colors displayed with the escape character shown as ESC, whereas the desired behavior would be that the escape sequences have their intended effect. Commands such as git diff and git log pipe their output into a pager, less by default. Git tries to tell less to allow control characters to ...


41

Yes, less can follow by file name The feature has a fairly obscure syntax: less --follow-name +F file.log With less, --follow-name is different from the tail option --follow=name. It does not make less follow the file, instead it modifies the behaviour of the command key F inside of less to follow based on the file name, not the file descriptor. Also, ...


41

There are two worldviews here: As far as programs using termcap/terminfo are concerned, your terminal potentially has two modes: cursor addressing mode and scrolling mode. The latter is the normal mode, and a program switches to cursor addressing mode when it needs to move the cursor around the screen by row and column addresses, treating the screen as a ...


19

As the name implies, roughly a pager is a piece of software that helps the user get the output one page at a time, by getting the size of rows of the terminal and displaying that many lines.


18

Git uses isatty() to check whether stdout is a tty: this is used to see if a pager must be used (pager.c) as well as colors (color.c).


17

On terminals that support setting the scrolling region: tailf() ( # args: <file> [<number-of-header-lines>] trap 'tput csr 0 "$((LINES-1))"' INT tput csr "$((1+${2-1}))" "$((LINES-1))" tput clear { head -n"${2-1}" printf "%${COLUMNS}s\n" "" | tr ' ' = tail -n "$((LINES-1-${2-1}))" -f } < "$1" ) (assumes a shell like zsh ...


17

When no other pager is specified, man uses less to display man pages. The other answers that involve changing the pager command line are correct, but you can also type -i while less is running. From the less man page: - Followed by one of the command line option letters (see OPTIONS below), this will change the setting of that option and print a ...


13

Only if you use caps, not if you just use lower case letters. For example, run man bash and try: /invoc <== case insensitive /Invoc <== case sensitive /INVOC <== case sensitive As @manatwork poited out in the comments, you can also control this behavior by adding export MANPAGER='less -I' to your ~/.profile. The MANPAGER variable defines which ...


12

Yes, using J (as in ShiftJ). So you can go to the end of the file with G, then scroll down past the end with J until the last line of the file is at the top of the screen (less won’t let you scroll any further). K and Y do the same at the top of the file, scrolling up past the beginning until the first line is at the bottom of the screen. As David Ongaro ...


11

If you're familiar with vim, this is probably the best option for you. You can enable horizontal-scroll-bind-only by changing 'scrollopt': set scrollopt=hor So with vim -u NONE, you get the desired behavior with: :set scrollopt=hor :set nowrap :1split :windo set scrollbind You may want to adjust 'sidescroll' and 'sidescrolloff' to change how many columns ...


11

Running: git diff --color=always > output shows the color escapes. Damn I found it in git's color.c file: static int check_auto_color(void) { if (color_stdout_is_tty < 0) ...


10

There is a solution using Vim. First, we need a Vim macro, which will do most of the work, I save it in ~/.vim/plugin/less.vim: " :Less " turn vim into a pager for psql aligned results fun! Less() set nocompatible set nowrap set scrollopt=hor set scrollbind set number execute 'above split' " resize upper window to one line; two lines are not ...


10

The default underlines hurt my eyes. This setup greatly improves my man page reading: Add the following in your `~.bashrc': # Have less display colours # from: https://wiki.archlinux.org/index.php/Color_output_in_console#man export LESS_TERMCAP_mb=$'\e[1;31m' # begin bold export LESS_TERMCAP_md=$'\e[1;33m' # begin blink export LESS_TERMCAP_so=$'\e[...


9

most hotkeys are highly configurable. The settings are customized with ~/.mostrc file. Actually, your most package most likely comes with lesskeys.rc example configuration, somewhere in the documentation folder (it's /usr/share/doc/packages/most/lesskeys.rc for me on openSUSE Leap 42.1). You just need to copy that file's contents into your ~/.mostrc and ...


8

The more command is considerably older than the less command (1978 vs 1983ish). The less command was introduced as a 'backwards more' (because you could scroll up). The more command is part of the OS binaries with most modern unix/linux OSs, while less is maintained externally as an open source project. I'll often use more on systems with the bare minimum ...


8

iselect provides an up-down list, (as input from a prior pipe), in which the user can tag multiple entries, (as output to the next pipe): # show some available executables ending in '*sh*' to run through `whatis` find /bin /sbin /usr/bin -maxdepth 1 -type f -executable -name '*sh' | iselect -t "select some executables to run 'whatis' on..." -a -m | xargs -...


8

Your PAGER=less sets the shell variable PAGER to the value less. For man (or anything other than the current shell) to see this, you will have to additionally make PAGER an environment variable. You do this with export, either through PAGER=less export PAGER or export PAGER=less A shell variable is "exported into the environment" with export. This ...


6

Try this (you'll need to install multitail): multitail -du -t "$(head -n 1 filename)" filename or, for headers longer than one line: multitail -wh 2 -l "head -n 2 filename" filename If you want to follow command output instead of a file: multitail -wh 2 -l "command | head -n 2" -l command or use -t as appropriate. Note that you may need to use unbuffer ...


6

I think you've brought up a culture clash caused by a technical limitation. Since Shift+Space generates the same output as Space, the Unix terminal model treats them identically. To distinguish between the two, you need a programming environment that supports key up / key down events. That is possible in X11 and in terminal emulators that support ...


5

If you use Oh My Zsh, you can add colored-man-pages to the plugins array in your .zshrc file.


5

You can pipe the output of ls to pipe as follows $ ls | less Then you are able to use less to browse the output, for example with Page Up and Page Down. You can exit less by pressing q. Type man less to find out more ways to scroll the output.


5

A library called curses, it knows what terminal type you are using, and sends the correct escape sequences. There terminal is asked to switch to a different vertical buffer, and mode that allows more control.


5

It's the shell that sets the pipeline up. less is not involved in that. When you do ls | less, the shell starts ls and less concurrently after having made the stdout of the process that will eventually execute ls the writing end of a pipe and the stdin of the one that will execute less the reading end of that same pipe. ls detects that its stdout is not a ...


4

In Fedora at least less has a +F option that follows the contents of a file just like tail -f does.. Update, try hitting F in less to toggle to follow mode as well


4

The Linux kernel has options to restrict what physical address ranges it will use as RAM, but that won't prevent buggy drivers or access through /dev/mem to escape those ranges. You won't gain anything from modifying the MMU configuration during the boot stage, because the kernel will take control of the MMU after that anyway. If you want to be absolutely ...


4

It really depends on the application that is used to open a document. perldoc uses application defined in PERLDOC_PAGER, MANPAGER, or PAGER environment variable. It defaults to less viewer on most systems, so you should press q when browsing the document. But if by accident you pressed other keys, you might need to finish the operation before q would allow ...


4

You can write vipe in a few lines of shell. Quick-and-dirty proof-of-concept that works for me: EDITOR=vi # change to preferred editor as needed. vipe() { cat > .temp.$$ if $EDITOR .temp.$$ < /dev/tty > /dev/tty 2>&1 ; then cat .temp.$$ fi rm .temp.$$ } Source this into your shell and there it is. The purpose of the if is to ...


4

You can add a no-clear to this a couple of ways. You can resolve less from clearing the screen by calling it with the -X argument. Note the $ symbol in the command lines below. This is specifying the terminal prompt of a normal user. $ seq 1 200 | less -X If that is your desired behavior you can alias less to this default with: $ alias less='less -X' ...


4

The man page for systemctl (man systemctl) explains this behaviour clearly, and even offers options to change it: $SYSTEMD_PAGER Pager to use when --no-pager is not given; overrides $PAGER. If neither $SYSTEMD_PAGER nor $PAGER are set, a set of well-known pager implementations are tried in turn, including less(1) and more(1), until one is found. If no ...


3

Solutions within Mutt I'm not finding much in the way of how to do this. Mutt has *_format variables, I suspect you could use those to control pager_format and index_format, for example: set index_format="%4C %Z %[!%y-%m%d] %-18.18F (%4c) %s" set pager_format="%S [%C] %n (%l) %s" But I don't think this will give you what you want. Also I found a ...


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