File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # This file is part of eRCaGuy_dotfiles: https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles
2+
3+ # This is a custom configuration file accompanies the script
4+ # named "eRCaGuy_dotfiles/useful_scripts/git-branch_.sh".
5+
6+ # INSTALLATION & USAGE INSTRUCTIONS:
7+ # 1. If you'd like THE BELOW IGNORED `git branch` BRANCH NAME PREFIXES TO SUPERSEDE AND TAKE
8+ # PRIORITY OVER ANY DEFINED INSIDE "eRCaGuy_dotfiles/useful_scripts/git-branch_.sh", simply copy
9+ # and paste this file into your home directory (`~`) and update it as you see fit.
10+ # cp -i path/to/eRCaGuy_dotfiles/home/.git_branch_prefixes ~
11+ # 2. Also follow the installation instructions inside
12+ # "eRCaGuy_dotfiles/useful_scripts/git-branch_.sh"
13+
14+ IGNORED_PREFIXES=() # create array
15+
16+ # Append any prefixes to this array which you'd like to ignore!
17+
18+ # DEFAULT BRANCH PREFIXES TO IGNORE
19+ IGNORED_PREFIXES+=("z-bak")
20+ IGNORED_PREFIXES+=("_")
21+
22+ # YOUR CUSTOM BRANCH PREFIXES TO IGNORE
23+ # IGNORED_PREFIXES+=("custom_prefix_1")
24+ # IGNORED_PREFIXES+=("custom_prefix_2")
Original file line number Diff line number Diff line change 3838
3939# Ignore (don't print with `git branch_`) branch names which begin with
4040# these prefix strings
41- PREFIX1=" z-bak"
42- PREFIX2=" _"
41+ IGNORED_PREFIXES=() # create array
42+ # Append any prefixes to this array which you'd like to ignore!
43+ IGNORED_PREFIXES+=(" z-bak" )
44+ IGNORED_PREFIXES+=(" _" )
4345
44- git branch --color=always " $@ " \
45- | grep --color=never -v " ^ $PREFIX1 " \
46- | grep --color=never -v " ^ $PREFIX2 "
46+ # TO OVERRIDE THESE PREFIXES ABOVE:
47+ # Copy/paste the "eRCaGuy_dotfiles/home/.git_branch_prefixes" file into your
48+ # home dir (`~`) and customize it as you wish.
49+ if [ -f ~ /.git_branch_prefixes ]; then
50+ . ~ /.git_branch_prefixes
51+ fi
4752
53+ # debug prints:
54+ # echo "len = ${#IGNORED_PREFIXES[@]}" # debugging
55+ # echo "IGNORED_PREFIXES = ${IGNORED_PREFIXES[@]}" # debugging
56+
57+ # read all branch names
58+ filtered_branch_list=" $( git branch --color=always " $@ " ) "
59+
60+ # now filter out the ones with prefixes we don't want to see!
61+ for prefix in " ${IGNORED_PREFIXES[@]} " ; do
62+ regex=" ^ $prefix "
63+ # Filter out (ie: remove--hence the `grep -v`) all lines which match the above `regex` search
64+ # pattern
65+ filtered_branch_list=" $( printf " %s" " $filtered_branch_list " \
66+ | grep --color=never -v " $regex " ) "
67+ done
68+
69+ printf " %s\n" " $filtered_branch_list "
You can’t perform that action at this time.
0 commit comments