bash-ps1 | Yet another bash PS1 utility | Script Programming library
kandi X-RAY | bash-ps1 Summary
kandi X-RAY | bash-ps1 Summary
Yet another bash PS1 utility.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of bash-ps1
bash-ps1 Key Features
bash-ps1 Examples and Code Snippets
Community Discussions
Trending Discussions on bash-ps1
QUESTION
My setup:
- zsh 5.7.1 (x86_64-apple-darwin19.0)
- macOS Catalina 10.15.5
Here's the standard PS1 var: PS1="%n@%m %~ %# "
Problems arise when I try adding text coloring using either ANSI colors or tput. Example (without terminating the color, it behaves oddly regardless of that):
PS1="%n@%m \e[38;5;197m%~ %# "
Here's what happens when I use Ctrl+R (reverse search):
What could be the reason for this indent?
Second problem happens when a long string in the prompt goes to the newline - new character after newline overlaps the first line and I can't see the latter. This happens only with the first newline, third one appears normally (but in second place).
I tried using this answer but the solution can't get parsed by the shell: rombez@MacBook-Pro \[\e[38;5;197m\]~
ANSWER
Answered 2020-Jul-17 at 12:50ANSI escape sequences don't take up any space on the terminal, so you have to tell zsh
that they don't contribute to the length of the prompt. You do this by wrapping them in %{...%}
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install bash-ps1
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page