2

I'm using the default terminal command prompt on Ubuntu 12.04. When I'm doing something on the prompt (as opposed to editing in VI) the scrolling starts when the text reaches bottom of the screen. I don't like that because I have to keep my eyes always at the bottom of the screen. I would prefer if there were an option to start scrolling things up when we reach a particular fraction of vertical screen size. Currently I just use clear screen (CTRL+L) but it's tedious to do that every time. I don't like resizing command prompt because the background distracts me and I have to resize it each time in a new session. Is there some way to do scroll when prompt fills until a particular fraction (say 70%)?

4

I'm using gnome-terminal as my console and it respects the vt100 set scroll region Control character Sequence.

$ cat setscroll.sh 
function min(){
  if [[ $1 -le $2 ]]; then echo $1; else echo $2; fi
}

function max(){
  if [[ $1 -ge $2 ]]; then echo $1; else echo $2; fi
}

function setscrollregion(){
  CLR="\033[2J"
  SRGN="\033[1;"$1"r"
  echo -ne $CLR$SRGN
}

function calcline(){

  set `stty size` $1            # ;echo height=$1 width=$2 perc=$3
  bline=$(( ($1 * $3 ) / 100  ))    # calculate bottom line
  bline=$( min $bline $1)       # max is screen height
  bline=$( max 5 $bline)        # min is 5 lines customise as you wish
  echo $bline
}

setscrollregion $(calcline $1)

Then,

$ bash ./setscroll.sh 50

will set the scroll region to 50% of height

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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