File: bash_completion.sh

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (195 lines) | stat: -rw-r--r-- 3,511 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# shellcheck shell=bash
# bash completion support for git-extras.

_git_changelog(){
  local s_opts=( '-a' '-l' '-t' '-f' '-s' '-n' '-p' '-x' '-h' '?' )
  local l_opts=(
    '--all'
    '--list'
    '--tag'
    '--final-tag'
    '--start-tag'
    '--start-commit'
    '--no-merges'
    '--prune-old'
    '--stdout'
    '--help'
  )
  local merged_opts_str=""
  merged_opts_str+="$(printf "%s " "${s_opts[@]}")"
  merged_opts_str+="$(printf "%s " "${l_opts[@]}")"

  __gitcomp "$merged_opts_str"
}

_git_authors(){
  __gitcomp "-l --list --no-email"
}

_git_brv(){
  __gitcomp "-r --reverse"
}

_git_coauthor(){
  local oldIfs=$IFS
  IFS=$'\n'
  local cur="${COMP_WORDS[COMP_CWORD]}"
  local selection=
  if ((COMP_CWORD == 2)); then
    for line in $(git authors --list); do
      selection+="${line% *}"$'\n'
    done
  elif ((COMP_CWORD == 3)); then
    local chosen_name="${COMP_WORDS[COMP_CWORD-1]}"
    for line in $(git authors --list); do
      if [ "$chosen_name" = "${line% *}" ]; then
        local email=${line#*<}
        email=${email%>*}
        selection+="$email"$'\n'
      fi
    done
  fi
  compopt +o default
  compopt -o filenames
  COMPREPLY=($(compgen -W "$selection" -- "$cur"))
  IFS=$oldIfs
}

_git_contrib(){
# git completion function modified from
# https://github.com/markgandolfo/git-bash-completion/blob/master/git-completion.bash
  contributors="$(git shortlog -s | cut -f2)"
  local all c s=$'\n' IFS=$'\n'
  local cur="${COMP_WORDS[COMP_CWORD]}"
  for c in $contributors; do
    all="$all$c $s"
  done
  COMPREPLY=($(compgen -W "$all" -- "$cur"))
}

_git_count(){
  __gitcomp "--all"
}

__git_cp(){
  __git_complete_file
}

_git_delete_branch(){
  __gitcomp "$(__git_heads)"
}

_git_delete_squashed_branches(){
  __gitcomp "$(__git_heads)"
}

_git_delete_submodule(){
  __gitcomp "$(git submodule status | awk '{print $2}')"
}

_git_delete_tag(){
  __gitcomp "$(__git_tags)"
}

_git_effort(){
  __git_has_doubledash && return

  case "$cur" in
  --*)
    # shellcheck disable=SC2154
    __gitcomp "
      --above
      $__git_log_common_options
      $__git_log_shortlog_options
      "
    return
    ;;
  esac
}

_git_extras(){
  __gitcomp "--version update"
}

__git_extras_workflow(){
  __gitcomp "$(__git_heads | grep -- "^$1/" | sed s/^"$1"\\///g) finish"
}

_git_feature(){
  __git_extras_workflow "feature"
}

_git_graft(){
  __gitcomp "$(__git_heads)"
}

_git_ignore(){
  case "$cur" in
  --*)
    __gitcomp "--global --local --private"
    return
    ;;
  -*)
    __gitcomp "--global --local --private -g -l -p"
    return
    ;;
  esac
}

_git_missing(){
    # Suggest all known refs
    __gitcomp "$(git for-each-ref --format='%(refname:short)')"
}

_git_psykorebase(){
  __gitcomp "$(__git_heads) --continue --no-ff"
}

_git_reauthor(){
  local prev="${COMP_WORDS[COMP_CWORD-1]}"
  local comp

  if [[ "${prev}" == '--type' ]] || [[ "${prev}" == '-t' ]]; then
    comp='author committer full'
  else
    comp='--all --correct-email --correct-name --old-email --type --use-config'
  fi

   __gitcomp "${comp}"
}

_git_scp(){
  __git_complete_remote_or_refspec
}

_git_stamp(){
  __gitcomp '--replace -r'
}

_git_rscp(){
  __git_complete_remote_or_refspec
}

_git_squash(){
  __gitcomp "$(__git_heads)"
}

_git_undo(){
   __gitcomp "--hard --soft -h -s"
}

_git_info(){
  __gitcomp "--color -c --no-config"
}

_git_browse(){
  __git_complete_remote_or_refspec
}

_git_browse_ci(){
  __git_complete_remote_or_refspec
}

_git_rename_file() {
  __gitcomp "-h --help"
}