From f9d3d2ad80ad2a821d69ee78544f1220497cfab1 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Mon, 16 Jan 2017 17:19:27 +0100 Subject: [PATCH 01/23] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 16a9487..fdf9fb9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # log-so-handy -> A convenient tool to easily jump between commits diff. +> A convenient tool to easily go through your git logs. ![git hlog](http://imgur.com/bq9kRez.gif) From 981bbfa0b8e43991e28adf92e528a62e2a496164 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Mon, 16 Jan 2017 22:45:26 +0100 Subject: [PATCH 02/23] Explain git-hlog limitation --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fdf9fb9..60436ad 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ $ git hlog [-a ] ##### Options description: -- `-a` - Restrict search for a specific user +- `-a` - Restrict search for a specific user (use -a "all" for all users) - `-d` - Display commits for the last n days - `-f` - Fetch the latest changes - `-h` - Show help screen @@ -25,8 +25,11 @@ $ git hlog [-a ] Once the commits are displayed, you can use the `arrow keys` to switch between commits, press `TAB` to `expand/reduce` the commit's diff or `q` to quit. -**Note** that when the commit's diff is too long, the result will be displayed using the [`less`](http://www.tutorialspoint.com/unix_commands/less.htm) program. You can use either -`TAB` or `q` to return to the commits list. +##### Limitaions: + +when the number of lines between the commits list and a commit's diff is higher than the number of lines of the current terminal session, +the result will be displayed using the [`less`](http://www.tutorialspoint.com/unix_commands/less.htm) program which will open the diff in a separate screen. +You can still use either `TAB` or `q` to return to the commits list. (It might be fixed soon) ## Examples From ce3a519d9080b8698fb849e372653dd6375ada9c Mon Sep 17 00:00:00 2001 From: Fakerr Date: Mon, 16 Jan 2017 23:20:45 +0100 Subject: [PATCH 03/23] add support for vim-like keys --- git-hlog | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git-hlog b/git-hlog index 7d34bf1..e447e4d 100644 --- a/git-hlog +++ b/git-hlog @@ -126,7 +126,9 @@ TN=$(( $NI < $((SN -1)) ? $NI : $((SN -1)))) # Number of lines that we will disp # Set keys. au="`echo -e '\e[A'`" # arrow up +au_1="k" # arrow up ad="`echo -e '\e[B'`" # arrow down +ad_1="j" # arrow down ec="`echo -e '\e'`" # escape nl="`echo -e '\n'`" # newline @@ -211,7 +213,7 @@ do case "$key" in - "$au") + "$au" | "$au_1") CP=$(( CP - 1 )) [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $(( SN - 1 )) ]] && CP=$NI && SI=$(( NI - SN + 2 )) [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $NI ]] && CP=$TN @@ -220,7 +222,7 @@ do [[ $SI != 1 ]] && tput ed # clear screen ;; - "$ad") + "$ad" | "$ad_1") CP=$(( CP + 1 )) [[ $CP == $(( NI + 1 )) ]] && CP=1 && SI=1 [[ $CP == $(( SN + SI - 1)) ]] && [[ $TN == $(( SN - 1 )) ]] && SI=$(( SI + 1 )) From 965654cde101ac32cf457c910fb4d81301ea2943 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Mon, 16 Jan 2017 23:46:56 +0100 Subject: [PATCH 04/23] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60436ad..dfea3db 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ $ git hlog [-a ] ##### How to use: -Once the commits are displayed, you can use the `arrow keys` to switch between commits, +Once the commits are displayed, you can use the `arrow keys` or `j/k` to switch between commits, press `TAB` to `expand/reduce` the commit's diff or `q` to quit. ##### Limitaions: From 94505adae4446715fedbf0902f4d2c0a019475ef Mon Sep 17 00:00:00 2001 From: Fakerr Date: Tue, 17 Jan 2017 12:03:18 +0100 Subject: [PATCH 05/23] refactoring ... --- git-hlog | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/git-hlog b/git-hlog index e447e4d..884287c 100644 --- a/git-hlog +++ b/git-hlog @@ -126,9 +126,9 @@ TN=$(( $NI < $((SN -1)) ? $NI : $((SN -1)))) # Number of lines that we will disp # Set keys. au="`echo -e '\e[A'`" # arrow up -au_1="k" # arrow up +au_1="k" # arrow up ad="`echo -e '\e[B'`" # arrow down -ad_1="j" # arrow down +ad_1="j" # arrow down ec="`echo -e '\e'`" # escape nl="`echo -e '\n'`" # newline @@ -158,7 +158,6 @@ function print_diff() { do echo -n "$NORMAL" [[ $CP == $i ]] && echo -n "$REVERSE" - echo "${COMMITS[$i - 1]}" if [[ $CP == $i ]]; then @@ -200,7 +199,6 @@ do do echo -n "$NORMAL" [[ $CP == $i ]] && echo -n "$REVERSE" - echo "${COMMITS[$i - 1]}" done From d6cbd507673eaf79f48170b6a4815752886dfd33 Mon Sep 17 00:00:00 2001 From: Walid Berrahal Date: Wed, 18 Jan 2017 18:26:04 +0100 Subject: [PATCH 06/23] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dfea3db..4cb829a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ press `TAB` to `expand/reduce` the commit's diff or `q` to quit. when the number of lines between the commits list and a commit's diff is higher than the number of lines of the current terminal session, the result will be displayed using the [`less`](http://www.tutorialspoint.com/unix_commands/less.htm) program which will open the diff in a separate screen. -You can still use either `TAB` or `q` to return to the commits list. (It might be fixed soon) +You can still use either `TAB` or `q` to return to the commits list. ## Examples From 7acfe51014d25cde0d23c04b28e6fb4b479e1142 Mon Sep 17 00:00:00 2001 From: Walid Berrahal Date: Wed, 18 Jan 2017 21:47:34 +0100 Subject: [PATCH 07/23] update description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4cb829a..461eb33 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # log-so-handy -> A convenient tool to easily go through your git logs. +> A simple and convenient Git tool to easily check your commits. ![git hlog](http://imgur.com/bq9kRez.gif) From 9f3c97d87cf30247ac46188339f40a6a77fdd4fe Mon Sep 17 00:00:00 2001 From: Walid Berrahal Date: Wed, 18 Jan 2017 22:45:21 +0100 Subject: [PATCH 08/23] update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 461eb33..feb1f41 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ press `TAB` to `expand/reduce` the commit's diff or `q` to quit. ##### Limitaions: -when the number of lines between the commits list and a commit's diff is higher than the number of lines of the current terminal session, +when the number of lines between the commits list and a commit's diff is higher than the current terminal session's number of lines, the result will be displayed using the [`less`](http://www.tutorialspoint.com/unix_commands/less.htm) program which will open the diff in a separate screen. You can still use either `TAB` or `q` to return to the commits list. From 4018d54530c1f3e369c97f7eaf7d92ecfae63efe Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 28 Jan 2017 20:24:59 +0100 Subject: [PATCH 09/23] change script name --- git-recall | 254 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 git-recall diff --git a/git-recall b/git-recall new file mode 100644 index 0000000..884287c --- /dev/null +++ b/git-recall @@ -0,0 +1,254 @@ +#!/usr/bin/env bash + + +# usage info +usage() { + cat <&2 + exit 1 +fi + +# Parse options +while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do + case $1 in + -v | --version ) + echo $version + exit + ;; + -d | --date ) + SINCE="$2 days ago" + shift; + ;; + -a | --author ) + AUTHOR="$2" + shift + ;; + -f | --fetch ) + FETCH=true + ;; + -h | --help ) + usage + exit + ;; + * ) + echo "abort: unknown argument" 1>&2 + exit 1 + esac + shift +done +if [[ "$1" == "--" ]]; then shift; fi + + +# Colored output. +function colored() { + GREEN=$(tput setaf 4) + YELLOW=$(tput setaf 3) + NORMAL=$(tput sgr0) + REVERSE=$(tput rev) +} + +# Uncolored output. +function uncolored() { + GREEN="" + YELLOW="" + NORMAL="" + REVERSE="" +} + +# Enable colors if supported by terminal. +if [[ -t 1 ]] && [[ -n "$TERM" ]] && which tput &>/dev/null && tput colors &>/dev/null; then + ncolors=$(tput colors) + if [[ -n "$ncolors" ]] && [[ "$ncolors" -ge 8 ]] ; then + colored + else + uncolored + fi +else + uncolored +fi + +# Set AUTHOR to current user if no param passed or display for all users if param equal to "all". +if [[ ! -n $AUTHOR ]]; then + AUTHOR=$(git config user.name 2>/dev/null) +elif [[ $AUTHOR = "all" ]]; then + AUTHOR=".*" +fi + +# Fetch changes before. +if [[ $FETCH == true ]]; then + echo "${GREEN}Fetching changes...${NORMAL}" + git fetch --all &> /dev/null + tput cuu1 + tput ed # clear screen +fi + +# Log template. +GIT_FORMAT="%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" + +# Log command. +GIT_LOG="git log --pretty=format:'${GIT_FORMAT}' + --author \"$AUTHOR\" + --since \"$SINCE\" --abbrev-commit" + +# Change temporary the IFS to store GIT_LOG's output into an array. +IFS=$'\n' +COMMITS=($(eval ${GIT_LOG} 2>/dev/null)) +unset IFS + +NI=${#COMMITS[@]} # Total number of items. +SN=$(( `tput lines` - 1 )) # Screen number of lines. +TN=$(( $NI < $((SN -1)) ? $NI : $((SN -1)))) # Number of lines that we will display. + +# If there is no items, exit. +[[ $NI = 0 ]] && echo "${YELLOW}The contributor \"${AUTHOR}\" did nothing during this period.${NORMAL}" && exit 0 + +# Set keys. +au="`echo -e '\e[A'`" # arrow up +au_1="k" # arrow up +ad="`echo -e '\e[B'`" # arrow down +ad_1="j" # 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 + DIFF_TIP=${ELT:0:7} + DIFF_CMD="git show $DIFF_TIP --color=always" + DIFF=$(eval ${DIFF_CMD} 2>/dev/null) + DIFF_LINES_NUMBER="$(echo "$DIFF" | wc -l)" +} + +## This function will print the diff according the commit's tip. If the diff is too long, the result will be displayed using 'less'. +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 + else + stop=false + tput ed + for i in `seq 1 $TN` + do + echo -n "$NORMAL" + [[ $CP == $i ]] && echo -n "$REVERSE" + echo "${COMMITS[$i - 1]}" + + if [[ $CP == $i ]]; then + echo "$DIFF" + fi + done + + while ! $stop + do + read -sn 1 key + case "$key" in + "$nl") + stop=true + ;; + "q") + stop=true + END=true + ;; + esac + done + [[ $END = false ]] && tput cuu $(( TN + DIFF_LINES_NUMBER )) && tput ed + [[ $END = true ]] && tput cuu 1 + fi +} + + +{ # capture stdout to stderr + +tput civis # hide cursor. +CP=1 # current position +SI=1 # index +END=false # end while loop + +## Loops, reads inputs and prints commits until user presses 'q' to exit or TAB to show the diff. +while ! $END +do + + for i in `seq $SI $(( $TN + $SI -1 ))` + do + echo -n "$NORMAL" + [[ $CP == $i ]] && echo -n "$REVERSE" + echo "${COMMITS[$i - 1]}" + done + + read -sn 1 key + [[ "$key" == "$ec" ]] && + { + read -sn 2 k2 + key="$key$k2" + } + + case "$key" in + + "$au" | "$au_1") + CP=$(( CP - 1 )) + [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $(( SN - 1 )) ]] && CP=$NI && SI=$(( NI - SN + 2 )) + [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $NI ]] && CP=$TN + [[ $CP == $(( SI - 1 )) ]] && [[ $SI != 1 ]] && SI=$(( SI - 1 )) + tput cuu $TN + [[ $SI != 1 ]] && tput ed # clear screen + ;; + + "$ad" | "$ad_1") + CP=$(( CP + 1 )) + [[ $CP == $(( NI + 1 )) ]] && CP=1 && SI=1 + [[ $CP == $(( SN + SI - 1)) ]] && [[ $TN == $(( SN - 1 )) ]] && SI=$(( SI + 1 )) + tput cuu $TN + [[ $SI != 1 ]] && tput ed # clear screen + [[ $SI = 1 ]] && [[ $CP = 1 ]] && tput ed # clear screen + ;; + + "$nl") + tput cuu $TN + print_diff + ;; + + "q") + si=false + END=true + tput cuu 1 + ;; + + * ) + tput cuu $TN + esac + +done + +rm $HOME/.lsh_less_keys_tmp # remove temporary less keybindings +tput cnorm # unhide cursor +echo "$NORMAL" # normal colors + +} >&2 # END capture + From 2abbeed7183fbb0dfaf5fc26a72e51d35c83d171 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 28 Jan 2017 20:25:43 +0100 Subject: [PATCH 10/23] delete old file --- git-hlog | 254 ------------------------------------------------------- 1 file changed, 254 deletions(-) delete mode 100644 git-hlog diff --git a/git-hlog b/git-hlog deleted file mode 100644 index 884287c..0000000 --- a/git-hlog +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/env bash - - -# usage info -usage() { - cat <&2 - exit 1 -fi - -# Parse options -while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do - case $1 in - -v | --version ) - echo $version - exit - ;; - -d | --date ) - SINCE="$2 days ago" - shift; - ;; - -a | --author ) - AUTHOR="$2" - shift - ;; - -f | --fetch ) - FETCH=true - ;; - -h | --help ) - usage - exit - ;; - * ) - echo "abort: unknown argument" 1>&2 - exit 1 - esac - shift -done -if [[ "$1" == "--" ]]; then shift; fi - - -# Colored output. -function colored() { - GREEN=$(tput setaf 4) - YELLOW=$(tput setaf 3) - NORMAL=$(tput sgr0) - REVERSE=$(tput rev) -} - -# Uncolored output. -function uncolored() { - GREEN="" - YELLOW="" - NORMAL="" - REVERSE="" -} - -# Enable colors if supported by terminal. -if [[ -t 1 ]] && [[ -n "$TERM" ]] && which tput &>/dev/null && tput colors &>/dev/null; then - ncolors=$(tput colors) - if [[ -n "$ncolors" ]] && [[ "$ncolors" -ge 8 ]] ; then - colored - else - uncolored - fi -else - uncolored -fi - -# Set AUTHOR to current user if no param passed or display for all users if param equal to "all". -if [[ ! -n $AUTHOR ]]; then - AUTHOR=$(git config user.name 2>/dev/null) -elif [[ $AUTHOR = "all" ]]; then - AUTHOR=".*" -fi - -# Fetch changes before. -if [[ $FETCH == true ]]; then - echo "${GREEN}Fetching changes...${NORMAL}" - git fetch --all &> /dev/null - tput cuu1 - tput ed # clear screen -fi - -# Log template. -GIT_FORMAT="%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" - -# Log command. -GIT_LOG="git log --pretty=format:'${GIT_FORMAT}' - --author \"$AUTHOR\" - --since \"$SINCE\" --abbrev-commit" - -# Change temporary the IFS to store GIT_LOG's output into an array. -IFS=$'\n' -COMMITS=($(eval ${GIT_LOG} 2>/dev/null)) -unset IFS - -NI=${#COMMITS[@]} # Total number of items. -SN=$(( `tput lines` - 1 )) # Screen number of lines. -TN=$(( $NI < $((SN -1)) ? $NI : $((SN -1)))) # Number of lines that we will display. - -# If there is no items, exit. -[[ $NI = 0 ]] && echo "${YELLOW}The contributor \"${AUTHOR}\" did nothing during this period.${NORMAL}" && exit 0 - -# Set keys. -au="`echo -e '\e[A'`" # arrow up -au_1="k" # arrow up -ad="`echo -e '\e[B'`" # arrow down -ad_1="j" # 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 - DIFF_TIP=${ELT:0:7} - DIFF_CMD="git show $DIFF_TIP --color=always" - DIFF=$(eval ${DIFF_CMD} 2>/dev/null) - DIFF_LINES_NUMBER="$(echo "$DIFF" | wc -l)" -} - -## This function will print the diff according the commit's tip. If the diff is too long, the result will be displayed using 'less'. -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 - else - stop=false - tput ed - for i in `seq 1 $TN` - do - echo -n "$NORMAL" - [[ $CP == $i ]] && echo -n "$REVERSE" - echo "${COMMITS[$i - 1]}" - - if [[ $CP == $i ]]; then - echo "$DIFF" - fi - done - - while ! $stop - do - read -sn 1 key - case "$key" in - "$nl") - stop=true - ;; - "q") - stop=true - END=true - ;; - esac - done - [[ $END = false ]] && tput cuu $(( TN + DIFF_LINES_NUMBER )) && tput ed - [[ $END = true ]] && tput cuu 1 - fi -} - - -{ # capture stdout to stderr - -tput civis # hide cursor. -CP=1 # current position -SI=1 # index -END=false # end while loop - -## Loops, reads inputs and prints commits until user presses 'q' to exit or TAB to show the diff. -while ! $END -do - - for i in `seq $SI $(( $TN + $SI -1 ))` - do - echo -n "$NORMAL" - [[ $CP == $i ]] && echo -n "$REVERSE" - echo "${COMMITS[$i - 1]}" - done - - read -sn 1 key - [[ "$key" == "$ec" ]] && - { - read -sn 2 k2 - key="$key$k2" - } - - case "$key" in - - "$au" | "$au_1") - CP=$(( CP - 1 )) - [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $(( SN - 1 )) ]] && CP=$NI && SI=$(( NI - SN + 2 )) - [[ $CP == 0 ]] && [[ $SI=1 ]] && [[ $TN == $NI ]] && CP=$TN - [[ $CP == $(( SI - 1 )) ]] && [[ $SI != 1 ]] && SI=$(( SI - 1 )) - tput cuu $TN - [[ $SI != 1 ]] && tput ed # clear screen - ;; - - "$ad" | "$ad_1") - CP=$(( CP + 1 )) - [[ $CP == $(( NI + 1 )) ]] && CP=1 && SI=1 - [[ $CP == $(( SN + SI - 1)) ]] && [[ $TN == $(( SN - 1 )) ]] && SI=$(( SI + 1 )) - tput cuu $TN - [[ $SI != 1 ]] && tput ed # clear screen - [[ $SI = 1 ]] && [[ $CP = 1 ]] && tput ed # clear screen - ;; - - "$nl") - tput cuu $TN - print_diff - ;; - - "q") - si=false - END=true - tput cuu 1 - ;; - - * ) - tput cuu $TN - esac - -done - -rm $HOME/.lsh_less_keys_tmp # remove temporary less keybindings -tput cnorm # unhide cursor -echo "$NORMAL" # normal colors - -} >&2 # END capture - From 624c5b349659c83abb3bb825bc6a60664d93b7f8 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 28 Jan 2017 20:53:23 +0100 Subject: [PATCH 11/23] changing API --- Makefile | 2 +- README.md | 28 ++++++++++++++-------------- package.json | 12 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 8c779a3..5f47754 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PREFIX = /usr/local BINPREFIX = "$(PREFIX)/bin" -LIB=git-hlog +LIB=git-recall .PHONY: all install uninstall diff --git a/README.md b/README.md index feb1f41..ff51465 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,16 @@ -# log-so-handy +# git-recall > A simple and convenient Git tool to easily check your commits. -![git hlog](http://imgur.com/bq9kRez.gif) +![git recall](http://imgur.com/bq9kRez.gif) ## Usage ```sh -$ git hlog [-a ] - [-d ] - [-f] - [-h] +$ git recall [-a ] + [-d ] + [-f] + [-h] ``` ##### Options description: @@ -34,23 +34,23 @@ You can still use either `TAB` or `q` to return to the commits list. ## Examples ```sh -$ git hlog +$ git recall # By default (without options), the command will display commits from yesterday and # for the current user. ``` ```sh -$ git hlog -d 5 -a "Doge" +$ git recall -d 5 -a "Doge" # The command will show all Doge's commits from 5 days ago. -$ git hlog -d 5 -a "all" +$ git recall -d 5 -a "all" # The command will show commits of all contributors from 5 days ago. ``` ```sh -$ git hlog -f +$ git recall -f # Fetch commits beforehand. ``` @@ -59,7 +59,7 @@ $ git hlog -f ##### Without using tools ``` -You can install it by simply copying the `git-hlog` script into any existing path +You can install it by simply copying the `git-recall` script into any existing path (e.g. /usr/local/bin) or create your own directory and add it to the 'PATH' variable. ``` @@ -67,14 +67,14 @@ You can install it by simply copying the `git-hlog` script into any existing pat Use `npm` to install the project. ```sh -npm install --global log-so-handy +npm install --global git-recall ``` ##### Manual install Clone the project and install it using make install. ```sh -$ git clone https://github.com/Fakerr/log-so-handy.git -$ cd log-so-handy +$ git clone https://github.com/Fakerr/git-recall.git +$ cd git-recall $ sudo make install ``` ## Requirements diff --git a/package.json b/package.json index 3872f69..28a1b36 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,17 @@ { - "name": "log-so-handy", - "version": "1.0.3", - "description": "Convenient log for git", + "name": "git-recall", + "version": "1.1.0", + "description": "Simple and convenient Git tool to easily recall what you've done", "main": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "https://github.com/Fakerr/log-so-handy.git" + "url": "https://github.com/Fakerr/git-recall.git" }, "bin": { - "git-hlog": "./git-hlog" + "git-recall": "./git-recall" }, "keywords": [ "git", @@ -20,5 +20,5 @@ ], "author": "Walid Berrahal", "license": "MIT", - "homepage": "https://github.com/Fakerr/log-so-handy" + "homepage": "https://github.com/Fakerr/git-recall" } From 7fe7cb005b27012606c8f32759e93dd87cd3e345 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 28 Jan 2017 20:55:58 +0100 Subject: [PATCH 12/23] fix help message --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 884287c..2bf0930 100644 --- a/git-recall +++ b/git-recall @@ -4,7 +4,7 @@ # usage info usage() { cat < Date: Sat, 28 Jan 2017 20:57:17 +0100 Subject: [PATCH 13/23] Update version --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 2bf0930..71559ef 100644 --- a/git-recall +++ b/git-recall @@ -22,7 +22,7 @@ FETCH=false GIT_FORMAT="" GIT_LOG="" COMMITS="" -VERSION="1.0.3" +VERSION="1.1.0" # Are we in a git repo? if [[ ! -d ".git" ]]; then From 2e6d0d5c9391fcede5180b81f513dd58f6a27d64 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 28 Jan 2017 21:15:46 +0100 Subject: [PATCH 14/23] Update README --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index ff51465..c5a62d6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # git-recall -> A simple and convenient Git tool to easily check your commits. - +> Simple and handy tool to easily recall what you've done ![git recall](http://imgur.com/bq9kRez.gif) From bdf9e275177c721d06d393c4a692a205b7d4ad47 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sat, 28 Jan 2017 21:34:13 +0100 Subject: [PATCH 15/23] point lesskey output to /dev/null --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 71559ef..9038f04 100644 --- a/git-recall +++ b/git-recall @@ -133,7 +133,7 @@ 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 -- - +echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - &> /dev/null ## Get commit's diff. function get_diff() { From a8aa724f6cb25c309c1b9526e97a9cf8308b9345 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 11:41:50 +0100 Subject: [PATCH 16/23] Update README --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5a62d6..23bc598 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,12 @@ ![git recall](http://imgur.com/bq9kRez.gif) +## Purpose +`git-recall` is a simple tool that allows you to easily go through your commits and +check what you or other contributors in your team did. It doesn't aim to be a replacement for the +`git log` command, but just to be a handy way to recall your work from your terminal. + + ## Usage ```sh @@ -21,7 +27,7 @@ $ git recall [-a ] ##### How to use: -Once the commits are displayed, you can use the `arrow keys` or `j/k` to switch between commits, +Once the commits are displayed, you can use either the `arrow keys` or `j/k` to switch between commits, press `TAB` to `expand/reduce` the commit's diff or `q` to quit. ##### Limitaions: From c90cce87c9efad30c6306d4ae86f5b98412b3b00 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 11:49:46 +0100 Subject: [PATCH 17/23] small fix --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 23bc598..ef3cfdd 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # git-recall -> Simple and handy tool to easily recall what you've done ![git recall](http://imgur.com/bq9kRez.gif) ## Purpose + `git-recall` is a simple tool that allows you to easily go through your commits and check what you or other contributors in your team did. It doesn't aim to be a replacement for the -`git log` command, but just to be a handy way to recall your work from your terminal. +`git log` command, but just to be a handy way to recall what you've done from your terminal. ## Usage From 2b73e20ba92a20038326c3f9e639eac6343230ed Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 12:10:38 +0100 Subject: [PATCH 18/23] add description --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ef3cfdd..2ea1229 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # git-recall +> Simple and handy tool to easily recall what you've done + ![git recall](http://imgur.com/bq9kRez.gif) ## Purpose From c4f952c0233c38dd89cd5bea236cce95712edb4e Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 14:41:57 +0100 Subject: [PATCH 19/23] fix typo; update gif --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2ea1229..1952399 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > Simple and handy tool to easily recall what you've done -![git recall](http://imgur.com/bq9kRez.gif) +![git recall](http://imgur.com/zuw2LqW.gif) ## Purpose @@ -32,7 +32,7 @@ $ git recall [-a ] Once the commits are displayed, you can use either the `arrow keys` or `j/k` to switch between commits, press `TAB` to `expand/reduce` the commit's diff or `q` to quit. -##### Limitaions: +##### Limitations: when the number of lines between the commits list and a commit's diff is higher than the current terminal session's number of lines, the result will be displayed using the [`less`](http://www.tutorialspoint.com/unix_commands/less.htm) program which will open the diff in a separate screen. From b4eb3ddac3a24fb12546e468be68e3de2db5996c Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 14:56:55 +0100 Subject: [PATCH 20/23] add condition for lesskey --- git-recall | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git-recall b/git-recall index 9038f04..c70c0b7 100644 --- a/git-recall +++ b/git-recall @@ -89,6 +89,12 @@ 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 +fi + # Set AUTHOR to current user if no param passed or display for all users if param equal to "all". if [[ ! -n $AUTHOR ]]; then AUTHOR=$(git config user.name 2>/dev/null) From 8fc61a38b3f950f0097510af98ad062b7e145fcd Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 15:48:29 +0100 Subject: [PATCH 21/23] 1.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 28a1b36..f84d8d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "git-recall", - "version": "1.1.0", + "version": "1.1.1", "description": "Simple and convenient Git tool to easily recall what you've done", "main": "", "scripts": { From 3ace09fb788032ace5d108e49a901a6f96664036 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 15:49:40 +0100 Subject: [PATCH 22/23] fix version --- git-recall | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-recall b/git-recall index c70c0b7..091c202 100644 --- a/git-recall +++ b/git-recall @@ -22,7 +22,7 @@ FETCH=false GIT_FORMAT="" GIT_LOG="" COMMITS="" -VERSION="1.1.0" +VERSION="1.1.1" # Are we in a git repo? if [[ ! -d ".git" ]]; then From a46433ab6b7b9f926cd289f5a845b2293ae926f3 Mon Sep 17 00:00:00 2001 From: Fakerr Date: Sun, 29 Jan 2017 17:40:55 +0100 Subject: [PATCH 23/23] provide a better message --- git-recall | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/git-recall b/git-recall index 091c202..1daaac9 100644 --- a/git-recall +++ b/git-recall @@ -128,7 +128,13 @@ SN=$(( `tput lines` - 1 )) # Screen number of lines. TN=$(( $NI < $((SN -1)) ? $NI : $((SN -1)))) # Number of lines that we will display. # If there is no items, exit. -[[ $NI = 0 ]] && echo "${YELLOW}The contributor \"${AUTHOR}\" did nothing during this period.${NORMAL}" && exit 0 +if [[ $NI = 0 ]]; then + if [[ $AUTHOR = ".*" ]]; then + echo "${YELLOW}All contributors did nothing during this period.${NORMAL}" && exit 0 + else + echo "${YELLOW}The contributor \"${AUTHOR}\" did nothing during this period.${NORMAL}" && exit 0 + fi +fi # Set keys. au="`echo -e '\e[A'`" # arrow up