🔧 chore(fish): plugin updates

This commit is contained in:
Sergio Laín 2023-10-28 00:25:25 +02:00
parent 673373045b
commit fe88d487f9
No known key found for this signature in database
GPG key ID: 14C9B8080681777B
3 changed files with 485 additions and 513 deletions

View file

@ -4,3 +4,4 @@ abbr -a t --function projectdo_test
abbr -a p --function projectdo_tool abbr -a p --function projectdo_tool
abbr -a y yadm abbr -a y yadm
abbr -a pse pacseek abbr -a pse pacseek
abbr -a g git

View file

@ -138,6 +138,9 @@ _forgit_diff() {
# We have to do a two-step sed -> tr pipe because OSX's sed implementation does # We have to do a two-step sed -> tr pipe because OSX's sed implementation does
# not support the null-character directly. # not support the null-character directly.
get_files="echo {} | sed 's/.*] *//' | sed 's/ -> /\\\n/' | tr '\\\n' '\\\0'" get_files="echo {} | sed 's/.*] *//' | sed 's/ -> /\\\n/' | tr '\\\n' '\\\0'"
# Similar to the line above, but only gets a single file from a single line
# Gets the new name of renamed files
get_file="echo {} | sed 's/.*] *//' | sed 's/.*-> //'"
# Git stashes are named "stash@{x}", which contains the fzf placeholder "{x}". # Git stashes are named "stash@{x}", which contains the fzf placeholder "{x}".
# In order to support passing stashes as arguments to _forgit_diff, we have to # In order to support passing stashes as arguments to _forgit_diff, we have to
# prevent fzf from interpreting this substring by escaping the opening bracket. # prevent fzf from interpreting this substring by escaping the opening bracket.
@ -150,7 +153,7 @@ opts="
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
+m -0 --bind=\"enter:execute($enter_cmd | $_forgit_enter_pager)\" +m -0 --bind=\"enter:execute($enter_cmd | $_forgit_enter_pager)\"
--preview=\"$preview_cmd\" --preview=\"$preview_cmd\"
--bind=\"alt-e:execute-silent($EDITOR \$\($get_files\) >/dev/tty </dev/tty)+refresh-preview\" --bind=\"alt-e:execute-silent($EDITOR \\\"\$\($get_file)\\\" >/dev/tty </dev/tty)+refresh-preview\"
$FORGIT_DIFF_FZF_OPTS $FORGIT_DIFF_FZF_OPTS
--prompt=\"$commits > \" --prompt=\"$commits > \"
" "
@ -169,10 +172,7 @@ _forgit_add() {
local git_add changed unmerged untracked files opts preview extract local git_add changed unmerged untracked files opts preview extract
git_add="git add $FORGIT_ADD_GIT_OPTS" git_add="git add $FORGIT_ADD_GIT_OPTS"
# Add files if passed as arguments # Add files if passed as arguments
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_add "$@" && git status -su; return $?; }
$git_add "$@" && git status -su
return $?
}
changed=$(git config --get-color color.status.changed red) changed=$(git config --get-color color.status.changed red)
unmerged=$(git config --get-color color.status.unmerged red) unmerged=$(git config --get-color color.status.unmerged red)
@ -194,7 +194,7 @@ else
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
-0 -m --nth 2..,.. -0 -m --nth 2..,..
--preview=\"$preview\" --preview=\"$preview\"
--bind=\"alt-e:execute-silent($EDITOR \$\(echo {} | $extract\) >/dev/tty </dev/tty)+refresh-preview\" --bind=\"alt-e:execute-silent($EDITOR \\\"\$\(echo {} | $extract\)\\\" >/dev/tty </dev/tty)+refresh-preview\"
$FORGIT_ADD_FZF_OPTS $FORGIT_ADD_FZF_OPTS
" "
files=$(git -c color.status=always -c status.relativePaths=true status -su | files=$(git -c color.status=always -c status.relativePaths=true status -su |
@ -211,10 +211,7 @@ _forgit_reset_head() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_reset_head cmd files opts rootdir local git_reset_head cmd files opts rootdir
git_reset_head="git reset -q $FORGIT_RESET_HEAD_GIT_OPTS HEAD" git_reset_head="git reset -q $FORGIT_RESET_HEAD_GIT_OPTS HEAD"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_reset_head "$@" && git status --short; return $?; }
$git_reset_head "$@" && git status --short
return $?
}
rootdir=$(git rev-parse --show-toplevel) rootdir=$(git rev-parse --show-toplevel)
cmd="git diff --staged --color=always -- $rootdir/{} | $_forgit_diff_pager " cmd="git diff --staged --color=always -- $rootdir/{} | $_forgit_diff_pager "
opts=" opts="
@ -234,10 +231,7 @@ _forgit_stash_show() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_stash_show git_stash_list cmd opts local git_stash_show git_stash_list cmd opts
git_stash_show="git stash show --color=always --ext-diff" git_stash_show="git stash show --color=always --ext-diff"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_stash_show "$@"; return $?; }
$git_stash_show "$@"
return $?
}
git_stash_list="git stash list $FORGIT_STASH_SHOW_GIT_OPTS" git_stash_list="git stash list $FORGIT_STASH_SHOW_GIT_OPTS"
cmd="echo {} |cut -d: -f1 |xargs -I% $git_stash_show % |$_forgit_diff_pager" cmd="echo {} |cut -d: -f1 |xargs -I% $git_stash_show % |$_forgit_diff_pager"
opts=" opts="
@ -270,10 +264,7 @@ _forgit_stash_push() {
# ignore -u as it's used implicitly # ignore -u as it's used implicitly
-u|--include-untracked) shift ;; -u|--include-untracked) shift ;;
# pass to git directly when encountering anything else # pass to git directly when encountering anything else
*) *) $git_stash_push "${args[@]}"; return $?
$git_stash_push "${args[@]}"
return $?
;;
esac esac
done done
local opts preview files local opts preview files
@ -298,10 +289,7 @@ _forgit_stash_push() {
# git clean selector # git clean selector
_forgit_clean() { _forgit_clean() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
_forgit_contains_non_flags "$@" && { _forgit_contains_non_flags "$@" && { git clean -q "$@"; return $?; }
git clean -q "$@"
return $?
}
local git_clean files opts local git_clean files opts
git_clean="git clean $FORGIT_CLEAN_GIT_OPTS" git_clean="git clean $FORGIT_CLEAN_GIT_OPTS"
opts=" opts="
@ -378,7 +366,8 @@ _forgit_cherry_pick_from_branch() {
" "
# loop until either the branch selector is closed or a commit to be cherry # loop until either the branch selector is closed or a commit to be cherry
# picked has been selected from within a branch # picked has been selected from within a branch
while true; do while true
do
if [[ -z $input_branch ]]; then if [[ -z $input_branch ]]; then
branch="$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $1}')" branch="$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $1}')"
else else
@ -451,10 +440,7 @@ _forgit_checkout_file() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_checkout cmd files opts local git_checkout cmd files opts
git_checkout="git checkout $FORGIT_CHECKOUT_FILE_GIT_OPTS" git_checkout="git checkout $FORGIT_CHECKOUT_FILE_GIT_OPTS"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_checkout -- "$@"; return $?; }
$git_checkout -- "$@"
return $?
}
cmd="git diff --color=always -- {} | $_forgit_diff_pager" cmd="git diff --color=always -- {} | $_forgit_diff_pager"
opts=" opts="
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
@ -512,10 +498,7 @@ _forgit_checkout_tag() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_checkout cmd opts preview local git_checkout cmd opts preview
git_checkout="git checkout $FORGIT_CHECKOUT_TAG_GIT_OPTS" git_checkout="git checkout $FORGIT_CHECKOUT_TAG_GIT_OPTS"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_checkout "$@"; return $?; }
$git_checkout "$@"
return $?
}
cmd="git tag -l --sort=-v:refname" cmd="git tag -l --sort=-v:refname"
preview="git log {1} $_forgit_log_preview_options" preview="git log {1} $_forgit_log_preview_options"
opts=" opts="
@ -534,10 +517,7 @@ _forgit_checkout_commit() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_checkout cmd opts graph local git_checkout cmd opts graph
git_checkout="git checkout $FORGIT_CHECKOUT_COMMIT_GIT_OPTS" git_checkout="git checkout $FORGIT_CHECKOUT_COMMIT_GIT_OPTS"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_checkout "$@"; return $?; }
$git_checkout "$@"
return $?
}
cmd="echo {} | $_forgit_extract_sha |xargs -I% git show --color=always % | $_forgit_show_pager" cmd="echo {} | $_forgit_extract_sha |xargs -I% git show --color=always % | $_forgit_show_pager"
opts=" opts="
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
@ -557,10 +537,7 @@ _forgit_branch_delete() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_branch preview opts cmd branches local git_branch preview opts cmd branches
git_branch="git branch $FORGIT_BRANCH_DELETE_GIT_OPTS" git_branch="git branch $FORGIT_BRANCH_DELETE_GIT_OPTS"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_branch -D "$@"; return $?; }
$git_branch -D "$@"
return $?
}
preview="git log {1} $_forgit_log_preview_options" preview="git log {1} $_forgit_log_preview_options"
opts=" opts="
@ -581,10 +558,7 @@ _forgit_revert_commit() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_revert cmd opts files preview commits IFS local git_revert cmd opts files preview commits IFS
git_revert="git revert $FORGIT_REVERT_COMMIT_GIT_OPTS" git_revert="git revert $FORGIT_REVERT_COMMIT_GIT_OPTS"
[[ $# -ne 0 ]] && { [[ $# -ne 0 ]] && { $git_revert "$@"; return $?; }
$git_revert "$@"
return $?
}
cmd="git log --graph --color=always --format='$_forgit_log_format' $* $_forgit_emojify" cmd="git log --graph --color=always --format='$_forgit_log_format' $* $_forgit_emojify"
opts=" opts="
@ -623,10 +597,7 @@ _forgit_blame() {
_forgit_inside_work_tree || return 1 _forgit_inside_work_tree || return 1
local git_blame opts flags preview file local git_blame opts flags preview file
git_blame="git blame $FORGIT_BLAME_GIT_OPTS" git_blame="git blame $FORGIT_BLAME_GIT_OPTS"
_forgit_contains_non_flags "$@" && { _forgit_contains_non_flags "$@" && { $git_blame "$@"; return $?; }
$git_blame "$@"
return $?
}
opts=" opts="
$FORGIT_FZF_DEFAULT_OPTS $FORGIT_FZF_DEFAULT_OPTS
$FORGIT_BLAME_FZF_OPTS $FORGIT_BLAME_FZF_OPTS

View file

@ -3,7 +3,7 @@ if not status is-interactive && test "$CI" != true
exit exit
end end
# Because of scoping rules, to capture the shell variables ezactly as they are, we must read # Because of scoping rules, to capture the shell variables exactly as they are, we must read
# them before even executing _fzf_search_variables. We use psub to store the # them before even executing _fzf_search_variables. We use psub to store the
# variables' info in temporary files and pass in the filenames as arguments. # variables' info in temporary files and pass in the filenames as arguments.
# This variable is global so that it can be referenced by fzf_configure_bindings and in tests # This variable is global so that it can be referenced by fzf_configure_bindings and in tests