mirror of
https://github.com/wfxr/forgit.git
synced 2026-09-14 09:16:16 -04:00
feat: add forgit::rebase function
This commit is contained in:
parent
50495dc421
commit
968d362997
|
|
@ -163,6 +163,25 @@ forgit::cherry::pick() {
|
|||
xargs -I% git cherry-pick %
|
||||
}
|
||||
|
||||
forgit::rebase() {
|
||||
forgit::inside_work_tree || return 1
|
||||
local cmd preview opts graph files
|
||||
graph=--graph
|
||||
[[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph=
|
||||
cmd="git log $graph --color=always --format='%C(auto)%h%d %s %C(black)%C(bold)%cr' $* $forgit_emojify"
|
||||
files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command
|
||||
preview="echo {} |grep -Eo '[a-f0-9]+' |head -1 |xargs -I% git show --color=always % -- $files | $forgit_show_pager"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"ctrl-y:execute-silent(echo {} |grep -Eo '[a-f0-9]+' | head -1 | tr -d '\n' |${FORGIT_COPY_CMD:-pbcopy})\"
|
||||
$FORGIT_REBASE_FZF_OPTS
|
||||
"
|
||||
eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" |
|
||||
grep -Eo '[a-f0-9]+' | head -1 |
|
||||
xargs -I% git rebase -i %
|
||||
}
|
||||
|
||||
# git ignore generator
|
||||
export FORGIT_GI_REPO_REMOTE=${FORGIT_GI_REPO_REMOTE:-https://github.com/dvcs/gitignore}
|
||||
export FORGIT_GI_REPO_LOCAL="${FORGIT_GI_REPO_LOCAL:-${XDG_CACHE_HOME:-$HOME/.cache}/forgit/gi/repos/dvcs/gitignore}"
|
||||
|
|
@ -238,4 +257,5 @@ if [[ -z "$FORGIT_NO_ALIASES" ]]; then
|
|||
alias "${forgit_clean:-gclean}"='forgit::clean'
|
||||
alias "${forgit_stash_show:-gss}"='forgit::stash::show'
|
||||
alias "${forgit_cherry_pick:-gcp}"='forgit::cherry::pick'
|
||||
alias "${forgit_rebase:-grb}"='forgit::rebase'
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue