mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-10 15:26:16 -04:00
Feature: Add interactive git reflog
This commit is contained in:
parent
8b60a899f4
commit
9726601728
|
|
@ -215,6 +215,31 @@ _forgit_log() {
|
|||
return $fzf_exit_code
|
||||
}
|
||||
|
||||
# git reflog viewer
|
||||
_forgit_reflog() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
_forgit_contains_non_flags "$@" && { git reflog "$@"; return $?; }
|
||||
local opts reflog_format
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"enter:execute($FORGIT log_enter {})\"
|
||||
--bind=\"ctrl-y:execute-silent($FORGIT yank_sha {})\"
|
||||
--preview=\"$FORGIT log_preview {}\"
|
||||
$FORGIT_REFLOG_FZF_OPTS
|
||||
"
|
||||
reflog_format=${FORGIT_GRL_FORMAT:-$_forgit_log_format}
|
||||
_forgit_reflog_git_opts=()
|
||||
_forgit_parse_array _forgit_reflog_git_opts "$FORGIT_REFLOG_GIT_OPTS"
|
||||
git reflog show --color=always --format="$reflog_format" "${_forgit_reflog_git_opts[@]}" "$@" |
|
||||
_forgit_emojify |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf
|
||||
fzf_exit_code=$?
|
||||
# exit successfully on 130 (ctrl-c/esc)
|
||||
[[ $fzf_exit_code == 130 ]] && return 0
|
||||
return $fzf_exit_code
|
||||
}
|
||||
|
||||
_forgit_get_files_from_diff_line() {
|
||||
# Construct a null-terminated list of the filenames
|
||||
# The input looks like one of these lines:
|
||||
|
|
@ -992,6 +1017,7 @@ public_commands=(
|
|||
"fixup"
|
||||
"ignore"
|
||||
"log"
|
||||
"reflog"
|
||||
"rebase"
|
||||
"reset_head"
|
||||
"revert_commit"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ forgit::log() {
|
|||
"$FORGIT" log "$@"
|
||||
}
|
||||
|
||||
forgit::reflog() {
|
||||
"$FORGIT" reflog "$@"
|
||||
}
|
||||
|
||||
forgit::diff() {
|
||||
"$FORGIT" diff "$@"
|
||||
}
|
||||
|
|
@ -140,6 +144,7 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
|
|||
export forgit_add="${forgit_add:-ga}"
|
||||
export forgit_reset_head="${forgit_reset_head:-grh}"
|
||||
export forgit_log="${forgit_log:-glo}"
|
||||
export forgit_reflog="${forgit_reflog:-grl}"
|
||||
export forgit_diff="${forgit_diff:-gd}"
|
||||
export forgit_ignore="${forgit_ignore:-gi}"
|
||||
export forgit_checkout_file="${forgit_checkout_file:-gcf}"
|
||||
|
|
@ -159,6 +164,7 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
|
|||
alias "${forgit_add}"='forgit::add'
|
||||
alias "${forgit_reset_head}"='forgit::reset::head'
|
||||
alias "${forgit_log}"='forgit::log'
|
||||
alias "${forgit_reflog}"='forgit::reflog'
|
||||
alias "${forgit_diff}"='forgit::diff'
|
||||
alias "${forgit_ignore}"='forgit::ignore'
|
||||
alias "${forgit_checkout_file}"='forgit::checkout::file'
|
||||
|
|
|
|||
Loading…
Reference in a new issue