mirror of
https://github.com/Fakerr/git-recall.git
synced 2026-09-13 08:56:42 -04:00
Compare commits
32 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6de1b235c | ||
|
|
ae3ed35a06 | ||
|
|
436a31cea1 | ||
|
|
7a41403687 | ||
|
|
c00f10a39e | ||
|
|
d18d910300 | ||
|
|
cf6849dfc6 | ||
|
|
2a5db45188 | ||
|
|
b8b00c832a | ||
|
|
f56c9309c6 | ||
|
|
740173deeb | ||
|
|
fa1f9036ba | ||
|
|
83496bf8c5 | ||
|
|
47e6d4eb15 | ||
|
|
47bbdaddbb | ||
|
|
acc413e8a1 | ||
|
|
91776f73ca | ||
|
|
39fccbbc6e | ||
|
|
72822bb787 | ||
|
|
db51c14ad9 | ||
|
|
e2fb61c533 | ||
|
|
35ac6970af | ||
|
|
a6fce2c863 | ||
|
|
be62cc387d | ||
|
|
11a51477c3 | ||
|
|
a177fb00f0 | ||
|
|
594f2bdca8 | ||
|
|
42faeda992 | ||
|
|
515dd02680 | ||
|
|
8db954a2d6 | ||
|
|
d7aa17d02c | ||
|
|
5950fd8ba7 |
|
|
@ -16,16 +16,22 @@ check what you or other contributors in your team did. It doesn't aim to be a re
|
||||||
```sh
|
```sh
|
||||||
$ git recall [-a <author name>]
|
$ git recall [-a <author name>]
|
||||||
[-d <days-ago>]
|
[-d <days-ago>]
|
||||||
|
[-b <branch name>]
|
||||||
|
[-p <paths>]
|
||||||
[-f]
|
[-f]
|
||||||
[-h]
|
[-h]
|
||||||
|
[-v]
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Options description:
|
##### Options description:
|
||||||
|
|
||||||
- `-a` - Restrict search for a specific user (use -a "all" for all users)
|
- `-a` - Restrict search for a specific user (use -a "all" for all users)
|
||||||
- `-d` - Display commits for the last n days
|
- `-d` - Display commits for the last n days
|
||||||
|
- `-b` - Specify branch to display commits from
|
||||||
|
- `-p` - Specify path/s or file/s to display commits from
|
||||||
- `-f` - Fetch the latest changes
|
- `-f` - Fetch the latest changes
|
||||||
- `-h` - Show help screen
|
- `-h` - Show help screen
|
||||||
|
- `-v` - Show version
|
||||||
|
|
||||||
##### How to use:
|
##### How to use:
|
||||||
|
|
||||||
|
|
@ -68,6 +74,7 @@ $ git recall -f
|
||||||
You can install it by simply copying the `git-recall` 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.
|
(e.g. `/usr/local/bin`) or create your own directory and add it to the `PATH` variable.
|
||||||
|
|
||||||
|
Make sure to run `chmod +x /usr/local/bin/git-recall` or the directory in which you copied it to.
|
||||||
|
|
||||||
##### Using NPM
|
##### Using NPM
|
||||||
Use `npm` to install the project.
|
Use `npm` to install the project.
|
||||||
|
|
|
||||||
51
git-recall
51
git-recall
|
|
@ -1,14 +1,15 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# usage info
|
# usage info
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: git recall [options]
|
Usage: git recall [options]
|
||||||
Options:
|
Options:
|
||||||
-d, --date Show logs for last n days.
|
-d, --date Show logs for last n days.
|
||||||
-a, --author Author name.
|
-a, --author Author name (use -a "all" for all users).
|
||||||
|
-b, --branch Specify branch to display commits from.
|
||||||
|
-p --path Specify path or filename to display commits from.
|
||||||
-f, --fetch fetch commits.
|
-f, --fetch fetch commits.
|
||||||
-h, --help This message.
|
-h, --help This message.
|
||||||
-v, --version Show version.
|
-v, --version Show version.
|
||||||
|
|
@ -17,6 +18,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
|
orig_stty=$(stty -g) # Store original terminal settings
|
||||||
AUTHOR=""
|
AUTHOR=""
|
||||||
FETCH=false
|
FETCH=false
|
||||||
GIT_FORMAT=""
|
GIT_FORMAT=""
|
||||||
|
|
@ -26,7 +28,9 @@ SINCE="1 days ago" # show logs for last day by default
|
||||||
COMMITS_UNCOL=() # commits without colors
|
COMMITS_UNCOL=() # commits without colors
|
||||||
SED_CMD="" # Sed command to use according OS.
|
SED_CMD="" # Sed command to use according OS.
|
||||||
LESSKEY=false
|
LESSKEY=false
|
||||||
VERSION="1.2.0"
|
VERSION="1.2.4"
|
||||||
|
BRANCH=""
|
||||||
|
SEARCH_PATH=""
|
||||||
|
|
||||||
# Set key bindings.
|
# Set key bindings.
|
||||||
au="`echo -e '\e[A'`" # arrow up
|
au="`echo -e '\e[A'`" # arrow up
|
||||||
|
|
@ -87,6 +91,14 @@ while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
|
||||||
usage
|
usage
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
-b | --branch )
|
||||||
|
BRANCH="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-p | --path )
|
||||||
|
SEARCH_PATH="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
* )
|
* )
|
||||||
echo "abort: unknown argument" 1>&2
|
echo "abort: unknown argument" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -128,7 +140,7 @@ GIT_FORMAT="%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%a
|
||||||
# Log command.
|
# Log command.
|
||||||
GIT_LOG="git log --pretty=format:'${GIT_FORMAT}'
|
GIT_LOG="git log --pretty=format:'${GIT_FORMAT}'
|
||||||
--author \"$AUTHOR\"
|
--author \"$AUTHOR\"
|
||||||
--since \"$SINCE\" --abbrev-commit"
|
--since \"$SINCE\" --abbrev-commit --no-merges $BRANCH $SEARCH_PATH"
|
||||||
|
|
||||||
# Change temporary the IFS to store GIT_LOG's output into an array.
|
# Change temporary the IFS to store GIT_LOG's output into an array.
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
|
@ -178,14 +190,14 @@ done
|
||||||
|
|
||||||
# Create a temporary lesskey file to change the keybindings so the user can use the TAB key to quit less. (more convenient)
|
# 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
|
if [[ $LESSKEY = true ]]; then
|
||||||
echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - &> /dev/null
|
echo "\t quit" | lesskey -o /tmp/lsh_less_keys_tmp -- - &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get commit's diff.
|
# Get commit's diff.
|
||||||
function get_diff() {
|
function get_diff() {
|
||||||
ELT="$(echo "${COMMITS_UNCOL[$CP-1]}")"
|
ELT="$(echo "${COMMITS_UNCOL[$CP-1]}")"
|
||||||
DIFF_TIP=${ELT:0:7}
|
DIFF_TIP=${ELT:0:7}
|
||||||
DIFF_CMD="git show $DIFF_TIP --color=always"
|
DIFF_CMD="git show $DIFF_TIP --color=always $SEARCH_PATH"
|
||||||
DIFF=$(eval ${DIFF_CMD} 2>/dev/null)
|
DIFF=$(eval ${DIFF_CMD} 2>/dev/null)
|
||||||
tmp_diff="$(echo "$DIFF" | $SED_CMD)"
|
tmp_diff="$(echo "$DIFF" | $SED_CMD)"
|
||||||
off=$(echo "$tmp_diff" | grep -c ".\{$CN\}") # Number of lines in the diff that are longer than terminal width.
|
off=$(echo "$tmp_diff" | grep -c ".\{$CN\}") # Number of lines in the diff that are longer than terminal width.
|
||||||
|
|
@ -197,11 +209,13 @@ function get_diff() {
|
||||||
function print_diff() {
|
function print_diff() {
|
||||||
get_diff
|
get_diff
|
||||||
if [[ $(( TN + DIFF_LINES_NUMBER + OFFSET )) -ge $(( `tput lines` - 1 )) ]]; then
|
if [[ $(( TN + DIFF_LINES_NUMBER + OFFSET )) -ge $(( `tput lines` - 1 )) ]]; then
|
||||||
|
trap - INT
|
||||||
if [[ $LESSKEY = true ]]; then
|
if [[ $LESSKEY = true ]]; then
|
||||||
echo "$DIFF" | less -r -k $HOME/.lsh_less_keys_tmp
|
echo "$DIFF" | less -r -k /tmp/lsh_less_keys_tmp
|
||||||
else
|
else
|
||||||
echo "$DIFF" | less -r
|
echo "$DIFF" | less -r
|
||||||
fi
|
fi
|
||||||
|
trap cleanup_and_exit INT
|
||||||
clear_screen
|
clear_screen
|
||||||
else
|
else
|
||||||
stop=false
|
stop=false
|
||||||
|
|
@ -228,7 +242,6 @@ function print_diff() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
[[ $END = false ]] && tput cuu $(( TN + DIFF_LINES_NUMBER + OFFSET )) && clear_screen
|
[[ $END = false ]] && tput cuu $(( TN + DIFF_LINES_NUMBER + OFFSET )) && clear_screen
|
||||||
[[ $END = true ]] && tput cuu 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,6 +261,21 @@ function calculate_offset {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Reset changes made by this script before exiting
|
||||||
|
function cleanup_and_exit() {
|
||||||
|
# remove temporary less keybindings
|
||||||
|
[[ $LESSKEY = true ]] && rm /tmp/lsh_less_keys_tmp
|
||||||
|
|
||||||
|
tput cuu 1 # move cursor up one line. (remove extra line)
|
||||||
|
tput cnorm # unhide cursor
|
||||||
|
echo "$NORMAL" # normal colors
|
||||||
|
stty "$orig_stty" > /dev/null 2>&1
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
# Catch a control-C interrupt and perform cleanup operations before exiting
|
||||||
|
trap cleanup_and_exit INT
|
||||||
|
|
||||||
{ # capture stdout to stderr
|
{ # capture stdout to stderr
|
||||||
|
|
||||||
tput civis # hide cursor.
|
tput civis # hide cursor.
|
||||||
|
|
@ -318,18 +346,13 @@ do
|
||||||
"q")
|
"q")
|
||||||
si=false
|
si=false
|
||||||
END=true
|
END=true
|
||||||
tput cuu 1 #move cursor up one line. (remove extra line)
|
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
tput cuu $(( TN + OFFSET_2 ))
|
tput cuu $(( TN + OFFSET_2 ))
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove temporary less keybindings
|
cleanup_and_exit
|
||||||
[[ $LESSKEY = true ]] && rm $HOME/.lsh_less_keys_tmp
|
|
||||||
|
|
||||||
tput cnorm # unhide cursor
|
|
||||||
echo "$NORMAL" # normal colors
|
|
||||||
|
|
||||||
} >&2 # END capture
|
} >&2 # END capture
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "git-recall",
|
"name": "git-recall",
|
||||||
"version": "1.2.0",
|
"version": "1.2.4",
|
||||||
"description": "Simple and convenient Git tool to easily recall what you've done",
|
"description": "Simple and convenient Git tool to easily recall what you've done",
|
||||||
"main": "",
|
"main": "",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue