From f7a95a96fe66a13e6055ef15ee990d348d238d8e Mon Sep 17 00:00:00 2001 From: Felipe Rodrigues Date: Fri, 4 Apr 2014 17:26:17 -0300 Subject: [PATCH] added integral theme --- themes/integral/fish_prompt.fish | 56 ++++++++++++++++++++++++++++++++ themes/integral/readme.md | 10 ++++++ 2 files changed, 66 insertions(+) create mode 100644 themes/integral/fish_prompt.fish create mode 100644 themes/integral/readme.md diff --git a/themes/integral/fish_prompt.fish b/themes/integral/fish_prompt.fish new file mode 100644 index 0000000..d82d47b --- /dev/null +++ b/themes/integral/fish_prompt.fish @@ -0,0 +1,56 @@ +# name: Integral +function _git_branch_name + echo (command git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||') +end + +function _git_vs_upstream + set -l count (command git rev-list --count --left-right "origin/$argv"...HEAD ^/dev/null) + switch $count + case "" # no upstream + echo '' + case "0?0" # equal to upstream + echo '' + case "0??" # ahead of upstream + echo u+ + case "??0" # behind upstream + echo u- + case '???' # diverged from upstream + echo u+- + end +end + +function _is_git_dirty + echo (command git status -s --ignore-submodules=dirty ^/dev/null) +end + +function fish_prompt + set -l blue (set_color blue) + set -l yellow (set_color yellow) + set -l normal (set_color normal) + set -l green (set_color green) + + set -l arrow "∫" + set -l cwd $blue(basename (prompt_pwd)) + + if [ (_git_branch_name) ] + set -l git_branch (_git_branch_name) + set -l git_vs_upstream (_git_vs_upstream $git_branch) + + if [ (_is_git_dirty) ] + set git_info $yellow '('$git_branch "±" "$git_vs_upstream"')' $normal + else if [ (_git_vs_upstream $git_branch) ] + set git_info $yellow '('$git_branch "$git_vs_upstream"')' $normal + else + set git_info $green '('$git_branch')' $normal + end + end + + echo -n -s $cwd "$git_info" $normal $arrow ' ' +end + +function fish_right_prompt + set -l dark_gray (set_color 222) + + echo -n -s $dark_gray ' ['(date +%H:%M:%S)'] ' + +end diff --git a/themes/integral/readme.md b/themes/integral/readme.md new file mode 100644 index 0000000..bf16dbf --- /dev/null +++ b/themes/integral/readme.md @@ -0,0 +1,10 @@ +## integral + +A simple git upstream theme. + +#### Characteristics + +* Current branch +* Dirty working directory +* Working directory +* Git upstream status \ No newline at end of file