Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am wondering about some bash environment setting here: is it possible to set stdout of bash as a pipe to /bin/more? You know, like using vi as editor for your commands it should be possible to avoid using Ctrl-PgUp or Ctrl-PgDown for looking on all the output (by default).

To be more specific: I don't want to pipe the output of a single command to more like:

$> ls | more
a b c
...
--more--

BUT: pipe any output of my current session to more, so to get either all output printet as usual just beneath the prompt - or if it's too much, screen-wise.

# automatically piped to more:
$> ls 
a b c
...
--more--

Is there any bash-built-in to accomplish this?

EDIT: I wasn't specific enough, sorry for that: I am aware of "script" and command grouping like

(cmdA; cmdB) | less

What I really would like is to automatically avoid getting a 100 page output at once but instead have a more-like behavior of bash'es stdout. As could be accomplished by adding

 2>&1 | more

to all commands entered on command promt - just automatically.

share|improve this question
    
To vi and less and su commands as well? How are those going to get input from you if more is taking it? –  Stephane Chazelas Jun 20 '13 at 10:18
    
Good point...*question closed* –  0815ZED Jun 20 '13 at 10:24
    
Running your shell inside Emacs has a lot of nice features. Of course, if you are a victim, the cause may already be lost. –  tripleee Jun 20 '13 at 12:21
    
Good idea - obviously I wouldn't do emacs: but for members of the "cult of VI": vim.org/scripts/script.php?script_id=2771 –  0815ZED Jun 21 '13 at 9:01
add comment

1 Answer

up vote 1 down vote accepted

Your question is not specific enough as to what you are trying to achieve. I'll take a few guesses:

If you would like to keep track of anything that happens in a session, use script. See man script for more information.

If you would like to combine the output of multiple commands into one block piped into less use braces like so:

(date; echo; cat /etc/hosts; echo; cat /etc/resolv.conf; echo; host bla.bla) | less

Using more concurrently while typing into the shell won't work as both the shell as well as less will want to read the keyboard from stdin. That's why we have page up and down and search facilities in terminal programs nowadays.

share|improve this answer
    
Hi Coroos, thanks for your quick reply. I am aware of script and command-grouping. What I meant is like adding a ' 2>&1 | more' to the end of each command I enter. –  0815ZED Jun 20 '13 at 8:41
    
Ok, with the comment of Stephane Chazelas I understood your last point - didn't think it through obviously...bash cannot distinguish whether the stdout of a program is applicable for more or whether it is "live" (as vi output) –  0815ZED Jun 20 '13 at 10:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.