Skip to content

Instantly share code, notes, and snippets.

@mrcat323
Last active March 29, 2021 17:00
Show Gist options
  • Save mrcat323/ebc186cb7e706a7f4473bf664c345c27 to your computer and use it in GitHub Desktop.
Save mrcat323/ebc186cb7e706a7f4473bf664c345c27 to your computer and use it in GitHub Desktop.
Changing bash like a pro

I edited a bit @vankasteelj's stuff and made something like zsh, to react to git's changes image

If there are some changes then the color changes to orange or whatever, like in zsh (or fish also, I don't know) so, to do that, you need to create a function

function changes_in_branch() { 
    if [ -d .git ]; then
	if expr length + "$(git status -s)" 2>&1 > /dev/null; then     
	    echo -ne "\033[0;33m$(__git_ps1)\033[0m"; 
	else
	    echo -ne "\033[0;32m$(__git_ps1)\033[0m"; fi; 
    fi
}

and then simply just add that function to the PS1 stuff. Just like this:

PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \[\033[0;36m\]\h \w\[\033[0m\]$(changes_in_branch)\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment