meta: Add git branch information to fish prompt

If I stayed on zsh instead of switch to fish, I would've probably never
known how easy it is to add certain information to the prompt. Since
the prompt itself is just a function, you can run any commands you want
inside it to get information, including git commands.

This commit adds the current branch you're on only when inside a git
repository, and only when you're not in a tty.
This commit is contained in:
Donovan Glover 2018-12-05 11:35:16 -05:00
parent 7732bc7c52
commit 1ad54203d2
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65

View File

@ -12,12 +12,19 @@ function fish_prompt
set_color magenta; echo -n "($PWD)"
else
set pwd (basename $PWD)
set branch (git branch ^/dev/null | sed -n '/\* /s///p')
if [ $pwd = $USER ]
set pwd "~"
end
set_color magenta; echo -n "$pwd"
if [ "$branch" ]
set_color normal; echo -n " on "
set_color yellow; echo -n "$branch"
end
set_color normal; echo -n " "
set_color red; echo -n "➤"
set_color green; echo -n "➤"