Skip to content

Commit 8721752

Browse files
author
Bhavi Dhingra
committed
feat(gadd): refresh diff with ctrl-r
1 parent 9197e69 commit 8721752

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

cmd/gadd

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function main() {
3434
fzf -m --color 'fg:160'\
3535
--bind 'q:abort'\
3636
--bind '?:toggle-preview'\
37+
--bind 'ctrl-r:refresh-preview'\
3738
--header "${GADD_HEADER}"\
3839
--preview "source $__CUSTOM_GIT_UTIL/fzf_previews/__gdiff_preview; __gdiff_preview {}" |\
3940
read_and_stage_files

cmd/gdiff

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function main() {
2727
local str="$(git -c color.status=always status --short |\
2828
fzf --bind 'q:abort'\
2929
--bind '?:toggle-preview'\
30+
--bind 'ctrl-r:refresh-preview'\
3031
--header "${GDIFF_HEADER}"\
3132
--preview "source $__CUSTOM_GIT_UTIL/fzf_previews/__gdiff_preview; __gdiff_preview {}")"
3233

util/fzf_headers/__gadd_header

+9-7
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
88

99
function __gadd_header() {
1010

11-
local msg="gadd | enter: stage file(s), tab: select multiple files, ?: toggle preview, q/esc: quit"
12-
local colormsg="${UNDERLINE}${MAGENTA}gadd${RESET} | \
13-
${BLUE}enter: ${RESET}stage file(s), \
14-
${BLUE}tab: ${RESET}select multiple files, \
15-
${BLUE}?: ${RESET}toggle preview, \
16-
${BLUE}q/esc: ${RESET}quit"
11+
local msg="gadd | enter: stage file(s) | tab: select multiple files | ctrl-r: refresh diff"
12+
local colorMsgL1="${UNDERLINE}${MAGENTA}gadd${RESET} | \
13+
${BLUE}enter:${RESET} stage file(s) | \
14+
${BLUE}tab:${RESET} select multiple files | \
15+
${BLUE}ctrl-r:${RESET} refresh diff"
16+
local colorMsgL2=" ${BLUE}?:${RESET} toggle preview | \
17+
${BLUE}q/esc:${RESET} quit"
1718

1819
local edge="$(echo "${msg}" | sed -e 's/./-/g')"
1920
local GADD_HEADER="${edge}"'
20-
'"${colormsg}"'
21+
'"${colorMsgL1}"'
22+
'"${colorMsgL2}"'
2123
'"${edge}"'
2224
'
2325

util/fzf_headers/__gdiff_header

+5-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
88

99
function __gdiff_header() {
1010

11-
local msg="gdiff | enter: git diff, ?: toggle preview, q/esc: quit"
11+
local msg="gdiff | enter: git diff | ctrl-r: refresh diff | ?: toggle preview | q/esc: quit"
1212
local colormsg="${UNDERLINE}${MAGENTA}gdiff${RESET} | \
13-
${BLUE}enter: ${RESET}git diff, \
14-
${BLUE}?: ${RESET}toggle preview, \
15-
${BLUE}q/esc: ${RESET}quit"
13+
${BLUE}enter:${RESET} git diff | \
14+
${BLUE}ctrl-r:${RESET} refresh diff | \
15+
${BLUE}?:${RESET} toggle preview | \
16+
${BLUE}q/esc:${RESET} quit"
1617

1718
local edge="$(echo "${msg}" | sed -e 's/./-/g')"
1819
local GDIFF_HEADER="${edge}"'

util/fzf_headers/__glog_header

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
88

99
function __glog_header() {
1010

11-
local msg="glog | enter: git show, ctrl-c: copy commit SHA, ?: toggle preview, q/esc: quit"
11+
local msg="glog | enter: git show | ctrl-c: copy commit SHA | ?: toggle preview | q/esc: quit"
1212
local colormsg="${UNDERLINE}${MAGENTA}glog${RESET} | \
13-
${BLUE}enter: ${RESET}git show, \
14-
${BLUE}ctrl-c: ${RESET}copy commit SHA, \
15-
${BLUE}?: ${RESET}toggle preview, \
16-
${BLUE}q/esc: ${RESET}quit"
13+
${BLUE}enter:${RESET} git show | \
14+
${BLUE}ctrl-c:${RESET} copy commit SHA | \
15+
${BLUE}?:${RESET} toggle preview | \
16+
${BLUE}q/esc:${RESET} quit"
1717

1818
local edge="$(echo "${msg}" | sed -e 's/./-/g')"
1919
local GLOG_HEADER="${edge}"'

util/fzf_headers/__grestore_header

+8-7
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
88

99
function __grestore_header() {
1010

11-
local msg="grestore | enter: restore modified file(s) / remove new file(s), tab: select multiple files, ?: toggle preview, q/esc: quit"
12-
local colormsg="${UNDERLINE}${MAGENTA}grestore${RESET} | \
13-
${BLUE}enter: ${RESET}restore modified file(s) / restore new file(s), \
14-
${BLUE}tab: ${RESET}select multiple files, \
15-
${BLUE}?: ${RESET}toggle preview, \
16-
${BLUE}q/esc: ${RESET}quit"
11+
local msg="grestore | enter: restore modified file(s) / remove new file(s) | q/esc: quit "
12+
local colorMsgL1="${UNDERLINE}${MAGENTA}grestore${RESET} | \
13+
${BLUE}enter:${RESET} restore modified file(s) / restore new file(s) | \
14+
${BLUE}q/esc:${RESET} quit"
15+
local colorMsgL2=" ${BLUE}tab: ${RESET}select multiple files | \
16+
${BLUE}?: ${RESET}toggle preview"
1717

1818
local edge="$(echo "${msg}" | sed -e 's/./-/g')"
1919
local GRESTORE_HEADER="${edge}"'
20-
'"${colormsg}"'
20+
'"${colorMsgL1}"'
21+
'"${colorMsgL2}"'
2122
'"${edge}"'
2223
'
2324

util/fzf_headers/__grestorestaged_header

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,17 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
88

99
function __grestorestaged_header() {
1010

11-
local msg="grestorestaged | enter: restore staged file(s), tab: select multiple files, ?: toggle preview, q/esc: quit"
12-
local colormsg="${UNDERLINE}${MAGENTA}grestorestaged${RESET} | \
13-
${BLUE}enter: ${RESET}restore staged file(s), \
14-
${BLUE}tab: ${RESET}select multiple files, \
15-
${BLUE}?: ${RESET}toggle preview, \
11+
local msg="grestorestaged | enter: restore staged file(s) | q/esc: quit "
12+
local colorMsgL1="${UNDERLINE}${MAGENTA}grestorestaged${RESET} | \
13+
${BLUE}enter: ${RESET}restore staged file(s) | \
1614
${BLUE}q/esc: ${RESET}quit"
15+
local colorMsgL2=" ${BLUE}tab: ${RESET}select multiple files | \
16+
${BLUE}?: ${RESET}toggle preview"
1717

1818
local edge="$(echo "${msg}" | sed -e 's/./-/g')"
1919
local GRESTORESTAGED_HEADER="${edge}"'
20-
'"${colormsg}"'
20+
'"${colorMsgL1}"'
21+
'"${colorMsgL2}"'
2122
'"${edge}"'
2223
'
2324

util/fzf_headers/__gshow_header

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ source "$__CUSTOM_CONSOLE_UTIL"/__common
88

99
function __gshow_header() {
1010

11-
local msg="gshow | enter: git show, ctrl-c: copy commit SHA, ?: toggle preview, q/esc: quit"
11+
local msg="gshow | enter: git show | ctrl-c: copy commit SHA | ?: toggle preview | q/esc: quit"
1212
local colormsg="${UNDERLINE}${MAGENTA}gshow${RESET} | \
13-
${BLUE}enter: ${RESET}git show, \
14-
${BLUE}ctrl-c: ${RESET}copy commit SHA, \
15-
${BLUE}?: ${RESET}toggle preview, \
16-
${BLUE}q/esc: ${RESET}quit"
13+
${BLUE}enter:${RESET} git show | \
14+
${BLUE}ctrl-c:${RESET} copy commit SHA | \
15+
${BLUE}?:${RESET} toggle preview | \
16+
${BLUE}q/esc:${RESET} quit"
1717

1818
local edge="$(echo "${msg}" | sed -e 's/./-/g')"
1919
local GSHOW_HEADER="${edge}"'

0 commit comments

Comments
 (0)