Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
Last active January 5, 2022 12:23
Show Gist options
  • Select an option

  • Save hohonuuli/1c760b4c65f9ebc6e819110515939604 to your computer and use it in GitHub Desktop.

Select an option

Save hohonuuli/1c760b4c65f9ebc6e819110515939604 to your computer and use it in GitHub Desktop.
Fish prompt that displays Java, Python versions when appropriate
set -g __fish_prompt_grey A3A3A3
set -g __fish_git_prompt_char_cleanstate "✔"
set -g __fish_git_prompt_char_conflictedstate "✖"
set -g __fish_git_prompt_char_dirtystate "✚"
set -g __fish_git_prompt_char_stagedstate "●"
set -g __fish_git_prompt_char_stateseparator \U0020 #\Ue725
set -g __fish_git_prompt_char_untrackedfiles "…"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
set -g __fish_git_prompt_color $__fish_prompt_grey
set -g __fish_git_prompt_color_branch $__fish_prompt_grey
set -g __fish_git_prompt_color_cleanstate green
set -g __fish_git_prompt_color_dirtystate blue
set -g __fish_git_prompt_color_invalidstate red
set -g __fish_git_prompt_color_stagedstate yellow
set -g __fish_git_prompt_color_untrackedfiles $__fish_prompt_grey #$fish_color_normal
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_showcolorhints 1
set -g __fish_git_prompt_showupstream "informative"
# Needed if bobthefish is isntalled
set -g theme_display_date no
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
set -l pathcolor $__fish_prompt_grey
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
set_color $pathcolor
echo
printf '%s' (whoami)
printf '@'
printf '%s' (hostname|cut -d . -f 1)
printf ':'
# If current dir is not writable display it in red
if not [ -w (pwd) ]
set_color red
end
printf '%s' (pwd)
set_color normal
printf '%s' (__fish_git_prompt)
if not test $last_status -eq 0
set_color $fish_color_error
end
set_color $pathcolor
# Display Java version if in a java project
echo
if test -f pom.xml \
-o -f build.sbt \
-o -f build.gradle \
-o -f build.sc \
-o (count *.java) -gt 0
set_color blue
printf '\Ue256 %s' (java -version 2>&1 | grep -Eo '"(.*?)"' | head -1 | cut -d '"' -f2)
else if test (count *.py) -gt 0
set_color green
printf '\Ue235 %s' (python --version 2>&1 | grep -o "\d*\.\d*\.\d*")
end
printf '\UE0B1 '
set_color normal
end
Copy link
Copy Markdown

ghost commented Jun 12, 2021

@hohonuuli this should be enough or do i need to install any theme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment