I’m looking for inspiration for a custom Bash prompt[1]. I’d love to see yours! 😊 If possible, include both the prompt’s PS1
, and a screenshot/example of what it looks like.
References
- Type: Documentation. Title: “Bash Reference Manual”. Publisher: Gnu Project. Edition: 5.2. Published: 2022-09-19. Accessed: 2025-03-21T02:46Z. URI: https://www.gnu.org/software/bash/manual/html_node/index.html.
- §6.9 “Controlling the Prompt”. URI: https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html.
Crossposts:
C:\>
/s
Convert the PWD value to use backslashes, too, for extra cursedness.
c/FoundSatan
Do you have anything to check whether the current directory is under
/media/
or/mnt/
so that you can change the drive letter according to a deterministic assignment?/s
HA, that’s so cursed. I love it.
Mine shows the full path and a new line for commands.
It will also print the exit code of the last command in red above the prompt, if the exit code is not 0.
PS1='$(ec=“$?”; if [ $ec -gt 0 ]; then echo -e “\n”[\e[91m]“exit code: $ec”[\e[0m]; fi)\n[\e[92m]\u[\e[38;5;213m]@[\e[38;5;39m]\h[\e[0m]:$PWD\n$ ’
Mine is just status(if not zero) and wd
I use Starship
Same. I guess, this is the Starship thread now. My config:
I adapted it from the Gruvbox Rainbow theme.
I can post my config, if anyone wants specifically that. (It does kind of assume a light background, though.)Another starship user. Mostly want it to summarise useful stuff for folders pulled from git or whatever so it’s pretty plain rest of the time. I use the same on all my boxes
Ok after viewing your prompts I noticed that mine is kinda lame
[username@host ~]$ >
My shit is custom and rather elaborate.
From left-to-right:
- name@server-name
- Uptime (multiplied by 10 and rounded to the nearest integer to save space)
- Percentage disk space available on
/
- Number on established network connections
- Git branch
:
commit - Python virtualenv
- [new line]
- date and time
The code for this is on GitLab.
I use zsh, but my old Bash prompt looks almost the same as my Zsh prompt. Sorry, no screenshot, but here’s the code:
export PS1='\[\033[01;34m\][\[\033[01;37m\] \W\[\033[01;34m\]]\$\033[01;34m\] $(git branch 2>/dev/null | grep '^*' | colrm 1 2)\n\033[01;34m└─>\033[37m '
I’m using fish and the default is enough for anybody. 😁
I love it! You get git and virtual env integration for free :)
I recently started with fish and dislike that I can’t drop bash commands into it because it parses differently. That is enough to annoy me to uninstall.
You shouldn’t just “drop bash commands into it” anyways. And if you really need it, bash is only one
bash
away.
export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e[m\] \[\e[38;5;214m\]\W\[\e[m\]\[\e[31m\]]\[\e[m\]\\$ "
That’s a warcrime.
How so? What does this do?
Best I can tell is it’s a normal `username@hostname current_directory$ sorta prompt with some coloring: • Red for the square brackets • Orange (color 172) for the username • Light blue (color 153) for the hostname • Amber (color 214) for the current working directory
Other than being hard to read from the embedded coloring I’m not sure why this is a war crime.
Mine’s really simple; I just make the path bold and yellow:
What I like to do is change the colour depending on the machine I ssh into, e.g. make the path red on my Raspberry Pi.
Mine is simple (inspired by Kali Linux, if that’s even correct)
PS1='\[\033[0;32m\]┌──[\t] (\u@\h)-[\w]\n└─$ \[\033[0m\]'
computer /usr/share/ $>
export PS1="\[\e]0;\u@\h:\w\a\]\[\e[1;34m\]\u@\h:\w\[\e[0m\]\$ "
I am a simple man.
I didn’t even know I needed to edit my prompt, but now I don’t know how I have lived with it for so long.