function peco_checkout_git_branch
  if git_is_repo
    git branch -a | peco | tr -d ' ' | read branch
    echo $branch
    if [ $branch ]
        if contains $branch "remotes/"
            set -l b (echo $branch | awk -F'/' '{print $3}')
            git checkout -b $b $branch
        else
            git checkout $branch
        end
    end
    commandline -f repaint
  else
    echo '.git?'
  end
end


function peco_checkout_git_branch
  if git_is_repo
    git branch -a | peco | tr -d ' ' | read branch
    echo $branch
    if [ $branch ]
      set -l is_remote (string match "remotes\/*" $branch)
      echo $is_remote
      if [ -n is_remote ]
        set -l b (string replace "remotes/origin/" "" $branch)
        echo $b
        git checkout $b
      else
        git checkout $branch
      end
    end
    commandline -f repaint
  else
    echo '.git?'
  end
end


Fix handling that checkout a remote branch
Fix handling that checkout a remote branch

ukoasis/dotfiles