Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Git bash on windows 7. Sometimes, when I am in a folder with a lot of files and when I type

$ ls

the shell displays more than one screen's worth of contents. In order to look at the complete results, I have to reach for the mouse and do some scrolling. Is there any way by which I can scroll through the shell window with just the keyboard?

[(Not so optimal)Fix 1] I know that you can achieve the result of scrolling through the results using

$ ls | less

but i feel adding the | less every time is too much work. So please don't suggest this as an answer.

[EDIT 1] The use of ls here is just as an example of any command that returns an output of more than one screen. So please don't center your answers around the ls command and offer answers that solve the problem of scrolling on the command prompt with the keyboard

share|improve this question
    
@MaQleod. I notice that you have edited this post. Yet I dont see a message saying what you have edited. I am not sure whether this is the right place for this question.Where can i see what changes you have made –  Prasanth Jun 9 '11 at 5:11
    
clicking on the edit age ("1 hour ago" now) above his name will take you to the history. –  heavyd Jun 9 '11 at 5:28
add comment

2 Answers

up vote 0 down vote accepted

"Scrolling the Windows [Console] With Only the Keyboard"

That the article talks about cmd.exe is irrelevant; all shells that use the Windows console work the same way in this regard.

share|improve this answer
    
the solution works. But I am still looking for something more elegant. With this solution, everytime I want to scroll, I have 4 extra keystrokes to do (Alt+Space, E, L and later the Esc) but I am wondering if you could do something like Ctrl + Up, Ctrl + Down to scroll without doing any of the extra stuff –  Prasanth Jun 10 '11 at 3:51
    
Sure, if you use a different console. –  Ignacio Vazquez-Abrams Jun 10 '11 at 3:52
    
which console supports that? currently, I am using Git Bash on Windows 7. I think I should look at Console2. Have you tried it ? –  Prasanth Jun 10 '11 at 4:02
    
I don't do Windows, sorry. –  Ignacio Vazquez-Abrams Jun 10 '11 at 4:04
add comment

I would create the ~/.bashrc file if it doesn't exists and add a function which overrides ls to ls | less so that you always get the less-ed version.

To edit your .bashrc type:

notepad.exe ~/.bashrc

Or use whatever editor you're comfortable with. Notepad will ask you to create the file if it doesn't exist. Now add this to your newly created .bashrc and save it:

function ls() { /bin/ls "$@" | less ;}

Now you will always get /bin/ls | less and and arguments will be passed to the "ls" command, not less.

share|improve this answer
    
as I have mentioned in my [EDIT 1], i use ls just as an example, I am sorry if I was unclear. I cannot use your solution because, i expect to scroll with the keyboard for any command - be it ls, or ipconfig or whatever –  Prasanth Jun 9 '11 at 5:50
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.