about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--fish/.config/fish/functions/fish_right_prompt.fish20
-rw-r--r--fish/.config/fish/functions/git_branch.fish5
-rw-r--r--fish/.config/fish/functions/is_git.fish3
-rw-r--r--fish/.config/fish/functions/is_git_ahead.fish4
-rw-r--r--fish/.config/fish/functions/is_git_dirty.fish3
5 files changed, 35 insertions, 0 deletions
diff --git a/fish/.config/fish/functions/fish_right_prompt.fish b/fish/.config/fish/functions/fish_right_prompt.fish
new file mode 100644
index 0000000..50a5f13
--- /dev/null
+++ b/fish/.config/fish/functions/fish_right_prompt.fish
@@ -0,0 +1,20 @@
+function fish_right_prompt
+    if is_git
+	if is_git_dirty
+	    set_color --underline
+	end
+
+        set_color yellow
+
+	if is_git_ahead
+            echo -n '^'
+	else
+	    echo -n '='
+	end
+	echo -n ' '
+
+        echo -n (git_branch)
+        set_color normal
+    end
+end
+
diff --git a/fish/.config/fish/functions/git_branch.fish b/fish/.config/fish/functions/git_branch.fish
new file mode 100644
index 0000000..e3507d0
--- /dev/null
+++ b/fish/.config/fish/functions/git_branch.fish
@@ -0,0 +1,5 @@
+function git_branch
+	if is_git
+echo (git rev-parse --abbrev-ref HEAD ^/dev/null)
+end
+end
diff --git a/fish/.config/fish/functions/is_git.fish b/fish/.config/fish/functions/is_git.fish
new file mode 100644
index 0000000..8bc6dd2
--- /dev/null
+++ b/fish/.config/fish/functions/is_git.fish
@@ -0,0 +1,3 @@
+function is_git
+	git symbolic-ref HEAD > /dev/null ^&1
+end
diff --git a/fish/.config/fish/functions/is_git_ahead.fish b/fish/.config/fish/functions/is_git_ahead.fish
new file mode 100644
index 0000000..31b9ce7
--- /dev/null
+++ b/fish/.config/fish/functions/is_git_ahead.fish
@@ -0,0 +1,4 @@
+function is_git_ahead
+	set -l revs (git rev-list origin/(git_branch)..HEAD ^/dev/null)
+[ "$revs" != "" ]
+end
diff --git a/fish/.config/fish/functions/is_git_dirty.fish b/fish/.config/fish/functions/is_git_dirty.fish
new file mode 100644
index 0000000..8511943
--- /dev/null
+++ b/fish/.config/fish/functions/is_git_dirty.fish
@@ -0,0 +1,3 @@
+function is_git_dirty
+	is_git; and [ (git status | tail -n1) != "nothing to commit, working tree clean" ]
+end