PS1 modified lags

The string property is not properly closed by default
You have to add a layer of closure by adding unprintable brackeys

Example 1 : We want Hello World in green as our prompt
	Without brackeys:
    	PS1="\033[1;32m Hello World \033[00m"
    With brackeys (no text-wrapping):
    	PS1="\[ \033[1;32m \] Hello World \[ \033[00m \]"

//note : I added spaces for more clarity but they are printed if you add them

Example 2 : My prompt
	PS1="\[\033[1;32m\]\u@\h\[\033[00m\] [ \[\033[38;5;215m\]\[\e[5m\]\w\[\e[25m\]\[\033[00m\] ] "

//note : I have my username and machine in green and the folder i'm in coloured in blinking orange

Ressource for colours and effects :
	"https://misc.flogisoft.com/bash/tip_colors_and_formatting"

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source