Reputation: 111
I'm currently customizing my terminal/bash command prompt for my mac. I was wondering if there was a way to keep the actually prompt in the middle/top top of page after running each command. I hate when it gets to the bottom of the screen then I have to clear it to get back to the top.
Upvotes: 3
Views: 4137
Reputation: 28406
Personally, I prefer the prompt at the bottom of the terminal, so I have this in my ~/.bashrc
:
__prompt_to_bottom_line() {
tput cup $LINES
}
alias clear='clear && __prompt_to_bottom_line'
__prompt_to_bottom_line
You can easily adapt it, e.g. by changing $LINES
to $(( LINES / 2 ))
you want it at the center of the screen.
Upvotes: 1
Reputation: 121
This answer seems to nearly work for me with some amendment but it still displays some odd behaviour:
PS1=$'\n\n\n\n\n\n\n\n\e[8A'"$PS1"
From: https://unix.stackexchange.com/a/698626
Upvotes: 1
Reputation: 531055
You can use an ANSI escape character to reposition the cursor prior displaying the prompt, but I don't think you're going to like the result; it's going to put the prompt above or on top of the output from the previous command.
PS1='\[\e[1;1H\]> '
"1;1" here represents the upper left-hand corner; you can vary the numbers to choose a different row/column if desired.
Upvotes: 2