Last active
December 25, 2017 11:35
-
-
Save kristerkari/5626386 to your computer and use it in GitHub Desktop.
Fish config/prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Port of the Bash version bundled with git | |
# Bodaniel Jeanes | |
function __git_ps1 | |
set -l g (git rev-parse --git-dir ^/dev/null) | |
if [ -n "$g" ] | |
set -l r "" | |
set -l b "" | |
if [ -d "$g/rebase" ] | |
if [ -f "$g/rebase/rebasing" ] | |
set r "|REBASE" | |
else if [ -f "$g/rebase/applying" ] | |
set r "|AM" | |
else | |
set r "|AM/REBASE" | |
end | |
set b (git symbolic-ref HEAD ^/dev/null) | |
else if [ -f "$g/rebase-merge/interactive" ] | |
set r "|REBASE-i" | |
set b (cat "$g/rebase-merge/head-name") | |
else if [ -d "$g/rebase-merge" ] | |
set r "|REBASE-m" | |
set b (cat "$g/rebase-merge/head-name") | |
else if [ -f "$g/MERGE_HEAD" ] | |
set r "|MERGING" | |
set b (git symbolic-ref HEAD ^/dev/null) | |
else | |
if [ -f "$g/BISECT_LOG" ] | |
set r "|BISECTING" | |
end | |
set b (git symbolic-ref HEAD ^/dev/null) | |
if [ -z $b ] | |
set b (git describe --exact-match HEAD ^/dev/null) | |
if [ -z $b ] | |
set b (cut -c1-7 "$g/HEAD") | |
set b "$b..." | |
end | |
end | |
end | |
if not test $argv | |
set argv " (%s)" | |
end | |
set b (echo $b | sed -e 's|^refs/heads/||') | |
printf $argv "$b$r" ^/dev/null | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -x EDITOR "subl" | |
set -x VISUAL $EDITOR | |
set -x GIT_EDITOR $EDITOR | |
set -x CLICOLOR 1 | |
set -U BROWSER "open -a Chrome" | |
set fish_color_git_branch green | |
set fish_color_cwd blue | |
set fish_color_uneditable_cwd red |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fish_prompt --description 'Write out the prompt' | |
set -l last_status $status | |
printf '%s%s%s ' (set_color green) (whoami) (set_color normal) | |
# Write the process working directory | |
if test -w "." | |
printf '%s%s' (set_color -o $fish_color_cwd) (prompt_pwd) | |
else | |
printf '%s%s' (set_color -o $fish_color_uneditable_cwd) (prompt_pwd) | |
end | |
printf '%s%s ' (set_color red) (__git_ps1) | |
if git_dirty | |
printf '%s⚡ ' (set_color yellow) | |
end | |
printf '%s ' (set_color -o $fish_color_cwd) (set_color normal) | |
if not test $last_status -eq 0 | |
set_color $fish_color_error | |
end | |
printf '\n↳ ' (set_color normal) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function git_dirty | |
if not is_git_repo | |
return 1 | |
end | |
not git diff HEAD --quiet ^/dev/null | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_git_repo | |
git status >/dev/null ^/dev/null | |
not test $status -eq 128 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment