Skip to content

Instantly share code, notes, and snippets.

@jerinisready
Created March 10, 2026 09:59
Show Gist options
  • Select an option

  • Save jerinisready/81cb9f682f532111adb93a72adb273c2 to your computer and use it in GitHub Desktop.

Select an option

Save jerinisready/81cb9f682f532111adb93a72adb273c2 to your computer and use it in GitHub Desktop.

If you want crazy but actually useful, build PS1 with runtime info (git, exit code, time, docker/k8s context). Static PS1s are boring.

Example:

parse_git_branch() {
  git rev-parse --abbrev-ref HEAD 2>/dev/null
}

parse_git_dirty() {
  [[ -n $(git status --porcelain 2>/dev/null) ]] && echo "*"
}

PS1='\[\e[32m\]\u@\h\[\e[37m\]:\[\e[34m\]\w \
\[\e[35m\]$(parse_git_branch)\[\e[31m\]$(parse_git_dirty) \
\[\e[33m\][\A] \
\[\e[0m\]\$ '

Example output:

root@rj:~/code/roja-pipeline shift-left-phase* [14:22] $

What this gives you:

  • green user@host
  • blue cwd
  • purple git branch
  • red * if repo dirty
  • yellow time
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment