Segments

Click to add. Reorder with the arrows, set a colour per segment.

    Preview

    bash

    Add this to ~/.bashrc

    Open ~/.bashrc in an editor, paste at the end, save, then run source ~/.bashrc. Your old prompt comes back if you remove the lines. On macOS (zsh by default) run bash first, or see the prompt guide.

    How Bash prompts work

    Bash draws your prompt from the PS1 variable. Backslash codes such as \u (user), \h (host) and \w (current directory) are replaced each time the prompt appears. Colours are ANSI escape codes like \e[1;32m; wrapping them in \[ \] tells Bash they take up no space, so long commands wrap correctly.

    The git branch and exit-status segments use small shell functions, which this tool adds for you. Read the full guide to customizing your Bash prompt to go further.