# .bashrc PAGER='vim -R -' # # least is a selective pager. If the file paged fits in the terminal it # will be sent to stdout (as if you used cat), if the lines paged do not # fit on one screen it will use your $PAGER. # # Someone commented that this is what 'less -FX' does -- which it does. # least is only useful if your PAGER != less ... like in my case. # # example: # cat file | least # least file1 file2 # # you can put this in your .bashrc # function least() { declare -a lines if ! [ -z "$@" ] ; then cat $@ | least return 0 fi if [ -z "$LINES" ] || ! ( echo $LINES | grep -q '^[0-9]\+$' ) ; then LINES=20 fi function dump_array () { for n in `seq 1 "${#lines[@]}"` ; do echo "${lines[$n]}" done } while read x ; do lines[((${#lines[@]}+1))]="$x" if [ "${#lines[@]}" -ge $LINES ] ; then ( dump_array ; cat ) | $PAGER exit 0 fi done dump_array } # # here is a macro that I use infront of commands that I want to see output of # # example: # v cvs log # function v() { $@ | least ; }