akaros/scripts/git/bashrc-git-compl
<<
>>
Prefs
   1
   2_git_untrack ()
   3{
   4        _git_branch
   5}
   6
   7_git_track ()
   8{
   9        local remote=""
  10        local trim_remote=""
  11
  12        if [[ $cur =~ ^.+?/ ]]
  13        then
  14                remote=${BASH_REMATCH[0]}
  15        fi
  16
  17        # We have no remote, let's get one and append the /
  18        if [ -z "$remote" ]; then
  19                __gitcomp_nl "$(__git_remotes)" "" "$cur" "/"
  20                return
  21        fi
  22        # remove the / for the ls-remote
  23        trim_remote="${remote::-1}"
  24        remote_branches="$(git ls-remote --heads $trim_remote | grep -o '[^/]*$')"
  25        # arg3: generate completion matches, should be current string minus
  26        # remote/
  27        __gitcomp_nl "$remote_branches" "$remote" "${cur#$remote}"
  28}
  29
  30_git_track_review ()
  31{
  32        _git_track
  33}
  34
  35