Skip to content

Instantly share code, notes, and snippets.

@b-rucel
Created March 5, 2025 23:33
Show Gist options
  • Save b-rucel/25272dce27a725ae7eaccfc6a8b02319 to your computer and use it in GitHub Desktop.
Save b-rucel/25272dce27a725ae7eaccfc6a8b02319 to your computer and use it in GitHub Desktop.
git_branch() {
local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ -n "$branch" ]]; then
echo "${git_color}${branch}${reset} "
fi
}
git_color=$(tput setaf 2) # green
dir_color=$(tput setaf 6) # cyan
reset=$(tput sgr0)
if [[ $UID -eq 0 ]]; then
PROMPT=' %n %1~ $(git_branch)💀 ' # root user
else
PROMPT=' %n ${dir_color}%1~${reset} $(git_branch)👺 ' # normal user
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment