-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.sh
40 lines (32 loc) · 887 Bytes
/
utils.sh
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
#!/usr/bin/env bash
__gi_grep_command="rg"
branch_filter_command="rg -v '_backup'"
__gi_is_git_repo() {
git rev-parse --git-dir &> /dev/null && echo "true" || echo "false"
}
__gi_check_dependencies() {
if ! command -v fzf &> /dev/null
then
echo "Unable to find command 'fzf'. Please install 'fzf'."
return 1
fi
}
__gi_fetch_branches() {
local git_branch_arg=""
for arg in "$@"
do
if [ "$arg" = "-r" ] || [ "$arg" = "--include-remote-branches" ]
then
git_branch_arg="-r"
elif [ "$arg" = "-a" ] || [ "$arg" = "--all" ]
then
git_branch_arg="-a"
fi
done
local branches=$(git branch $git_branch_arg | sed -r 's/^\*?\s*//')
if [ -n "$branch_filter_command" ]
then
branches="$(echo $branches | eval $branch_filter_command)"
fi
echo "$branches"
}