Commit ad626cb7 authored by James Hillyerd's avatar James Hillyerd Committed by Bruno Pinto

Use __fish_git_prompt

parent 1e042773
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
A simple two-line theme best displayed on a terminal configured with Solarized A simple two-line theme best displayed on a terminal configured with Solarized
Dark colors. Dark colors.
⌈`user@host ~/c/w/dir (branch+)` user@host ~/c/w/dir (branch *)
⌊`%` %
Characteristics: Characteristics:
- Uses the fish prompt_pwd, so paths will be abbreviated - Uses the fish prompt_pwd, so paths will be abbreviated
- Git branch name will be followed by a red + if dirty - Uses built-in __fish_git_prompt functionality
- Indicates Git work-in-progress (gwip/gunwip) if detected - Indicates Git work-in-progress (gwip/gunwip) if detected
- Tradition bourne prompt characters: $ for user, # for root - Tradition bourne prompt characters: $ for user, # for root
- Prompt character is colored red if previous command had a non-zero exit - Prompt character is colored red if previous command had a non-zero exit
......
function fish_prompt function fish_prompt
# Cache exit status
set -l last_status $status set -l last_status $status
# Setup colors
set -l normal (set_color normal) set -l normal (set_color normal)
set -l red (set_color red) set -l red (set_color red)
set -l cyan (set_color cyan) set -l cyan (set_color cyan)
set -l white (set_color white) set -l white (set_color white)
set -l gray (set_color -o cyan) set -l gray (set_color -o cyan)
set -l green (set_color green)
set -l brwhite (set_color -o white) set -l brwhite (set_color -o white)
# Color prompt char red if something failed # Configure __fish_git_prompt
set -l pcolor $red set -g __fish_git_prompt_showdirtystate true
if test $last_status = 0 set -g __fish_git_prompt_showuntrackedfiles true
set pcolor $gray set -g __fish_git_prompt_showstashstate true
set -g __fish_git_prompt_color green
set -g __fish_git_prompt_color_flags red
# Color prompt char red for non-zero exit status
set -l pcolor $gray
if test $last_status -ne 0
set pcolor $red
end end
# Traditional prompt chars # Traditional prompt chars
...@@ -20,25 +29,12 @@ function fish_prompt ...@@ -20,25 +29,12 @@ function fish_prompt
set pchar = '#' set pchar = '#'
end end
# Determine git branch
set -l git_branch (begin
git symbolic-ref HEAD; or \
git rev-parse --short HEAD
end ^/dev/null | sed -e 's|^refs/heads/||')
# Line 1 # Line 1
echo -n $red'┌'$cyan$USER$white'@'$cyan(hostname -s)' '$gray(prompt_pwd)$normal echo -n $red'┌'$cyan$USER$white'@'$cyan(hostname -s)' '$gray(prompt_pwd)$normal
if test -n "$git_branch" __fish_git_prompt
echo -n ' '$green'('$git_branch # Check for gwip; does last commit log contain --wip--?
set -l dirty (command git status -s --ignore-submodules=dirty ^/dev/null | tail -n1) if begin git log -n 1 ^/dev/null | grep -qc "\-\-wip\-\-"; end
if test -n "$dirty" echo -n $brwhite' WIP!'$normal
echo -n $red'+'
end
echo -n $green')'
# Check for gwip; does last commit log contain --wip--?
if begin git log -n 1 ^/dev/null | grep -qc "\-\-wip\-\-"; end
echo -n $brwhite' WIP!'$normal
end
end end
echo echo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment