Skip to content

How to show full branch name? #481

Open

Description

@chiphogg

(I know the project is close-to-unmaintained, but I'm hoping it will be very quick to point me in the right direction for how to solve this.)

I love this project, but the branch name abbreviation drives me absolutely batty. The way we use git at work, all my branches start with the same chiphogg/ prefix, which thus contains zero information. And the end of the branch often includes #PROJ-1234 suffixes, which all kinda blend together. The real useful information is in the middle!

I want to configure the prompt to print the full branch name, always, no matter how long it is. Which pathway(s) are available to me?

  1. Follow the copy-and-modify approach at the end of the bash section
  2. Provide a PR to add a new environment variable that a user can set, to gate what I assume is the truncation code
  3. Fork this project and delete the truncation code
  4. ...something else?

Thanks in advance!

Activity

  1. romkatv commented on Dec 3, 2025

    @romkatv
    Owner

    1 is a good option, and so is 3.

  2. chiphogg commented on Dec 3, 2025

    @chiphogg
    Author

    Thank you!

    Is (1) even an option, if the contents of where get unconditionally clobbered by the truncation code? I assume not --- so, therefore, I assume that (3) is the way to go.


    By the way, the act of choosing (3) means that also doing (2) would be a very small marginal effort. So, I'll probably put up a PR as well after I fork it. Given the status of this repo, I have no expectation that it will be merged... but, there's an outside chance that the PR ends up being both simple and desirable enough that you might merge it anyway.

    And if not, then the PR will end up linked to this issue, so others who want this functionality will be able to stumble upon it.

  3. added a commit that references this issue on Dec 4, 2025
    73e65fa
  4. romkatv commented on Dec 4, 2025

    @romkatv
    Owner

    For (1), you can start with this:

    source ~/gitstatus/gitstatus.plugin.sh
    
    function my_set_prompt() {
      PS1='\w'
    
      if gitstatus_query && [[ "$VCS_STATUS_RESULT" == ok-sync ]]; then
        if [[ -n "$VCS_STATUS_LOCAL_BRANCH" ]]; then
          PS1+=" ${VCS_STATUS_LOCAL_BRANCH//\\/\\\\}"  # escape backslash
        else
          PS1+=" @${VCS_STATUS_COMMIT//\\/\\\\}"       # escape backslash
        fi
        (( VCS_STATUS_HAS_STAGED"    )) && PS1+='+'
        (( VCS_STATUS_HAS_UNSTAGED"  )) && PS1+='!'
        (( VCS_STATUS_HAS_UNTRACKED" )) && PS1+='?'
      fi
    
      PS1+='\n\$ '
    
      shopt -u promptvars  # disable expansion of '$(...)' and the like
    }
    
    gitstatus_stop && gitstatus_start
    PROMPT_COMMAND=my_set_prompt

    Modify my_set_prompt as you like.

  5. chiphogg commented on Dec 7, 2025

    @chiphogg
    Author

    Thanks!

    I ended up creating #483, since I wanted to have the option to have a fully default prompt (apart from the abbreviation, of course). I've been using it for a few days, and it works great.

    The only downside I see to this approach is that it introduces a new discrepancy between the features for bash and zsh. My understanding is that they were already not at feature parity, so maybe that's OK, but I'll let you be the judge. Options I can see are:

    1. Reject the PR.
    2. Accept the PR; live with bash having a config option that zsh does not.
    3. Accept the PR after it supports zsh; move documentation outside of the bash section to somewhere more general.

    I'd have been happy to add zsh support, but I don't use zsh so it's not easy for me to test it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions