Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
2 votes
2 answers
3k views

How to insert bash scripts inside the PS1 variable

I made a custom PS1 variable, which is a tremendously confusing. Here is the one that is closest to being fully working: PS1="\n[\e[1;31m]\u@\H[\e[35m] \@ [\e[32m] PWD: \w [\e[1;34m]This folder has ...
SOMN's user avatar
  • 1,121
0 votes
1 answer
139 views

Prompt Customization Query - PS1='[\u@\h]\!:echo $? $ '

If in .bashrc the following reports the 'history number of the current command' (and the exit code of the last command), how can I configure it to report the 'history number of the previous command'? ...
user98496's user avatar
  • 733
40 votes
2 answers
12k views

Linux: coloring bash prompt will break carriage return

When I try to colorize the bash prompt like this: export PS1="\e[0;31m[\u@\h \W]\$ \e[m " it breaks the carriage return (instead of going to a new line when line is full, it starts in the same line ...
Abonec's user avatar
  • 502
1 vote
1 answer
177 views

Formatting my $PS1 to x amount of character

I'm looking for a way to force my PS1 variable to a certain number of chars. It currently looks like: $PS1="\W $" and I'm trying to keep the same number of characters regardless of the length of ...
cmwright's user avatar
  • 123