wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.4k stars 137 forks source link

Strange searching in gcb #180

Closed timsofteng closed 2 years ago

timsofteng commented 2 years ago

Hello. When I invoke branch changing by gcb I would like to make search on branches names only. How can I enable it?

NullSense commented 2 years ago
gcb() {
  local tags branches target
  branches=$(
  git --no-pager branch --sort=-committerdate --all \
    --format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \
    | sed '/^$/d') || return
      tags=$(
      git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}') || return
      target=$(
      (echo "$branches"; echo "$tags") |
        fzf --no-hscroll --no-multi -n 2 \
        --ansi --preview="git log master..{2} --graph --pretty=format:'%Cgreen(%<(7,trunc)%cr) %C(bold blue)%<(7,trunc)<%an>%Creset %s %C(yellow)%d%Creset' --color=always --abbrev-commit --date=relative") || return
              git checkout "$(awk '{print $2}' <<<"$target" )"
            }

Here's a version I am using at the moment.

tommyalatalo commented 2 years ago

This is exactly the same as my issue https://github.com/wfxr/forgit/issues/167.

cjappl commented 2 years ago

PR's are welcome to address this issue! Agreed it looks the same as #167

tommyalatalo commented 2 years ago

I've opened PR #201 to fix this.