Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest tag support #64

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# set -g theme_display_git no
# set -g theme_display_git_untracked no
# set -g theme_display_git_ahead_verbose yes
# set -g theme_display_git_latest_tag no
# set -g theme_git_worktree_support yes
# set -g theme_display_vagrant yes
# set -g theme_display_docker_machine no
Expand Down Expand Up @@ -51,16 +52,23 @@
# end

function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish)'
if [ "$theme_display_git_latest_tag" = 'yes' ]
set -l latest_tag_value (command git describe --abbrev=0 --tags 2> /dev/null)
if [ "$latest_tag_value" != '' ]
set latest_tag " $__bobthefish_latest_tag_glyph$latest_tag_value"
end
end

set -l ref (command git symbolic-ref HEAD ^/dev/null)
and echo $ref | sed "s#refs/heads/#$__bobthefish_branch_glyph #"
and echo "$ref$latest_tag" | sed "s#refs/heads/#$__bobthefish_branch_glyph #"
and return

set -l tag (command git describe --tags --exact-match ^/dev/null)
and echo "$__bobthefish_tag_glyph $tag"
and echo "$__bobthefish_tag_glyph $tag$latest_tag"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will echo the same thing twice. if you're exactly on a tag, like you would be here, git describe --tags --abbrev=0 and git describe --tags --exact-match have the exact same value :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will, but that's kind of the point. If you are in the latest tag it's a confirmation of that fact. I can see that the tag I'm in and the latest are one and the same.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been using this for the past 25 days and it's REALLY useful. I hope other people will find it useful as well.

and return

set -l branch (command git show-ref --head -s --abbrev | head -n1 ^/dev/null)
echo "$__bobthefish_detached_glyph $branch"
echo "$__bobthefish_detached_glyph $branch$latest_tag"
end

function __bobthefish_hg_branch -S -d 'Get the current hg branch'
Expand Down Expand Up @@ -762,6 +770,7 @@ function fish_prompt -d 'bobthefish, a fish theme optimized for awesome'
# Additional glyphs
set -l __bobthefish_detached_glyph \u27A6
set -l __bobthefish_tag_glyph \u2302
set -l __bobthefish_latest_tag_glyph \u205D
set -l __bobthefish_nonzero_exit_glyph '! '
set -l __bobthefish_superuser_glyph '$ '
set -l __bobthefish_bg_job_glyph '% '
Expand Down