Last active
April 10, 2019 16:48
-
-
Save hospadar/42cc466cbada770a859022c53f1bc77f to your computer and use it in GitHub Desktop.
ultimate_prompt.fish
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
#version of my ultimate prompt for the fish shell. MUCH easier to read! | |
function find_git_branch | |
# Based on: http://stackoverflow.com/a/13003854/170413 | |
set -l git_branch (git rev-parse --abbrev-ref HEAD 2> /dev/null) | |
if [ -z "$git_branch" ] | |
echo -n "" | |
else | |
if [ "$git_branch" = "HEAD" ] | |
echo -n ' detached*' | |
end | |
echo -n " $git_branch" | |
end | |
end | |
function find_git_dirty | |
set -l git_status (git status --porcelain 2> /dev/null) | |
if [ "$git_status" != "" ] | |
return 0 | |
else | |
return 1 | |
end | |
end | |
function date_series | |
set -l START (date -jf '%Y-%m-%d' $argv[1] +%s) | |
set -l END (date -jf '%Y-%m-%d' $argv[2] +%s) | |
if [ $START -lt $END ] | |
while [ $START -le $END ] | |
echo (date -jf '%s' $START +%Y-%m-%d) | |
set -l START (echo "$START + 24 * 60 * 60" | bc) | |
end | |
else | |
echo "end date must be greater than start date" | |
end | |
end | |
function fish_prompt | |
set -l last_status $status | |
set_color brred | |
echo -n (date +%H:%M) | |
set_color normal | |
echo -n "|" | |
set_color bryellow | |
echo -n (prompt_hostname) | |
set_color normal | |
echo -n ":" | |
set_color brblue | |
echo -n (prompt_pwd) | |
set_color normal | |
if [ -n find_git_branch ] | |
if find_git_dirty | |
set_color red | |
else | |
set_color green | |
end | |
find_git_branch | |
echo -n " " | |
end | |
set_color normal | |
if [ $last_status = 0 ] | |
set_color brgreen | |
echo -n ":)" | |
else | |
set_color brred | |
echo -n ":(" | |
end | |
set_color normal | |
echo -n " " | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment