summaryrefslogtreecommitdiffstats
path: root/.config/fish/config.fish
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2011-12-21 12:18:26 +0100
committerGravatar Tom Willemsen2011-12-21 12:18:26 +0100
commit2ca89c32f57dd7e2389a52926521a3593e7d6948 (patch)
tree19f9c19782c270935b19732c56981f47ed9b3222 /.config/fish/config.fish
parent79b2d1ba59eb83382a26042cfee0db116503a49b (diff)
downloaddotfiles-2ca89c32f57dd7e2389a52926521a3593e7d6948.tar.gz
dotfiles-2ca89c32f57dd7e2389a52926521a3593e7d6948.zip
FISH: show updates and the current git branch in prompt
Diffstat (limited to '.config/fish/config.fish')
-rwxr-xr-x.config/fish/config.fish31
1 files changed, 30 insertions, 1 deletions
diff --git a/.config/fish/config.fish b/.config/fish/config.fish
index c397118..17a8e2d 100755
--- a/.config/fish/config.fish
+++ b/.config/fish/config.fish
@@ -1,7 +1,36 @@
#! /usr/bin/fish
function fish_prompt -d "Write out the prompt"
- printf '(%s%s %s%s%s)> ' (set_color 'magenta') (hostname|cut -d . -f 1) (set_color $fish_color_cwd) (prompt_pwd) (set_color normal)
+ set last_status $status
+ set current_directory (prompt_pwd)
+ set git_branch (git branch --contains HEAD 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
+ set pac_cnt (cat /var/cache/pacman/updates.cnt)
+ set aur_cnt (cat /var/cache/pacman/aur.cnt)
+ set cnormal (set_color white)
+
+ echo -n $cnormal
+
+ if test $pac_cnt -gt 0 -o $aur_cnt -gt 0
+ printf '%s%d%s/%s%d%s:' (set_color cyan) $pac_cnt $cnormal (set_color cyan) $aur_cnt $cnormal
+ end
+
+ printf '%s%s%s' (set_color magenta) (hostname|cut -d . -f 1) $cnormal
+
+ if test -n "$current_directory"
+ printf ':%s%s%s' (set_color $fish_color_cwd) $current_directory $cnormal
+ end
+
+ if test -n "$git_branch"
+ printf '@%s%s%s' (set_color yellow) $git_branch $cnormal
+ end
+
+ if test $last_status -eq 0
+ printf '%s%s' (set_color --bold green)
+ else
+ printf '%s%s' (set_color --bold red)
+ end
+
+ printf '>%s ' (set_color normal)
end
function cower