kuda.ai

Thoughts on programming and music theory.

Better Terminal Prompt (easy)

Created on July 2, 2025 Updated on July 8, 2025

terminals

The default prompt is not ideal to help you at the terminal. With a simple update of the PS1 (bash) or the PROMPT (zsh) env var, you can have a much better terminal experience.

on my own mac or Linux, I use the fantastic starship.rs to make my shell look great.

I spend a lot of times on remote servers. e.g. on build agents or on servers running apps.

When I login to remote servers, I don’t want to install my usual shell tools such as starship, fzf or others.

I was living with the regular shell prompt for a long time. But it makes the user experience very different.

I have just discovered a very nice and simple way to 10x your user experience on the shell.

# .zshrc
PROMPT=$'\n%n@%m on %~\n%# '

# .bashrc
PS1='\n\u@\h on \w\n\$ '

This makes the shell look as follows (examples run in a debian docker container):

before:

❯ docker run --rm -ti debian

root@7540a5ffcec9:/# echo hello world
hello world
root@7540a5ffcec9:/# pwd
/
root@7540a5ffcec9:/# mkdir -p Users/david/
root@7540a5ffcec9:/# cd Users/david
root@7540a5ffcec9:/Users/david# ls
root@7540a5ffcec9:/Users/david# <your-prompt-is-here>

after:

❯ docker run --rm -ti debian

root@c82e7b0da17a:/# PS1='\n\u@\h on \w\n\$ '

root@c82e7b0da17a on /
# echo hello world
hello world

root@c82e7b0da17a on /
# pwd
/

root@c82e7b0da17a on /
# mkdir -p Users/david

root@c82e7b0da17a on /
# cd Users/david/

root@c82e7b0da17a on /Users/david
# ls

root@c82e7b0da17a on /Users/david
# <your-prompt-is-here>

You can add colors like so:

# zsh:
# syntax: %F{color}very-prompt-such-wow%f
export PROMPT=$'\n%F{magenta}%n%f%F{cyan}@%m%f on %F{blue}%~%f\n%# '

# bash:
PS1='\n\[\e[32m\]\u@\h\[\e[0m\]:\[\e[34m\]\w\[\e[0m\]\n\$ '

On Powershell:

function prompt { "`n$env:USERNAME@$env:COMPUTERNAME on $(Get-Location)`nPS> " }