-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-gen.plugin.zsh
45 lines (40 loc) · 899 Bytes
/
git-gen.plugin.zsh
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
# Creates bulk branches and delete them
function make_branches() {
if [[ ! -d "${PWD}/.git" ]]; then
echo 'This directory does not contain .git';
return;
fi
exists=`git show-ref refs/heads/$1`
if [ ! -n "$exists" ]; then
echo "There is no branch named: $1";
return;
else
git checkout $1;
fi
arr=("$@");
arraylength=${#arr[@]}
for (( i=2; i<=${arraylength}; i++ ));
do
bn="${arr[$i]}"
exists=`git show-ref refs/heads/$bn`
if [ ! -n "$exists" ]; then
git branch $bn
fi
done
}
function delete_branches() {
if [[ ! -d "${PWD}/.git" ]]; then
echo 'Not a Valid Git Repository';
return;
fi
arr=("$@");
arraylength=${#arr[@]}
for (( i=1; i<=${arraylength}; i++ ));
do
bn="${arr[$i]}"
exists=`git show-ref refs/heads/$bn`
if [ -n "$exists" ]; then
git branch -d $bn
fi
done
}