0

When you do find / in the native ubuntu terminal it prints output till the end of the screen. After this there is no empty scroll space available to scroll down. I temporarily solved this problem by clear function which adds additional scroll space. I do python programming in terminal and in it this doesn't work

for a in range(1000):
    print(a)

How I can hard code terminal to get some scroll empty space for both bash and python?

13
  • What do you have your terminal profile scroll buffer set to? Scrolling in such a situation is the default.
    – ubfan1
    Mar 10, 2019 at 3:31
  • Mine is limited to 8192 lines
    – Eka
    Mar 10, 2019 at 3:46
  • 2
    As far as I understand, your problem is that there is no empty space under the output of your utilities. New lines will automatically appear there and the existing content will scroll upwards whenever needed. What is your actual problem, what is it that doesn't work for you?
    – egmont
    Mar 10, 2019 at 23:39
  • 1
    @Eka Why do you need empty space?
    – wjandrea
    Mar 11, 2019 at 3:39
  • 2
    See superuser.com/questions/1106674/….
    – egmont
    Mar 11, 2019 at 10:48

1 Answer 1

1

Let's say you want three extra lines below your prompt.

In Bash, run this, and from then on, you will have the three extra lines:

PS1+="\[\eD\eD\eD\e[3A\]"

To make it permanent, put it in your ~/.bashrc.


The equivalent in Python uses sys.ps1:

import sys
sys.ps1 += '\x01\x1bD\x1bD\x1bD\x1b[3A\x02'

Or you could move the number of extra lines into a variable:

_ps1_extra_lines = 3
sys.ps1 += '\x01' + '\x1bD' * _ps1_extra_lines + '\x1b[A' * _ps1_extra_lines + '\x02'

To make it permanent, put it in a PYTHONSTARTUP file, which you may need to set up first.

Also note this is meant for the regular Python shell, and will not work in IPython, for example.


For explanation and more details, see How to add blank lines above the bottom in terminal - Super User.

2
  • I like a blank line before my prompt rather than after. Mar 13, 2019 at 15:15
  • @Win Me too, but that's too easy ;)
    – wjandrea
    Mar 13, 2019 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .