From cd0a2f7d74b188d5b784d9732a96b382fc85b1db Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 15 Jan 2017 22:31:51 +0100 Subject: [PATCH 1/2] User is now able to quit less using the TAB key --- git-hlog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git-hlog b/git-hlog index 31d3f29..108044e 100644 --- a/git-hlog +++ b/git-hlog @@ -130,6 +130,9 @@ ad="`echo -e '\e[B'`" # arrow down ec="`echo -e '\e'`" # escape nl="`echo -e '\n'`" # newline +# Create a temporary lesskey file to change the keybindings so the user can use the TAB key to quit less. (more convenient) +echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - + ## Get commit's diff. function get_diff() { ELT="$(echo "${COMMITS[$CP-1]}" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" # remove colors escape codes @@ -145,7 +148,7 @@ function print_diff() { get_diff if [[ $(( TN + DIFF_LINES_NUMBER )) -ge $(( `tput lines` - 1 )) ]]; then - echo -e "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r + echo -e "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r -k $HOME/.lsh_less_keys_tmp else stop=false tput ed From 155e3150fcda2eb32053c8bc496f871061e7b257 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 15 Jan 2017 22:36:04 +0100 Subject: [PATCH 2/2] remove temporary less keys binding --- git-hlog | 1 + 1 file changed, 1 insertion(+) diff --git a/git-hlog b/git-hlog index 108044e..5050cb3 100644 --- a/git-hlog +++ b/git-hlog @@ -246,6 +246,7 @@ do done +rm $HOME/.lsh_less_keys_tmp # remove temporary less keybindings tput cnorm # unhide cursor echo "$NORMAL" # normal colors