AutoYADM commit: 2025-06-03 13:00:14
This commit is contained in:
parent
f4d51acdfb
commit
b81120710b
7 changed files with 75 additions and 15 deletions
|
@ -75,6 +75,8 @@ _git-forgit() {
|
||||||
'rebase:git rebase'
|
'rebase:git rebase'
|
||||||
'reset_head:git reset HEAD (unstage) selector'
|
'reset_head:git reset HEAD (unstage) selector'
|
||||||
'revert_commit:git revert commit selector'
|
'revert_commit:git revert commit selector'
|
||||||
|
'reword:git fixup=reword'
|
||||||
|
'squash:git squash'
|
||||||
'stash_show:git stash viewer'
|
'stash_show:git stash viewer'
|
||||||
'stash_push:git stash push selector'
|
'stash_push:git stash push selector'
|
||||||
)
|
)
|
||||||
|
@ -96,6 +98,8 @@ _git-forgit() {
|
||||||
rebase) _git-rebase ;;
|
rebase) _git-rebase ;;
|
||||||
reset_head) _git-staged ;;
|
reset_head) _git-staged ;;
|
||||||
revert_commit) __git_recent_commits ;;
|
revert_commit) __git_recent_commits ;;
|
||||||
|
reword) __git_branch_names ;;
|
||||||
|
squash) __git_branch_names ;;
|
||||||
stash_show) _git-stash-show ;;
|
stash_show) _git-stash-show ;;
|
||||||
show) _git-show ;;
|
show) _git-show ;;
|
||||||
esac
|
esac
|
||||||
|
@ -122,6 +126,8 @@ compdef _git-reflog forgit::reflog
|
||||||
compdef _git-rebase forgit::rebase
|
compdef _git-rebase forgit::rebase
|
||||||
compdef _git-staged forgit::reset::head
|
compdef _git-staged forgit::reset::head
|
||||||
compdef __git_recent_commits forgit::revert::commit
|
compdef __git_recent_commits forgit::revert::commit
|
||||||
|
compdef __git_branch_names forgit::reword
|
||||||
|
compdef __git_branch_names forgit::squash
|
||||||
compdef _git-stash-show forgit::stash::show
|
compdef _git-stash-show forgit::stash::show
|
||||||
compdef _git-show forgit::show
|
compdef _git-show forgit::show
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,9 @@ _git_forgit()
|
||||||
rebase
|
rebase
|
||||||
reset_head
|
reset_head
|
||||||
revert_commit
|
revert_commit
|
||||||
|
reword
|
||||||
show
|
show
|
||||||
|
squash
|
||||||
stash_show
|
stash_show
|
||||||
stash_push
|
stash_push
|
||||||
"
|
"
|
||||||
|
@ -102,7 +104,9 @@ _git_forgit()
|
||||||
rebase) _git_rebase ;;
|
rebase) _git_rebase ;;
|
||||||
reset_head) _git_reset ;;
|
reset_head) _git_reset ;;
|
||||||
revert_commit) _git_revert ;;
|
revert_commit) _git_revert ;;
|
||||||
|
reword) _git_branch ;;
|
||||||
show) _git_show ;;
|
show) _git_show ;;
|
||||||
|
squash) _git_branch ;;
|
||||||
stash_show) _git_stash_show ;;
|
stash_show) _git_stash_show ;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
@ -137,7 +141,9 @@ then
|
||||||
__git_complete forgit::rebase _git_rebase
|
__git_complete forgit::rebase _git_rebase
|
||||||
__git_complete forgit::reset::head _git_reset
|
__git_complete forgit::reset::head _git_reset
|
||||||
__git_complete forgit::revert::commit _git_revert
|
__git_complete forgit::revert::commit _git_revert
|
||||||
|
__git_complete forgit::reword _git_branch
|
||||||
__git_complete forgit::show _git_show
|
__git_complete forgit::show _git_show
|
||||||
|
__git_complete forgit::squash _git_branch
|
||||||
__git_complete forgit::stash::show _git_stash_show
|
__git_complete forgit::stash::show _git_stash_show
|
||||||
|
|
||||||
# Completion for forgit plugin shell aliases
|
# Completion for forgit plugin shell aliases
|
||||||
|
@ -157,7 +163,9 @@ then
|
||||||
__git_complete "${forgit_rebase}" _git_rebase
|
__git_complete "${forgit_rebase}" _git_rebase
|
||||||
__git_complete "${forgit_reset_head}" _git_reset
|
__git_complete "${forgit_reset_head}" _git_reset
|
||||||
__git_complete "${forgit_revert_commit}" _git_revert
|
__git_complete "${forgit_revert_commit}" _git_revert
|
||||||
|
__git_complete "${forgit_reword_commit}" _git_branch
|
||||||
__git_complete "${forgit_show}" _git_show
|
__git_complete "${forgit_show}" _git_show
|
||||||
|
__git_complete "${forgit_squash}" _git_branch
|
||||||
__git_complete "${forgit_stash_show}" _git_stash_show
|
__git_complete "${forgit_stash_show}" _git_stash_show
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
function __fish_forgit_needs_subcommand
|
function __fish_forgit_needs_subcommand
|
||||||
for subcmd in add blame branch_delete checkout_branch checkout_commit checkout_file checkout_tag \
|
for subcmd in add blame branch_delete checkout_branch checkout_commit checkout_file checkout_tag \
|
||||||
cherry_pick cherry_pick_from_branch clean diff fixup ignore log reflog rebase reset_head \
|
cherry_pick cherry_pick_from_branch clean diff fixup ignore log reflog rebase reset_head \
|
||||||
revert_commit stash_show stash_push
|
revert_commit reword squash stash_show stash_push
|
||||||
if contains -- $subcmd (commandline -opc)
|
if contains -- $subcmd (commandline -opc)
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
@ -40,7 +40,9 @@ complete -c git-forgit -n __fish_forgit_needs_subcommand -a reflog -d 'git reflo
|
||||||
complete -c git-forgit -n __fish_forgit_needs_subcommand -a rebase -d 'git rebase'
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a rebase -d 'git rebase'
|
||||||
complete -c git-forgit -n __fish_forgit_needs_subcommand -a reset_head -d 'git reset HEAD (unstage) selector'
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a reset_head -d 'git reset HEAD (unstage) selector'
|
||||||
complete -c git-forgit -n __fish_forgit_needs_subcommand -a revert_commit -d 'git revert commit selector'
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a revert_commit -d 'git revert commit selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a reword -d 'git fixup=reword'
|
||||||
complete -c git-forgit -n __fish_forgit_needs_subcommand -a show -d 'git show viewer'
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a show -d 'git show viewer'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a squash -d 'git squash'
|
||||||
complete -c git-forgit -n __fish_forgit_needs_subcommand -a stash_show -d 'git stash viewer'
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a stash_show -d 'git stash viewer'
|
||||||
complete -c git-forgit -n __fish_forgit_needs_subcommand -a stash_push -d 'git stash push selector'
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a stash_push -d 'git stash push selector'
|
||||||
|
|
||||||
|
@ -59,6 +61,8 @@ complete -c git-forgit -n '__fish_seen_subcommand_from reflog' -a "(complete -C
|
||||||
complete -c git-forgit -n '__fish_seen_subcommand_from rebase' -a "(complete -C 'git rebase ')"
|
complete -c git-forgit -n '__fish_seen_subcommand_from rebase' -a "(complete -C 'git rebase ')"
|
||||||
complete -c git-forgit -n '__fish_seen_subcommand_from reset_head' -a "(__fish_git_files all-staged)"
|
complete -c git-forgit -n '__fish_seen_subcommand_from reset_head' -a "(__fish_git_files all-staged)"
|
||||||
complete -c git-forgit -n '__fish_seen_subcommand_from revert_commit' -a "(__fish_git_commits)"
|
complete -c git-forgit -n '__fish_seen_subcommand_from revert_commit' -a "(__fish_git_commits)"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from reword' -a "(__fish_git_local_branches)"
|
||||||
complete -c git-forgit -n '__fish_seen_subcommand_from show' -a "(complete -C 'git show ')"
|
complete -c git-forgit -n '__fish_seen_subcommand_from show' -a "(complete -C 'git show ')"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from squash' -a "(__fish_git_local_branches)"
|
||||||
complete -c git-forgit -n '__fish_seen_subcommand_from stash_show' -a "(__fish_git_complete_stashes)"
|
complete -c git-forgit -n '__fish_seen_subcommand_from stash_show' -a "(__fish_git_complete_stashes)"
|
||||||
complete -c git-forgit -n '__fish_seen_subcommand_from stash_push' -a "(__fish_git_files modified deleted modified-staged-deleted)"
|
complete -c git-forgit -n '__fish_seen_subcommand_from stash_push' -a "(__fish_git_files modified deleted modified-staged-deleted)"
|
||||||
|
|
|
@ -28,10 +28,6 @@ if [[ "$higher_fzf_version" != "$installed_fzf_version" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set shell for fzf preview commands
|
# Set shell for fzf preview commands
|
||||||
# Disable shellcheck for "which", because it suggests "command -v xxx" instead,
|
|
||||||
# which is not a working replacement.
|
|
||||||
# See https://github.com/koalaman/shellcheck/issues/1162
|
|
||||||
# shellcheck disable=2230
|
|
||||||
SHELL="$(which bash)"
|
SHELL="$(which bash)"
|
||||||
export SHELL
|
export SHELL
|
||||||
|
|
||||||
|
@ -759,25 +755,64 @@ _forgit_file_preview() {
|
||||||
_forgit_fixup() {
|
_forgit_fixup() {
|
||||||
_forgit_inside_work_tree || return 1
|
_forgit_inside_work_tree || return 1
|
||||||
git diff --cached --quiet && echo 'Nothing to fixup: there are no staged changes.' && return 1
|
git diff --cached --quiet && echo 'Nothing to fixup: there are no staged changes.' && return 1
|
||||||
local opts graph quoted_files target_commit prev_commit
|
_forgit_edit_commit --fixup "$FORGIT_FIXUP_FZF_OPTS" "$FORGIT_FIXUP_GIT_OPTS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_forgit_squash() {
|
||||||
|
_forgit_inside_work_tree || return 1
|
||||||
|
git diff --cached --quiet && echo 'Nothing to squash: there are no staged changes.' && return 1
|
||||||
|
_forgit_edit_commit --squash "$FORGIT_SQUASH_FZF_OPTS" "$FORGIT_SQUASH_GIT_OPTS"
|
||||||
|
}
|
||||||
|
|
||||||
|
_forgit_edit_commit() {
|
||||||
|
local action fzf_opts opts graph target_commit prev_commit
|
||||||
|
action=$1
|
||||||
|
fzf_opts=$2
|
||||||
graph=()
|
graph=()
|
||||||
[[ $_forgit_log_graph_enable == true ]] && graph=(--graph)
|
[[ $_forgit_log_graph_enable == true ]] && graph=(--graph)
|
||||||
_forgit_fixup_git_opts=()
|
git_opts=()
|
||||||
_forgit_parse_array _forgit_fixup_git_opts "$FORGIT_FIXUP_GIT_OPTS"
|
_forgit_parse_array git_opts "$3"
|
||||||
quoted_files=$(_forgit_quote_files "$@")
|
|
||||||
opts="
|
opts="
|
||||||
$FORGIT_FZF_DEFAULT_OPTS
|
$FORGIT_FZF_DEFAULT_OPTS
|
||||||
+s +m --tiebreak=index
|
+s +m --tiebreak=index
|
||||||
--bind=\"ctrl-y:execute-silent($FORGIT yank_sha {})\"
|
--bind=\"ctrl-y:execute-silent($FORGIT yank_sha {})\"
|
||||||
--preview=\"$FORGIT file_preview {} $quoted_files\"
|
--preview=\"$FORGIT file_preview {}\"
|
||||||
$FORGIT_FIXUP_FZF_OPTS
|
$fzf_opts
|
||||||
"
|
"
|
||||||
target_commit=$(
|
target_commit=$(
|
||||||
git log "${graph[@]}" --color=always --format="$_forgit_log_format" "$@" |
|
git log "${graph[@]}" --color=always --format="$_forgit_log_format" |
|
||||||
_forgit_emojify |
|
_forgit_emojify |
|
||||||
FZF_DEFAULT_OPTS="$opts" fzf |
|
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||||
_forgit_extract_sha)
|
_forgit_extract_sha)
|
||||||
if [[ -n "$target_commit" ]] && git commit "${_forgit_fixup_git_opts[@]}" --fixup "$target_commit"; then
|
# GIT_EDITOR=: is needed to skip the editor
|
||||||
|
if [[ -n "$target_commit" ]] && GIT_EDITOR=: git commit "${git_opts[@]}" "$action" "$target_commit"; then
|
||||||
|
prev_commit=$(_forgit_previous_commit "$target_commit")
|
||||||
|
# rebase will fail if there are unstaged changes so --autostash is needed to temporarily stash them
|
||||||
|
# GIT_SEQUENCE_EDITOR=: is needed to skip the editor
|
||||||
|
GIT_SEQUENCE_EDITOR=: git rebase --autostash -i --autosquash "$prev_commit"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_forgit_reword() {
|
||||||
|
_forgit_inside_work_tree || return 1
|
||||||
|
local opts graph quoted_files target_commit prev_commit
|
||||||
|
graph=()
|
||||||
|
[[ $_forgit_log_graph_enable == true ]] && graph=(--graph)
|
||||||
|
git_opts=()
|
||||||
|
_forgit_parse_array _forgit_reword_git_opts "$FORGIT_REWORD_GIT_OPTS"
|
||||||
|
opts="
|
||||||
|
$FORGIT_FZF_DEFAULT_OPTS
|
||||||
|
+s +m --tiebreak=index
|
||||||
|
--bind=\"ctrl-y:execute-silent($FORGIT yank_sha {})\"
|
||||||
|
--preview=\"$FORGIT file_preview {}\"
|
||||||
|
$FORGIT_REWORD_FZF_OPTS
|
||||||
|
"
|
||||||
|
target_commit=$(
|
||||||
|
git log "${graph[@]}" --color=always --format="$_forgit_log_format" |
|
||||||
|
_forgit_emojify |
|
||||||
|
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||||
|
_forgit_extract_sha)
|
||||||
|
if [[ -n "$target_commit" ]] && git commit "${git_opts[@]}" --fixup=reword:"$target_commit"; then
|
||||||
prev_commit=$(_forgit_previous_commit "$target_commit")
|
prev_commit=$(_forgit_previous_commit "$target_commit")
|
||||||
# rebase will fail if there are unstaged changes so --autostash is needed to temporarily stash them
|
# rebase will fail if there are unstaged changes so --autostash is needed to temporarily stash them
|
||||||
# GIT_SEQUENCE_EDITOR=: is needed to skip the editor
|
# GIT_SEQUENCE_EDITOR=: is needed to skip the editor
|
||||||
|
@ -1152,6 +1187,8 @@ public_commands=(
|
||||||
"clean"
|
"clean"
|
||||||
"diff"
|
"diff"
|
||||||
"fixup"
|
"fixup"
|
||||||
|
"squash"
|
||||||
|
"reword"
|
||||||
"ignore"
|
"ignore"
|
||||||
"log"
|
"log"
|
||||||
"reflog"
|
"reflog"
|
||||||
|
|
|
@ -49,6 +49,8 @@ if test -z "$FORGIT_NO_ALIASES"
|
||||||
abbr -a -- (string collect $forgit_cherry_pick; or string collect "gcp") git-forgit cherry_pick_from_branch
|
abbr -a -- (string collect $forgit_cherry_pick; or string collect "gcp") git-forgit cherry_pick_from_branch
|
||||||
abbr -a -- (string collect $forgit_rebase; or string collect "grb") git-forgit rebase
|
abbr -a -- (string collect $forgit_rebase; or string collect "grb") git-forgit rebase
|
||||||
abbr -a -- (string collect $forgit_fixup; or string collect "gfu") git-forgit fixup
|
abbr -a -- (string collect $forgit_fixup; or string collect "gfu") git-forgit fixup
|
||||||
|
abbr -a -- (string collect $forgit_squash; or string collect "gsq") git-forgit squash
|
||||||
|
abbr -a -- (string collect $forgit_reword; or string collect "grw") git-forgit reword
|
||||||
abbr -a -- (string collect $forgit_checkout_commit; or string collect "gco") git-forgit checkout_commit
|
abbr -a -- (string collect $forgit_checkout_commit; or string collect "gco") git-forgit checkout_commit
|
||||||
abbr -a -- (string collect $forgit_revert_commit; or string collect "grc") git-forgit revert_commit
|
abbr -a -- (string collect $forgit_revert_commit; or string collect "grc") git-forgit revert_commit
|
||||||
abbr -a -- (string collect $forgit_blame; or string collect "gbl") git-forgit blame
|
abbr -a -- (string collect $forgit_blame; or string collect "gbl") git-forgit blame
|
||||||
|
|
|
@ -166,3 +166,6 @@ define-command -docstring %{
|
||||||
|
|
||||||
map -docstring 'jump forward' global normal <c-f> <c-i>
|
map -docstring 'jump forward' global normal <c-f> <c-i>
|
||||||
map -docstring 'save to jumplist' global normal <c-v> <c-s>
|
map -docstring 'save to jumplist' global normal <c-v> <c-s>
|
||||||
|
|
||||||
|
# selection saving
|
||||||
|
map -docstring 'add selection' global normal Y <a-Z>a
|
||||||
|
|
|
@ -22,9 +22,9 @@ c.completion.open_categories = [
|
||||||
"filesystem",
|
"filesystem",
|
||||||
]
|
]
|
||||||
|
|
||||||
c.hints.chars = "tnserigm"
|
# c.hints.chars = "tnserigm"
|
||||||
# c.hints.chars = "tnseripldh"
|
# c.hints.chars = "tnseripldh"
|
||||||
# c.hints.chars = "tnserigmao"
|
c.hints.chars = "tnserigmao"
|
||||||
|
|
||||||
# dark mode
|
# dark mode
|
||||||
c.colors.webpage.darkmode.enabled = True
|
c.colors.webpage.darkmode.enabled = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue