mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-12-16 03:40:57 +01:00
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:
parent
7732bc7c52
commit
1ad54203d2
@ -12,12 +12,19 @@ function fish_prompt
|
|||||||
set_color magenta; echo -n "($PWD)"
|
set_color magenta; echo -n "($PWD)"
|
||||||
else
|
else
|
||||||
set pwd (basename $PWD)
|
set pwd (basename $PWD)
|
||||||
|
set branch (git branch ^/dev/null | sed -n '/\* /s///p')
|
||||||
|
|
||||||
if [ $pwd = $USER ]
|
if [ $pwd = $USER ]
|
||||||
set pwd "~"
|
set pwd "~"
|
||||||
end
|
end
|
||||||
|
|
||||||
set_color magenta; echo -n "$pwd"
|
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 normal; echo -n " "
|
||||||
set_color red; echo -n "➤"
|
set_color red; echo -n "➤"
|
||||||
set_color green; echo -n "➤"
|
set_color green; echo -n "➤"
|
||||||
|
Loading…
Reference in New Issue
Block a user