How can I display the current branch and folder path in terminal?

It’s not about a plugin. It’s about prompt tricks in the shell.

For a cool setup in bash, check out the dotfiles project of this guy:

https://github.com/mathiasbynens/dotfiles

To get a fancy prompt, include the .bash_prompt in your ~/.bash_profile or ~/.bashrc.

To get the exact same prompt as in your question, change the export PS1 line at the end of .bash_prompt like this:

export PS1="\[${BOLD}${MAGENTA}\]\u\[$WHITE\]@\[$ORANGE\]\h\[$WHITE\]: [\[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" - \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]] \$ \[$RESET\]"

I ended up using all the .bash* files from this repository about a month ago, and it’s been really useful for me.

For Git, there are extra goodies in .gitconfig.

And since you’re a mac user, there are even more goodies in .osx.

Leave a Comment