From 82fa776ffafa2658c3e354bcb40a5be65690c420 Mon Sep 17 00:00:00 2001 From: Henryk Iwaniuk Date: Sun, 29 Jan 2017 23:31:42 +0100 Subject: [PATCH 01/10] allow operation in subdirectory of repository redirect all output to null --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 1daaac9..3d3cfcd 100644 --- a/git-recall +++ b/git-recall @@ -25,7 +25,7 @@ COMMITS="" VERSION="1.1.1" # Are we in a git repo? -if [[ ! -d ".git" ]]; then +if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then echo "abort: not a git repository." 1>&2 exit 1 fi From 187b9a8aaf347fa97125bcecd00ed1cd7063ffd8 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Mon, 30 Jan 2017 13:30:57 +0100 Subject: [PATCH 02/10] Add dependencies in README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1952399..74095d1 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ $ cd git-recall $ sudo make install ``` ## Requirements -- Linux or OSX +- OS: Linux or OSX +- Tools: git, less, lesskey, sed ## Contribution Pull requests are welcome, along with any feedback or ideas. From f7e12091da5049c7b75d3c9c04d704445c916e02 Mon Sep 17 00:00:00 2001 From: radekk Date: Tue, 31 Jan 2017 14:22:46 +0100 Subject: [PATCH 03/10] Fixes #13. Different param name on OSX for Sed program. Sed on Mac OSX is using "-E" param instead of "-r" param on Linux for extended regexp evaluation. Adding switch/case statement allows to set valid parameter depending on the operating system type. --- git-recall | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 3d3cfcd..7727a57 100644 --- a/git-recall +++ b/git-recall @@ -149,7 +149,12 @@ echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - &> /dev/null ## 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 + case "$OSTYPE" in + darwin*) SED_BIN="sed -E" ;; + *) SED_BIN="sed -r" ;; + esac + + ELT="$(echo "${COMMITS[$CP-1]}" | $SED_BIN "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" # remove colors escape codes DIFF_TIP=${ELT:0:7} DIFF_CMD="git show $DIFF_TIP --color=always" DIFF=$(eval ${DIFF_CMD} 2>/dev/null) From 71367c9c8977c94f7032b6b3f021ce205faa7ad1 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Tue, 31 Jan 2017 14:41:14 +0100 Subject: [PATCH 04/10] lesskey is no longer mandatory --- README.md | 2 +- git-recall | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 74095d1..6bf93de 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ $ sudo make install ``` ## Requirements - OS: Linux or OSX -- Tools: git, less, lesskey, sed +- Tools: git, less, sed ## Contribution Pull requests are welcome, along with any feedback or ideas. diff --git a/git-recall b/git-recall index 3d3cfcd..a64d4ba 100644 --- a/git-recall +++ b/git-recall @@ -22,6 +22,7 @@ FETCH=false GIT_FORMAT="" GIT_LOG="" COMMITS="" +LESSKEY=false VERSION="1.1.1" # Are we in a git repo? @@ -89,10 +90,9 @@ else uncolored fi -# Check if lesskey is correctly installed. -if ! which lesskey &>/dev/null; then - echo "abort: the program lesskey is not installed. Make sure to install it before running git-recall" 1>&2 - exit 1 +# Check if lesskey is installed. +if command -v lesskey &> /dev/null; then + LESSKEY=true fi # Set AUTHOR to current user if no param passed or display for all users if param equal to "all". @@ -145,7 +145,9 @@ 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 -- - &> /dev/null +if [[ $LESSKEY = true ]]; then + echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - &> /dev/null +fi ## Get commit's diff. function get_diff() { @@ -162,7 +164,11 @@ 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 -k $HOME/.lsh_less_keys_tmp + if [[ $LESSKEY = true ]]; then + echo -e "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r -k $HOME/.lsh_less_keys_tmp + else + echo -e "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r + fi else stop=false tput ed @@ -258,7 +264,9 @@ do done -rm $HOME/.lsh_less_keys_tmp # remove temporary less keybindings +# remove temporary less keybindings +[[ $LESSKEY = true ]] && rm $HOME/.lsh_less_keys_tmp + tput cnorm # unhide cursor echo "$NORMAL" # normal colors From 63851647813c74c219710dc78ca16b68910cf074 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Tue, 31 Jan 2017 14:49:36 +0100 Subject: [PATCH 05/10] update README --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6bf93de..452aa8c 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,9 @@ $ sudo make install - OS: Linux or OSX - Tools: git, less, sed +##### Optional Requirements +- For a better UX, it's recommended to have installed the `lesskey` program. + ## Contribution Pull requests are welcome, along with any feedback or ideas. From 7b36884d86408b06b02059f092cc647f7e673b71 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Wed, 1 Feb 2017 14:58:55 +0100 Subject: [PATCH 06/10] 1.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f84d8d1..1ef53fe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "git-recall", - "version": "1.1.1", + "version": "1.1.2", "description": "Simple and convenient Git tool to easily recall what you've done", "main": "", "scripts": { From b656bb17a791b97e684311389f459678e89ef068 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Wed, 1 Feb 2017 14:59:32 +0100 Subject: [PATCH 07/10] update version --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 432e3f0..319a4cf 100644 --- a/git-recall +++ b/git-recall @@ -23,7 +23,7 @@ GIT_FORMAT="" GIT_LOG="" COMMITS="" LESSKEY=false -VERSION="1.1.1" +VERSION="1.1.2" # Are we in a git repo? if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then From d5f681df27a8891fb73b65270c670215abd0d3a0 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Thu, 2 Feb 2017 16:06:49 +0100 Subject: [PATCH 08/10] remove -e option for echo --- git-recall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-recall b/git-recall index 319a4cf..f7f1545 100644 --- a/git-recall +++ b/git-recall @@ -170,9 +170,9 @@ function print_diff() { if [[ $(( TN + DIFF_LINES_NUMBER )) -ge $(( `tput lines` - 1 )) ]]; then if [[ $LESSKEY = true ]]; then - echo -e "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r -k $HOME/.lsh_less_keys_tmp + echo "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r -k $HOME/.lsh_less_keys_tmp else - echo -e "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r + echo "$REVERSE ${COMMITS[$CP - 1]}\n\n $DIFF" | less -r fi else stop=false From 45b3829e64d0f1e0dba1c944c971681efb030d6f Mon Sep 17 00:00:00 2001 From: Fakerr Date: Thu, 2 Feb 2017 16:08:27 +0100 Subject: [PATCH 09/10] update version --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index f7f1545..0fdead2 100644 --- a/git-recall +++ b/git-recall @@ -23,7 +23,7 @@ GIT_FORMAT="" GIT_LOG="" COMMITS="" LESSKEY=false -VERSION="1.1.2" +VERSION="1.1.3" # Are we in a git repo? if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then From 53c7a86da34bd5bf9d9a7dff3833787617c6528c Mon Sep 17 00:00:00 2001 From: Fakerr Date: Thu, 2 Feb 2017 16:08:32 +0100 Subject: [PATCH 10/10] 1.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1ef53fe..acf559d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "git-recall", - "version": "1.1.2", + "version": "1.1.3", "description": "Simple and convenient Git tool to easily recall what you've done", "main": "", "scripts": {