Hacker News new | ask | show | jobs
by CupOfJava 3232 days ago
What's allowing the terminal to display the current git branch on the input line?

What's allowing the pretty path view instead of my ugly ascii "~/blah1/blah2$ ?

4 comments

Most shells let you do some arbitrary work before/during the display of the prompt line (in Bash, you can use `PS1` and `PROMPT_COMMAND`). Some people then install special fonts that let them render these fancy “bar segment” things. [Powerline](https://github.com/powerline/powerline) is a notable package for this, but there’s a lot of simpler alternatives out there nowadays.
I used https://github.com/magicmonty/bash-git-prompt for a long time - it's a bunch of bash scripts that show git info for directories that are git repositories.

I've since switched to the fish shell (https://fishshell.com/) which has this built in.

It doesn't matter which shell you use, all the common ones have some kind of plugins or extensions for that.

The shell, likely zsh with a special prompt config