File tree Expand file tree Collapse file tree 3 files changed +27
-14
lines changed
Expand file tree Collapse file tree 3 files changed +27
-14
lines changed Original file line number Diff line number Diff line change 22
33# shellcheck disable=SC1091 # Not following: ./__assertgitrepo was not specified as input
44# shellcheck disable=SC2155 # Declare and assign separately to avoid masking return values
5- # shellcheck disable=SC2001 # See if you can use ${variable//search/replace}
65
76source " ${__CUSTOM_GIT_UTIL} " /fzf_headers/__gstash_header
87source " ${__CUSTOM_GIT_UTIL} " /__assertgitrepo
8+ source " ${__CUSTOM_GIT_UTIL} " /__select_stash_id
99
1010__assertgitrepo
1111
1212function main() {
1313
14- local GSTASH_HEADER=" $( __gstash_header) "
14+ local GSTASH_HEADER=" $( __gstash_header " apply " ) "
1515
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
2118
22- local stashId=" $( echo " ${selectedStr} " | sed ' s/\:.*//g' ) "
2319 git stash apply " ${stashId} "
24-
25- git status
2620}
2721
2822main
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
88
99function __gstash_header() {
1010
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 | \
1416${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"
1619
1720 local edge=" $( echo " ${msg} " | sed -e ' s/./-/g' ) "
1821 local GSTASH_HEADER=" ${edge} " '
You can’t perform that action at this time.
0 commit comments