add git prompt
This commit is contained in:
parent
2a6e2bdf8c
commit
7a45a85686
1 changed files with 36 additions and 0 deletions
36
fish/.config/fish/functions/fish_prompt.fish
Normal file
36
fish/.config/fish/functions/fish_prompt.fish
Normal file
|
@ -0,0 +1,36 @@
|
|||
function __bcarlin_prompt_suffix
|
||||
set -l color_suffix
|
||||
set -l suffix "➜"
|
||||
|
||||
switch $USER
|
||||
case root toor
|
||||
if set -q fish_color_cwd_root
|
||||
echo root if
|
||||
set color_suffix $fish_color_cwd_root
|
||||
else
|
||||
set color_suffix $fish_color_cwd
|
||||
end
|
||||
case '*'
|
||||
set color_suffix $fish_color_cwd
|
||||
end
|
||||
|
||||
echo -n -s (set_color $color_suffix --bold) "$suffix" (set_color normal)
|
||||
end
|
||||
|
||||
function __bcarlin_prompt_git
|
||||
set -l git_branch (git rev-parse --abbrev-ref HEAD)
|
||||
if test $status -ne 0
|
||||
echo -n -s ''
|
||||
return
|
||||
end
|
||||
|
||||
echo -n -s (set_color blue) ± (set_color normal) '('
|
||||
echo -n -s (set_color red --bold) $git_branch (set_color normal)
|
||||
echo -n -s ')'
|
||||
end
|
||||
|
||||
function fish_prompt --description 'Write out the prompt'
|
||||
set -l _pwd (set_color $fish_color_cwd) (prompt_pwd)
|
||||
|
||||
echo -n -s "$USER" @ (prompt_hostname) ' ' $_pwd ' ' (__bcarlin_prompt_git) ' ' (__bcarlin_prompt_suffix) ' '
|
||||
end
|
Loading…
Add table
Reference in a new issue