Created
February 24, 2017 11:24
-
-
Save Samathy/5b0b70f7b7d3002029f7587ea093df21 to your computer and use it in GitHub Desktop.
Change the colour of the fish shell git prompt if source files are newer than build files. Set your prompt to fish_git_prompt then. Add this line to the bottom of ~/.config/fish/functions/fish_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
#Tests if source files listed are newer than the build | |
set currentTime 0 | |
set rebuild false | |
if test -e (pwd)"/"srcList.fish; and test -e (pwd)"/"buildList.fish | |
for file in (strings (pwd)"/"srcList.fish) | |
if test (stat -c '%Y' $file) -ge $currentTime | |
set currentTime (stat -c '%Y' $file) | |
end | |
end | |
for file in (strings (pwd)"/"buildList.fish) | |
if test (stat -c '%Y' $file) -lt $currentTime | |
set rebuild true | |
end | |
end | |
end | |
if test $rebuild = true | |
echo -n -s (set_color$fish_color_user) "$USER" $normal @ (set_color $fish_color_host) "$__fish_prompt_hostname" $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (set_color $fish_color_git) (__fish_git_prompt) $normal $prompt_status "$mode_str" "> " | |
else | |
echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $fish_color_host) "$__fish_prompt_hostname" $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (__fish_git_prompt) $normal $prompt_status "$mode_str" "> " | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment