From 001e4f345bb8e267844f0eb7dafcbd824a3832f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 29 Nov 2018 13:21:09 +0100 Subject: git: Add gitbcheckout --- bash-completion/gitbcheckout | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 bash-completion/gitbcheckout (limited to 'bash-completion/gitbcheckout') diff --git a/bash-completion/gitbcheckout b/bash-completion/gitbcheckout new file mode 100644 index 0000000..a3c1d8e --- /dev/null +++ b/bash-completion/gitbcheckout @@ -0,0 +1,14 @@ +_gitbcheckout() { + [ "$COMP_CWORD" -gt 1 ] && return # Complete only single branch + local cur prev words cword + _init_completion || return + local gdir branch + gdir="$(git rev-parse --git-common-dir 2>/dev/null)" || return + local branches=() + # TODO ignore current HEAD (merging HEAD to HEAD does not makes sense) + while read -r branch; do + branches+=("$branch") + done < <(find "$gdir/refs/heads" "$gdir/refs/remotes" -mindepth 1 -printf '%P\n') + COMPREPLY=($(compgen -W "${branches[*]}" -- ${cur})) +} +complete -F _gitbcheckout gitbcheckout -- cgit v1.2.3