Skip to content

Instantly share code, notes, and snippets.

@adityavm
Last active January 24, 2020 21:43
Show Gist options
  • Save adityavm/b5b3fdf1b07e72d6b7218bed4fd42062 to your computer and use it in GitHub Desktop.
Save adityavm/b5b3fdf1b07e72d6b7218bed4fd42062 to your computer and use it in GitHub Desktop.
Git branch descriptions

Install

Put git alias in git config Put fish aliases / functions in fish config folder

Usage

set a description

git checkout branch_name
git about "description for this branch"

get description for current branch

git about

list all branches and their descriptions

gdb
git branch --list | gdesc
alias gdesc 'get_branches_with_descriptions'
abbr gdb 'git branch --list | gdesc'
# https://stackoverflow.com/a/39867674
git config --global --add alias.about '!describe() { msg="$1"; git config branch."$(git rev-parse --abbrev-ref HEAD)".description ${msg:+"$msg"}; }; describe'
# Get given branch description
function get_branch_description
set -l description (git config "branch.$argv.description")
echo $description
end
# Get list of recent branches with descriptions
function get_branches_with_descriptions
while read -l i
set -l trimmed (echo $i | sed -e 's/[^a-zA-Z0-9\/_-]//g') # https://trigonakis.com/blog/2011/07/28/pattern-matching-hyphen-minus-sign-in-bash/
printf "%-40s %s %s %s\n" $i (set_color yellow) (get_branch_description $trimmed) (set_color normal)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment