Bash Prompt

Customizing our Git Bash prompt can be a fun and useful way to personalize our terminal. Here's an example of a minimalistic Bash prompt that includes basic Git information:

~/workspace/showcase/projects/app-showcase (schedule-vertical)
λ

This prompt shows our current working directory and the name of the Git branch we're currently on. It's a great way to keep track of our work while navigating through the terminal.

function git_prompt {
  PS1='\[\033]0;Git Bash\007\]'          # set window title
  PS1="$PS1\[\033[01;34m\]"              # change color to blue
  PS1="$PS1\w"                           # current working directory
  PS1="$PS1\[\033[01;33m\]"              # change color to yellow
  PS1="$PS1$(__git_ps1)"                 # git info
  PS1="$PS1\[\033[32m\]"                 # change color green
  PS1="$PS1\n"                           # new line
  PS1="$PS1λ "                           # lamda
  PS1="$PS1\[\033[00m\]"                 # change color to white
}

export PROMPT_COMMAND=git_prompt

We can also customize our Bash prompt to include Git information using the following:

git_branch() {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1="\[\033[01;34m\]\w\[\033[01;33m\]\$(git_branch)\[\033[32m\]\nλ \[\033[00m\]"