From 94915be4a74c11b9858eb6369d2465e907ae3e7a Mon Sep 17 00:00:00 2001 From: bwangel23 Date: Tue, 14 Feb 2017 10:57:48 +0800 Subject: [PATCH] feat(shortcuts): add home/gg end/G key maps press home or gg to the top, and press end or G to the bottom --- git-recall | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/git-recall b/git-recall index c2873cc..5be1b6e 100644 --- a/git-recall +++ b/git-recall @@ -168,6 +168,8 @@ ad="`echo -e '\e[B'`" # arrow down ad_1="j" # arrow down ec="`echo -e '\e'`" # escape nl="`echo -e '\n'`" # newline +home="`echo -e '\e[H'`" # Home +end="`echo -e '\e[F'`" # End # Create a temporary lesskey file to change the keybindings so the user can use the TAB key to quit less. (more convenient) if [[ $LESSKEY = true ]]; then @@ -288,6 +290,11 @@ do read -sn 2 k2 key="$key$k2" } + [[ "$key" == "g" ]] && + { + read -sn 1 k2 + key="$key$k2" + } case "$key" in @@ -313,6 +320,30 @@ do [[ $SI = 1 ]] && [[ $CP = 1 ]] && tput ed # clear screen ;; + "$home" | "gg") + CP=1 + SI=1 + [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $(( SN - 1 )) ]] && CP=$NI && SI=$(( NI - SN + 2 + OFFSET_2 )) + [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $NI ]] && CP=$TN + [[ $CP == $(( SI - 1 )) ]] && [[ $SI != 1 ]] && SI=$(( SI - 1 )) + + [[ $TN != $(( SN - 1 )) ]] && tput cuu $(( TN + OFFSET_2 )) + [[ $TN == $(( SN - 1 )) ]] && tput cuu $(( TN + EXT )) + [[ $SI != 1 ]] && tput ed # clear screen + ;; + + "$end" | "G") + CP=0 + SI=0 + [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $(( SN - 1 )) ]] && CP=$NI && SI=$(( NI - SN + 2 + OFFSET_2 )) + [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $NI ]] && CP=$TN + [[ $CP == $(( SI - 1 )) ]] && [[ $SI != 1 ]] && SI=$(( SI - 1 )) + + [[ $TN != $(( SN - 1 )) ]] && tput cuu $(( TN + OFFSET_2 )) + [[ $TN == $(( SN - 1 )) ]] && tput cuu $(( TN + EXT )) + [[ $SI != 1 ]] && tput ed # clear screen + ;; + "$nl") [[ $TN == $NI ]] && tput cuu $(( TN + OFFSET_2 )) [[ $TN != $NI ]] && tput cuu $(( TN + EXT ))