1
1
#! /usr/bin/env bash
2
2
# shellcheck disable=2016
3
3
4
+ GIT_FUZZY_STATUS_ADD_KEY=${GIT_FUZZY_STATUS_ADD_KEY:- Alt-S}
5
+ GIT_FUZZY_STATUS_EDIT_KEY=${GIT_FUZZY_STATUS_EDIT_KEY:- Alt-E}
6
+ GIT_FUZZY_STATUS_COMMIT_KEY=${GIT_FUZZY_STATUS_EDIT_KEY:- Alt-C}
7
+ GIT_FUZZY_STATUS_RESET_KEY=${GIT_FUZZY_STATUS_RESET_KEY:- Alt-R}
8
+ GIT_FUZZY_STATUS_DISCARD_KEY=${GIT_FUZZY_STATUS_DISCARD_KEY:- Alt-U}
9
+
4
10
GF_STATUS_HEADER='
5
11
Type to filter. ' " ${WHITE} Enter${NORMAL} to ${GREEN} ACCEPT${NORMAL} " '
6
12
7
13
' " ${GRAY} -- (${NORMAL} *${GRAY} ) editor: ${MAGENTA}${EDITOR} ${NORMAL}${GF_EDITOR_ARGS}${NORMAL} " '
8
- ' " * ${GREEN}${BOLD} edit ✎${NORMAL} ${WHITE} Alt-E ${NORMAL} " '
9
- ' " ${GREEN} all ☑${NORMAL} ${WHITE} Alt-A${NORMAL} ${GREEN} stage ${BOLD} ⇡${NORMAL} ${WHITE} Alt-S $ {NORMAL} ${RED}${BOLD} discard ✗${NORMAL} ${WHITE} Alt-U ${NORMAL} " '
10
- ' " ${GREEN} none ☐${NORMAL} ${WHITE} Alt-D${NORMAL} ${GREEN} reset ${RED}${BOLD} ⇣${NORMAL} ${WHITE} Alt-R $ {NORMAL} * ${RED}${BOLD} commit ${NORMAL}${RED} ⇧${NORMAL} ${WHITE} Alt-C ${NORMAL} " '
14
+ ' " * ${GREEN}${BOLD} edit ✎${NORMAL} ${WHITE} $GIT_FUZZY_STATUS_EDIT_KEY ${NORMAL} " '
15
+ ' " ${GREEN} all ☑${NORMAL} ${WHITE} Alt-A${NORMAL} ${GREEN} stage ${BOLD} ⇡${NORMAL} ${WHITE} $GIT_FUZZY_STATUS_ADD_KEY $ {NORMAL} ${RED}${BOLD} discard ✗${NORMAL} ${WHITE} $GIT_FUZZY_STATUS_DISCARD_KEY ${NORMAL} " '
16
+ ' " ${GREEN} none ☐${NORMAL} ${WHITE} Alt-D${NORMAL} ${GREEN} reset ${RED}${BOLD} ⇣${NORMAL} ${WHITE} $GIT_FUZZY_STATUS_RESET_KEY $ {NORMAL} * ${RED}${BOLD} commit ${NORMAL}${RED} ⇧${NORMAL} ${WHITE} $GIT_FUZZY_STATUS_COMMIT_KEY ${NORMAL} " '
11
17
12
18
'
13
19
gf_fzf_status () {
@@ -16,21 +22,21 @@ gf_fzf_status() {
16
22
17
23
gf_fzf -m --header " $GF_STATUS_HEADER " \
18
24
--header-lines=2 \
19
- --expect=' alt-e,alt-c ' \
25
+ --expect=' $GIT_FUZZY_STATUS_EDIT_KEY,$GIT_FUZZY_STATUS_COMMIT_KEY ' \
20
26
--nth=2 \
21
27
--preview ' git fuzzy helper status_preview_content {1} {2..}' \
22
- --bind " alt-s :execute-silent(git fuzzy helper status_add {+2..})+down+$RELOAD " \
23
- --bind " alt-r :execute-silent(git fuzzy helper status_reset {+2..})+down+$RELOAD " \
24
- --bind " alt-u :execute-silent(git fuzzy helper status_discard {2..})+$RELOAD "
28
+ --bind " $GIT_FUZZY_STATUS_ADD_KEY :execute-silent(git fuzzy helper status_add {+2..})+down+$RELOAD " \
29
+ --bind " $GIT_FUZZY_STATUS_RESET_KEY :execute-silent(git fuzzy helper status_reset {+2..})+down+$RELOAD " \
30
+ --bind " $GIT_FUZZY_STATUS_DISCARD_KEY :execute-silent(git fuzzy helper status_discard {2..})+$RELOAD "
25
31
}
26
32
27
33
gf_status_interpreter () {
28
34
CONTENT=" $( cat -) "
29
35
HEAD=" $( echo " $CONTENT " | head -n1) "
30
36
TAIL=" $( echo " $CONTENT " | tail -n +2) "
31
- if [ " $HEAD " = ' alt-e ' ]; then
37
+ if [ " $HEAD " = " $GIT_FUZZY_STATUS_EDIT_KEY " ]; then
32
38
eval " git fuzzy helper status_edit $( echo " $TAIL " | cut -c4- | join_lines_quoted) "
33
- elif [ " $HEAD " = ' alt-c ' ]; then
39
+ elif [ " $HEAD " = " $GIT_FUZZY_STATUS_COMMIT_KEY " ]; then
34
40
eval " git fuzzy helper status_commit"
35
41
else
36
42
echo " $TAIL " | cut -c4-
0 commit comments