Prompts with ANSI escape sequences |
|
|
Posted by: stak Tip of the day: If your shell uses the readline library (e.g. bash), and you have ANSI escape sequences in your prompt, you should surround the ANSI escape sequences with \001 and \002 so that readline knows they are "invisible characters". If you don't, readline can end up mis-positioning your cursor and generally screwing up the display.
export PS1='\u@\033[01;31m\h\033[m \W$ ' and that caused problems if for example I had a long command and used ctrl+a to get to the start of it.
export PS1='\u@\001\033[01;31m\002\h\001\033[m\002 \W$ ' and all is well.
|
(c) Kartikaya Gupta, 2004-2025. User comments owned by their respective posters. All rights reserved. You are accessing this website via IPv4. Consider upgrading to IPv6! |