Home ^[ escape in shell prompt
Reply: 0

^[ escape in shell prompt

user1048 Published in August 16, 2018, 6:14 am


I am writing an application in rust (for fun) that allows me to use DSL to pretty-print git repository stats into my bash shell prompt.

However, I am having an issue with the library I use to format text in the terminal. It uses an escape I haven't seen before, ^[, in the output. It seems to affect the line wrapping such that the text wraps onto the same line before the end of the terminal.

You can see here a demonstration in gnome shell and in hyper.


Create a file shell.txt with the following contents:


Set your prompt command to be the following:

__set_prompt() {
    PS1="$(cat shell.txt)"


What is the ^[ escape?

Is there a simple fix to get my shell to recognize the line width-properly?

bash --version 4.4.12(1)-release
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31426 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO