Adding a newline above PS1 that survives prepending
1
vote
2
answers
176
views
In OBSD ksh, I had a PS1 which prepended a blank line:
PS1="\n[\u@\h] \w\n\$"
The problem with this was that pyenv prepends the name of a virtual environment when that environment is activated. Here is the relevant bit of the pyenv activation script:
PS1="(porcupine) ${PS1:-}"
This eats the blank line, turning
[myusername@myhostname] ~/some/path $ echo foo
foo
[myusername@myhostname] ~/some/path $
into
(virtual-environment-name)
[myusername@myhostname] ~/some/path $ echo foo
foo
(virtual-environment-name)
[myusername@myhostname] ~/some/path $
This is annoying, so I tried to fix it with tput:
PS1_TEXT="[\u@\h] \w\n\$ "
PS1="$(tput sc il1 nw)$(tput rc DO 1)\n$PS1_TEXT"
This moves the cursor to the row above the virtual environment name, makes it a blank line, then returns and sticks in my original PS1.
This almost works, but when I hit the bottom of the terminal window, the virtual environment name vanishes. This is annoying, again.
Asked by user1093043
(103 rep)
Aug 2, 2023, 08:59 PM
Last activity: Aug 3, 2023, 01:16 PM
Last activity: Aug 3, 2023, 01:16 PM