File tree 3 files changed +40
-4
lines changed
3 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ main () {
14
14
15
15
__assertgitrepo
16
16
17
- local branchName=" $( __select_local_branch) "
17
+ local branchName=" $( __select_local_branch " gswitch " " select local branch to switch to " " exit " ) "
18
18
__exit_if_empty_str " ${branchName} " ${SUCCESS}
19
19
20
20
clear
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
- # shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values.
3
+ # shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values.
4
+ # shellcheck disable=SC1091 # Not following: ./fzf_headers/__select_local_branch_header was not specified as input (see shellcheck -x)
4
5
6
+ source " ${__CUSTOM_GIT_UTIL} " /fzf_headers/__select_local_branch_header
7
+
8
+ # Usage: __select_local_branch "gswitch" "select local branch to switch to" "exit"
5
9
function __select_local_branch() {
6
10
7
- local branchName=$( git branch --sort=-committerdate | fzf | sed ' s/^. //g' )
11
+ local cmd=" ${1} "
12
+ local cmdMsg=" ${2} "
13
+ local escAction=" ${3} "
14
+ local HEADER=" $( __select_local_branch_header " ${cmd} " " ${cmdMsg} " " ${escAction} " ) "
15
+ local branchName=" $( git branch --sort=-committerdate | \
16
+ fzf --height=50%\
17
+ --header " ${HEADER} " | \
18
+ sed ' s/^. //g' ) "
19
+
8
20
local rawBranchNameFile=" $( getrawstr " ${branchName} " ) "
9
- echo " ${rawBranchNameFile} " | xargs -I " {}" echo {} # xargs used to handle "invalid reference" error in git switch command
21
+ echo " ${rawBranchNameFile} " | xargs -I " {}" echo {} # xargs used to handle "invalid reference" for special characters
22
+ # like ', '#' in branch names
10
23
}
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # shellcheck disable=SC1091
4
+ # shellcheck disable=SC2155
5
+ # shellcheck disable=SC2001
6
+
7
+ source " ${__CUSTOM_CONSOLE_UTIL} " /__common # for colors
8
+
9
+ # Usage: __select_local_branch_header "gswitch" "select local branch" "exit"
10
+ function __select_local_branch_header() {
11
+
12
+ local cmd=" ${1} "
13
+ local cmdMsg=" ${2} "
14
+ local escAction=" ${3} "
15
+ local colorMsg=" ${MAGENTA}${UNDERLINE}${cmd}${RESET} | ${cmdMsg} \n\n"
16
+ colorMsg=" ${colorMsg}${BLUE} esc:${RESET} ${escAction} "
17
+
18
+ local x=" ${cmd} | ${cmdMsg} "
19
+ local edge=" $( echo " ${x} " | sed " s/./-/g" ) "
20
+ local HEADER=" ${edge} \n${colorMsg} \n${edge} \n "
21
+
22
+ echo -e " ${HEADER} "
23
+ }
You can’t perform that action at this time.
0 commit comments