diff --git a/README.md b/README.md index d856f219..aa2584bf 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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. diff --git a/fish_prompt.fish b/fish_prompt.fish index ec8e23ae..149dfd24 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -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