File tree 3 files changed +27
-14
lines changed
3 files changed +27
-14
lines changed Original file line number Diff line number Diff line change 2
2
3
3
# shellcheck disable=SC1091 # Not following: ./__assertgitrepo was not specified as input
4
4
# shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
5
- # shellcheck disable=SC2001 # See if you can use ${variable//search/replace}
6
5
7
6
source " ${__CUSTOM_GIT_UTIL} " /fzf_headers/__gstash_header
8
7
source " ${__CUSTOM_GIT_UTIL} " /__assertgitrepo
8
+ source " ${__CUSTOM_GIT_UTIL} " /__select_stash_id
9
9
10
10
__assertgitrepo
11
11
12
12
function main() {
13
13
14
- local GSTASH_HEADER=" $( __gstash_header) "
14
+ local GSTASH_HEADER=" $( __gstash_header " apply " ) "
15
15
16
- local selectedStr=" $( git stash list | \
17
- fzf --bind ' ?:toggle-preview' \
18
- --header " ${GSTASH_HEADER} " \
19
- --preview " source ${__CUSTOM_GIT_UTIL} /fzf_previews/__gstash_preview; __gstash_preview {}" ) "
20
- [ -z " ${selectedStr} " ] && return
16
+ local stashId=" $( __select_stash_id " ${GSTASH_HEADER} " ) "
17
+ [ -z " ${stashId} " ] && return
21
18
22
- local stashId=" $( echo " ${selectedStr} " | sed ' s/\:.*//g' ) "
23
19
git stash apply " ${stashId} "
24
-
25
- git status
26
20
}
27
21
28
22
main
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
4
+ # shellcheck disable=SC2001 # See if you can use ${variable//search/replace}
5
+
6
+ # Usage: __select_stash_id "${HEADER}"
7
+ function __select_stash_id() {
8
+
9
+ local GSTASH_HEADER=" ${1} "
10
+ local selectedStr=" $( git stash list | \
11
+ fzf --bind ' ?:toggle-preview' \
12
+ --header " ${GSTASH_HEADER} " \
13
+ --preview " source ${__CUSTOM_GIT_UTIL} /fzf_previews/__gstash_preview; __gstash_preview {}" ) "
14
+
15
+ echo " ${selectedStr} " | sed ' s/\:.*//g'
16
+ }
Original file line number Diff line number Diff line change @@ -8,11 +8,14 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
8
8
9
9
function __gstash_header() {
10
10
11
- local msg=" gstashapply | enter: apply stash | ?: toggle preview"
12
- local colorMsgL1=" ${UNDERLINE}${MAGENTA} gstashapply${RESET} | \
13
- ${BLUE} enter:${RESET} apply stash | \
11
+ local op=" ${1} "
12
+ local cmd=" gstash${1} "
13
+ local msg=" ${cmd} | enter: ${op} stash | ?: toggle preview"
14
+ local colorMsgL1=" ${UNDERLINE}${MAGENTA} gstash${op}${RESET} | \
15
+ ${BLUE} enter:${RESET} ${op} stash | \
14
16
${BLUE} ?:${RESET} toggle preview"
15
- local colorMsgL2=" | ${BLUE} esc:${RESET} quit"
17
+ local spaces=" $( echo " ${cmd} " | sed -e ' s/./ /g' ) "
18
+ local colorMsgL2=" ${spaces} | ${BLUE} esc:${RESET} quit"
16
19
17
20
local edge=" $( echo " ${msg} " | sed -e ' s/./-/g' ) "
18
21
local GSTASH_HEADER=" ${edge} " '
You can’t perform that action at this time.
0 commit comments