Skip to content

Commit

Permalink
Stop truncating git branch names by default.
Browse files Browse the repository at this point in the history
I used to think this was awesome, but have come around. The option is still there if you want it. Set `theme_use_abbreviated_branch_name` to `yes` :)
  • Loading branch information
bobthecow committed Oct 2, 2019
1 parent 256f43b commit cf09661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ set -g theme_display_git_dirty_verbose yes
set -g theme_display_git_stashed_verbose yes
set -g theme_display_git_master_branch yes
set -g theme_git_worktree_support yes
set -g theme_use_abbreviated_branch_name yes
set -g theme_display_vagrant yes
set -g theme_display_docker_machine no
set -g theme_display_k8s_context yes
Expand Down Expand Up @@ -123,6 +124,7 @@ set -g theme_newline_prompt '$ '
- `theme_display_hostname`. Same behaviour as `theme_display_user`.
- `theme_show_exit_status`. Set this option to `yes` to have the prompt show the last exit code if it was non_zero instead of just the exclamation mark.
- `theme_git_worktree_support`. If you do any git worktree shenanigans, setting this to `yes` will fix incorrect project-relative path display. If you don't do any git worktree shenanigans, leave it disabled. It's faster this way :)
- `theme_use_abbreviated_branch_name`. Set to `yes` to truncate git branch names in the prompt.
- `fish_prompt_pwd_dir_length`. bobthefish respects the Fish `$fish_prompt_pwd_dir_length` setting to abbreviate the prompt path. Set to `0` to show the full path, `1` (default) to show only the first character of each parent directory name, or any other number to show up to that many characters.
- `theme_project_dir_length`. The same as `$fish_prompt_pwd_dir_length`, but for the path relative to the current project root. Defaults to `0`; set to any other number to show an abbreviated path.
- `theme_newline_cursor`. Use `yes` to have cursor start on a new line. By default the prompt is only one line. When working with long directories it may be preferrend to have cursor on the next line. Setting this to `clean` instead of `yes` suppresses the caret on the new line.
Expand Down
4 changes: 3 additions & 1 deletion fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function __bobthefish_git_branch -S -d 'Get the current git branch (or commitish
and return

# truncate the middle of the branch name, but only if it's 25+ characters
set -l truncname (string replace -r '^(.{28}).{3,}(.{5})$' "\$1…\$2" $ref)
set -l truncname $ref
[ "$theme_use_abbreviated_branch_name" = 'yes' ]
and set truncname (string replace -r '^(.{28}).{3,}(.{5})$' "\$1…\$2" $ref)

string replace -r '^refs/heads/' "$branch_glyph " $truncname
and return
Expand Down

1 comment on commit cf09661

@SkylerLS
Copy link

Choose a reason for hiding this comment

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

THANK YOU SO MUCH!

This is exactly what I was referring to here #196 (comment).

You adding a flag is the most pragmatic way of approaching this. I prefer to see the whole branch name.

I can't tell you how happy this makes me. You just made my entire week.

Cheers!!

Please sign in to comment.