📦️ deps(fish): remove and update plugins
This commit is contained in:
parent
dd62c1c26e
commit
e3499e9f09
26 changed files with 61 additions and 1490 deletions
|
@ -1,101 +0,0 @@
|
|||
#compdef git-forgit
|
||||
#description Utility tool for using git interactively
|
||||
#
|
||||
# forgit completions for zsh
|
||||
#
|
||||
# Place this file in your $fpath (e.g. /usr/share/zsh/site-functions) to enable
|
||||
# tab completions for forgit as a git subcommmand. When using forgit as a shell
|
||||
# plugin, additionally source completions/git-forgit.zsh after
|
||||
# forgit.plugin.zsh to enable tab completion for shell functions and aliases.
|
||||
|
||||
_git-branches() {
|
||||
_alternative "branches:branchname:($(git branch -a --format '%(refname:short)'))"
|
||||
}
|
||||
|
||||
_git-checkout-file() {
|
||||
_alternative "files:filename:($(git ls-files --modified))"
|
||||
}
|
||||
|
||||
_git-stash-show() {
|
||||
_alternative "files:filename:($(git stash list | sed -n -e 's/:.*//p'))"
|
||||
}
|
||||
|
||||
# The completions for git already define a _git-diff completion function, but
|
||||
# it provides the wrong results when called from _git-forgit because it heavily
|
||||
# depends on the context it's been called from (usage of $curcontext and
|
||||
# $CURRENT), so we use a simplified version here which always provides the same
|
||||
# results independent of the context.
|
||||
_git-forgit-diff() {
|
||||
_alternative \
|
||||
'commit-ranges::__git_commit_ranges' \
|
||||
'blobs-and-trees-in-treeish::__git_blobs_and_trees_in_treeish' \
|
||||
'files::__git_changed-in-working-tree_files' \
|
||||
'blobs::__git_blobs '
|
||||
}
|
||||
|
||||
_git-staged() {
|
||||
_alternative "files:filename:($(git diff --name-only --staged))"
|
||||
}
|
||||
|
||||
_git-forgit() {
|
||||
local subcommand cword cmd
|
||||
subcommand="${words[1]}"
|
||||
if [[ "$subcommand" != "forgit" ]]; then
|
||||
# Forgit is obviously called via a git alias. Get the original
|
||||
# aliased subcommand and proceed as if it was the previous word.
|
||||
cmd=$(git config --get "alias.$subcommand" | cut -d ' ' -f 2)
|
||||
cword=$((CURRENT + 1))
|
||||
else
|
||||
cword=$CURRENT
|
||||
cmd=${words[2]}
|
||||
fi
|
||||
|
||||
case ${cword} in
|
||||
1) ;;
|
||||
2)
|
||||
local -a subcommands
|
||||
subcommands=(
|
||||
'add:git add selector'
|
||||
'blame:git blame viewer'
|
||||
'branch_delete:git branch deletion selector'
|
||||
'checkout_branch:git checkout branch selector'
|
||||
'checkout_commit:git checkout commit selector'
|
||||
'checkout_file:git checkout-file selector'
|
||||
'checkout_tag:git checkout tag selector'
|
||||
'cherry_pick:git cherry-picking'
|
||||
'cherry_pick_from_branch:git cherry-picking with interactive branch selection'
|
||||
'clean:git clean selector'
|
||||
'diff:git diff viewer'
|
||||
'fixup:git fixup'
|
||||
'ignore:git ignore generator'
|
||||
'log:git commit viewer'
|
||||
'rebase:git rebase'
|
||||
'reset_head:git reset HEAD (unstage) selector'
|
||||
'revert_commit:git revert commit selector'
|
||||
'stash_show:git stash viewer'
|
||||
'stash_push:git stash push selector'
|
||||
)
|
||||
_describe -t commands 'git forgit' subcommands
|
||||
;;
|
||||
*)
|
||||
case ${cmd} in
|
||||
add) _git-add ;;
|
||||
branch_delete) _git-branches ;;
|
||||
checkout_branch) _git-branches ;;
|
||||
checkout_commit) __git_recent_commits ;;
|
||||
checkout_file) _git-checkout-file ;;
|
||||
checkout_tag) __git_tags ;;
|
||||
cherry_pick) _git-cherry-pick ;;
|
||||
cherry_pick_from_branch) _git-branches ;;
|
||||
clean) _git-clean ;;
|
||||
diff) _git-forgit-diff ;;
|
||||
fixup) __git_branch_names ;;
|
||||
log) _git-log ;;
|
||||
rebase) _git-rebase ;;
|
||||
reset_head) _git-staged ;;
|
||||
revert_commit) __git_recent_commits ;;
|
||||
stash_show) _git-stash-show ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
# forgit completions for bash
|
||||
|
||||
# When using forgit as a subcommand of git, put this file in one of the
|
||||
# following places and it will be loaded automatically on tab completion of
|
||||
# 'git forgit' or any configured git aliases of it:
|
||||
#
|
||||
# /usr/share/bash-completion/completions
|
||||
# ~/.local/share/bash-completion/completions
|
||||
#
|
||||
# When using forgit via the shell plugin, source this file explicitly after
|
||||
# forgit.plugin.zsh to enable tab completion for shell functions and aliases.
|
||||
|
||||
_git_branch_delete()
|
||||
{
|
||||
__gitcomp_nl "$(__git_heads)"
|
||||
}
|
||||
|
||||
_git_checkout_branch()
|
||||
{
|
||||
__gitcomp_nl "$(__git branch -a --format '%(refname:short)')"
|
||||
}
|
||||
|
||||
_git_checkout_file()
|
||||
{
|
||||
__gitcomp_nl "$(__git ls-files --modified)"
|
||||
}
|
||||
|
||||
_git_checkout_tag()
|
||||
{
|
||||
__gitcomp_nl "$(__git_tags)"
|
||||
}
|
||||
|
||||
_git_stash_show()
|
||||
{
|
||||
__gitcomp_nl "$(__git stash list | sed -n -e 's/:.*//p')"
|
||||
}
|
||||
|
||||
# Completion for git-forgit
|
||||
# This includes git aliases, e.g. "alias.cb=forgit checkout_branch" will
|
||||
# correctly complete available branches on "git cb".
|
||||
_git_forgit()
|
||||
{
|
||||
local subcommand cword cur prev cmds
|
||||
|
||||
subcommand="${COMP_WORDS[1]}"
|
||||
if [[ "$subcommand" != "forgit" ]]
|
||||
then
|
||||
# Forgit is obviously called via a git alias. Get the original
|
||||
# aliased subcommand and proceed as if it was the previous word.
|
||||
prev=$(git config --get "alias.$subcommand" | cut -d' ' -f 2)
|
||||
cword=$((${COMP_CWORD} + 1))
|
||||
else
|
||||
cword=${COMP_CWORD}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
fi
|
||||
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
cmds="
|
||||
add
|
||||
blame
|
||||
branch_delete
|
||||
checkout_branch
|
||||
checkout_commit
|
||||
checkout_file
|
||||
checkout_tag
|
||||
cherry_pick
|
||||
cherry_pick_from_branch
|
||||
clean
|
||||
diff
|
||||
fixup
|
||||
ignore
|
||||
log
|
||||
rebase
|
||||
reset_head
|
||||
revert_commit
|
||||
stash_show
|
||||
stash_push
|
||||
"
|
||||
|
||||
case ${cword} in
|
||||
2)
|
||||
COMPREPLY=($(compgen -W "${cmds}" -- ${cur}))
|
||||
;;
|
||||
3)
|
||||
case ${prev} in
|
||||
add) _git_add ;;
|
||||
branch_delete) _git_branch_delete ;;
|
||||
checkout_branch) _git_checkout_branch ;;
|
||||
checkout_commit) _git_checkout ;;
|
||||
checkout_file) _git_checkout_file ;;
|
||||
checkout_tag) _git_checkout_tag ;;
|
||||
cherry_pick) _git_cherry_pick ;;
|
||||
cherry_pick_from_branch) _git_checkout_branch ;;
|
||||
clean) _git_clean ;;
|
||||
diff) _git_diff ;;
|
||||
fixup) _git_branch ;;
|
||||
log) _git_log ;;
|
||||
rebase) _git_rebase ;;
|
||||
reset_head) _git_reset ;;
|
||||
revert_commit) _git_revert ;;
|
||||
stash_show) _git_stash_show ;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Check if forgit plugin is loaded
|
||||
if [[ $(type -t forgit::add) == function ]]
|
||||
then
|
||||
# We're reusing existing git completion functions, so load those first
|
||||
# and check if completion function exists afterwards.
|
||||
_completion_loader git
|
||||
[[ $(type -t __git_complete) == function ]] || return 1
|
||||
|
||||
# Completion for forgit plugin shell functions
|
||||
__git_complete forgit::add _git_add
|
||||
__git_complete forgit::branch::delete _git_branch_delete
|
||||
__git_complete forgit::checkout::branch _git_checkout_branch
|
||||
__git_complete forgit::checkout::commit _git_checkout
|
||||
__git_complete forgit::checkout::file _git_checkout_file
|
||||
__git_complete forgit::checkout::tag _git_checkout_tag
|
||||
__git_complete forgit::cherry::pick _git_cherry_pick
|
||||
__git_complete forgit::cherry::pick::from::branch _git_checkout_branch
|
||||
__git_complete forgit::clean _git_clean
|
||||
__git_complete forgit::diff _git_diff
|
||||
__git_complete forgit::fixup _git_branch
|
||||
__git_complete forgit::log _git_log
|
||||
__git_complete forgit::rebase _git_rebase
|
||||
__git_complete forgit::reset::head _git_reset
|
||||
__git_complete forgit::revert::commit _git_revert
|
||||
__git_complete forgit::stash::show _git_stash_show
|
||||
|
||||
# Completion for forgit plugin shell aliases
|
||||
if [[ -z "$FORGIT_NO_ALIASES" ]]; then
|
||||
__git_complete "${forgit_add}" _git_add
|
||||
__git_complete "${forgit_branch_delete}" _git_branch_delete
|
||||
__git_complete "${forgit_checkout_branch}" _git_checkout_branch
|
||||
__git_complete "${forgit_checkout_commit}" _git_checkout
|
||||
__git_complete "${forgit_checkout_file}" _git_checkout_file
|
||||
__git_complete "${forgit_checkout_tag}" _git_checkout_tag
|
||||
__git_complete "${forgit_cherry_pick}" _git_checkout_branch
|
||||
__git_complete "${forgit_clean}" _git_clean
|
||||
__git_complete "${forgit_diff}" _git_diff
|
||||
__git_complete "${forgit_fixup}" _git_branch
|
||||
__git_complete "${forgit_log}" _git_log
|
||||
__git_complete "${forgit_rebase}" _git_rebase
|
||||
__git_complete "${forgit_reset_head}" _git_reset
|
||||
__git_complete "${forgit_revert_commit}" _git_revert
|
||||
__git_complete "${forgit_stash_show}" _git_stash_show
|
||||
fi
|
||||
fi
|
|
@ -1,34 +0,0 @@
|
|||
#!/bin/zsh
|
||||
#
|
||||
# forgit completions for zsh plugin
|
||||
#
|
||||
# When using forgit via the shell plugin, place completions/_git-forgit in your
|
||||
# $fpath (e.g. /usr/share/zsh/site-functions) and source this file after
|
||||
# forgit.plugin.zsh to enable tab completion for shell functions and aliases.
|
||||
|
||||
# Check if forgit plugin is loaded
|
||||
if (( $+functions[forgit::add] )); then
|
||||
# We're reusing existing completion functions, so load those first
|
||||
# if not already loaded and check if completion function exists afterwards.
|
||||
(( $+functions[_git-add] )) || _git
|
||||
(( $+functions[_git-add] )) || return 1
|
||||
(( $+functions[_git-branches] )) || _git-forgit
|
||||
(( $+functions[_git-branches] )) || return 1
|
||||
# Completions for forgit plugin shell functions (also works for aliases)
|
||||
compdef _git-add forgit::add
|
||||
compdef _git-branches forgit::branch::delete
|
||||
compdef _git-branches forgit::checkout::branch
|
||||
compdef __git_recent_commits forgit::checkout::commit
|
||||
compdef _git-checkout-file forgit::checkout::file
|
||||
compdef __git_tags forgit::checkout::tag
|
||||
compdef _git-cherry-pick forgit::cherry::pick
|
||||
compdef _git-branches forgit::cherry::pick::from::branch
|
||||
compdef _git-clean forgit::clean
|
||||
compdef _git-forgit-diff forgit::diff
|
||||
compdef __git_branch_names forgit::fixup
|
||||
compdef _git-log forgit::log
|
||||
compdef _git-rebase forgit::rebase
|
||||
compdef _git-staged forgit::reset::head
|
||||
compdef __git_recent_commits forgit::revert::commit
|
||||
compdef _git-stash-show forgit::stash::show
|
||||
fi
|
|
@ -1 +0,0 @@
|
|||
__to_update_bookmark_completions
|
|
@ -1,186 +0,0 @@
|
|||
status is-interactive
|
||||
or exit 0
|
||||
|
||||
set -g __async_prompt_tmpdir (command mktemp -d)
|
||||
|
||||
# Setup after the user defined prompt functions are loaded.
|
||||
function __async_prompt_setup_on_startup --on-event fish_prompt
|
||||
functions -e (status current-function)
|
||||
|
||||
for func in (__async_prompt_config_functions)
|
||||
function $func -V func
|
||||
test -e $__async_prompt_tmpdir'/'$fish_pid'_'$func
|
||||
and cat $__async_prompt_tmpdir'/'$fish_pid'_'$func
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
not set -q async_prompt_on_variable
|
||||
and set async_prompt_on_variable fish_bind_mode
|
||||
function __async_prompt_fire --on-event fish_prompt (for var in $async_prompt_on_variable; printf '%s\n' --on-variable $var; end)
|
||||
set -l __async_prompt_last_pipestatus $pipestatus
|
||||
|
||||
for func in (__async_prompt_config_functions)
|
||||
set -l tmpfile $__async_prompt_tmpdir'/'$fish_pid'_'$func
|
||||
|
||||
if functions -q $func'_loading_indicator' && test -e $tmpfile
|
||||
read -zl last_prompt <$tmpfile
|
||||
eval (string escape -- $func'_loading_indicator' "$last_prompt") >$tmpfile
|
||||
end
|
||||
|
||||
__async_prompt_config_inherit_variables | __async_prompt_last_pipestatus=$__async_prompt_last_pipestatus __async_prompt_spawn \
|
||||
$func' | read -z prompt
|
||||
echo -n $prompt >'$tmpfile
|
||||
end
|
||||
end
|
||||
|
||||
function __async_prompt_spawn -a cmd
|
||||
set -l envs
|
||||
begin
|
||||
while read line
|
||||
switch "$line"
|
||||
case fish_bind_mode
|
||||
echo fish_bind_mode $fish_bind_mode
|
||||
case FISH_VERSION PWD _ history 'fish_*' hostname version status_generation
|
||||
case status pipestatus
|
||||
echo pipestatus $__async_prompt_last_pipestatus
|
||||
case SHLVL
|
||||
set envs $envs SHLVL=$SHLVL
|
||||
case '*'
|
||||
echo $line (string escape -- $$line)
|
||||
end
|
||||
end
|
||||
end | read -lz vars
|
||||
echo $vars | env $envs fish -c '
|
||||
function __async_prompt_signal
|
||||
kill -s "'(__async_prompt_config_internal_signal)'" '$fish_pid' 2>/dev/null
|
||||
end
|
||||
while read -a line
|
||||
test -z "$line"
|
||||
and continue
|
||||
|
||||
if test "$line[1]" = pipestatus
|
||||
set -f _pipestatus $line[2..]
|
||||
else
|
||||
eval set "$line"
|
||||
end
|
||||
end
|
||||
|
||||
function __async_prompt_set_status
|
||||
return $argv
|
||||
end
|
||||
if set -q _pipestatus
|
||||
switch (count $_pipestatus)
|
||||
case 1
|
||||
__async_prompt_set_status $_pipestatus[1]
|
||||
case 2
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2]
|
||||
case 3
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3]
|
||||
case 4
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3] \
|
||||
| __async_prompt_set_status $_pipestatus[4]
|
||||
case 5
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3] \
|
||||
| __async_prompt_set_status $_pipestatus[4] \
|
||||
| __async_prompt_set_status $_pipestatus[5]
|
||||
case 6
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3] \
|
||||
| __async_prompt_set_status $_pipestatus[4] \
|
||||
| __async_prompt_set_status $_pipestatus[5] \
|
||||
| __async_prompt_set_status $_pipestatus[6]
|
||||
case 7
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3] \
|
||||
| __async_prompt_set_status $_pipestatus[4] \
|
||||
| __async_prompt_set_status $_pipestatus[5] \
|
||||
| __async_prompt_set_status $_pipestatus[6] \
|
||||
| __async_prompt_set_status $_pipestatus[7]
|
||||
case 8
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3] \
|
||||
| __async_prompt_set_status $_pipestatus[4] \
|
||||
| __async_prompt_set_status $_pipestatus[5] \
|
||||
| __async_prompt_set_status $_pipestatus[6] \
|
||||
| __async_prompt_set_status $_pipestatus[7] \
|
||||
| __async_prompt_set_status $_pipestatus[8]
|
||||
default
|
||||
__async_prompt_set_status $_pipestatus[1] \
|
||||
| __async_prompt_set_status $_pipestatus[2] \
|
||||
| __async_prompt_set_status $_pipestatus[3] \
|
||||
| __async_prompt_set_status $_pipestatus[4] \
|
||||
| __async_prompt_set_status $_pipestatus[5] \
|
||||
| __async_prompt_set_status $_pipestatus[6] \
|
||||
| __async_prompt_set_status $_pipestatus[7] \
|
||||
| __async_prompt_set_status $_pipestatus[8] \
|
||||
| __async_prompt_set_status $_pipestatus[-1]
|
||||
end
|
||||
else
|
||||
true
|
||||
end
|
||||
'$cmd'
|
||||
__async_prompt_signal
|
||||
sleep 0.3
|
||||
__async_prompt_signal
|
||||
sleep 0.3
|
||||
__async_prompt_signal' &
|
||||
disown
|
||||
end
|
||||
|
||||
function __async_prompt_config_inherit_variables
|
||||
if set -q async_prompt_inherit_variables
|
||||
if test "$async_prompt_inherit_variables" = all
|
||||
set -ng
|
||||
else
|
||||
for item in $async_prompt_inherit_variables
|
||||
echo $item
|
||||
end
|
||||
end
|
||||
else
|
||||
echo CMD_DURATION
|
||||
echo fish_bind_mode
|
||||
echo pipestatus
|
||||
echo SHLVL
|
||||
echo status
|
||||
end
|
||||
end
|
||||
|
||||
function __async_prompt_config_functions
|
||||
set -l funcs (
|
||||
if set -q async_prompt_functions
|
||||
string join \n $async_prompt_functions
|
||||
else
|
||||
echo fish_prompt
|
||||
echo fish_right_prompt
|
||||
end
|
||||
)
|
||||
for func in $funcs
|
||||
functions -q "$func"
|
||||
or continue
|
||||
|
||||
echo $func
|
||||
end
|
||||
end
|
||||
|
||||
function __async_prompt_config_internal_signal
|
||||
if test -z "$async_prompt_signal_number"
|
||||
echo SIGUSR1
|
||||
else
|
||||
echo "$async_prompt_signal_number"
|
||||
end
|
||||
end
|
||||
|
||||
function __async_prompt_repaint_prompt --on-signal (__async_prompt_config_internal_signal)
|
||||
commandline -f repaint >/dev/null 2>/dev/null
|
||||
end
|
|
@ -1,708 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# MIT (c) Wenxuan Zhang
|
||||
|
||||
# This file is meant to be executed directly. If it's available on the PATH,
|
||||
# it can also be used as a subcommand of git, which then forwards all arguments
|
||||
# on to forgit. So, all of these commands will work as expected:
|
||||
#
|
||||
# `git forgit log`
|
||||
# `git forgit checkout_file`
|
||||
# `git forgit checkout_file README.md`
|
||||
#
|
||||
# This gives users the choice to set aliases inside of their git config instead
|
||||
# of their shell config if they prefer.
|
||||
|
||||
# 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)"
|
||||
export SHELL
|
||||
|
||||
# Get absolute forgit path
|
||||
FORGIT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)/$(basename -- "${BASH_SOURCE[0]}")
|
||||
|
||||
FORGIT_FZF_DEFAULT_OPTS="
|
||||
$FZF_DEFAULT_OPTS
|
||||
--ansi
|
||||
--height='80%'
|
||||
--bind='alt-k:preview-up,alt-p:preview-up'
|
||||
--bind='alt-j:preview-down,alt-n:preview-down'
|
||||
--bind='ctrl-r:toggle-all'
|
||||
--bind='ctrl-s:toggle-sort'
|
||||
--bind='?:toggle-preview'
|
||||
--bind='alt-w:toggle-preview-wrap'
|
||||
--preview-window='right:60%'
|
||||
+1
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
"
|
||||
|
||||
_forgit_warn() { printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$@" >&2; }
|
||||
_forgit_info() { printf "%b[Info]%b %s\n" '\e[0;32m' '\e[0m' "$@" >&2; }
|
||||
_forgit_inside_work_tree() { git rev-parse --is-inside-work-tree >/dev/null; }
|
||||
# tac is not available on OSX, tail -r is not available on Linux, so we use either of them
|
||||
_forgit_reverse_lines() { tac 2> /dev/null || tail -r; }
|
||||
|
||||
_forgit_previous_commit() {
|
||||
# "SHA~" is invalid when the commit is the first commit, but we can use "--root" instead
|
||||
if [[ "$(git rev-parse "$1")" == "$(git rev-list --max-parents=0 HEAD)" ]]; then
|
||||
echo "--root"
|
||||
else
|
||||
echo "$1~"
|
||||
fi
|
||||
}
|
||||
|
||||
_forgit_contains_non_flags() {
|
||||
while (("$#")); do
|
||||
case "$1" in
|
||||
-*) shift ;;
|
||||
*)
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# optional render emoji characters (https://github.com/wfxr/emoji-cli)
|
||||
hash emojify &>/dev/null && _forgit_emojify='|emojify'
|
||||
|
||||
# extract the first git sha occurring in the input and strip trailing newline
|
||||
_forgit_extract_sha="grep -Eo '[a-f0-9]+' | head -1 | tr -d '[:space:]'"
|
||||
|
||||
_forgit_pager=${FORGIT_PAGER:-$(git config core.pager || echo 'cat')}
|
||||
_forgit_show_pager=${FORGIT_SHOW_PAGER:-$(git config pager.show || echo "$_forgit_pager")}
|
||||
_forgit_diff_pager=${FORGIT_DIFF_PAGER:-$(git config pager.diff || echo "$_forgit_pager")}
|
||||
_forgit_ignore_pager=${FORGIT_IGNORE_PAGER:-$(hash bat &>/dev/null && echo 'bat -l gitignore --color=always' || echo 'cat')}
|
||||
_forgit_blame_pager=${FORGIT_BLAME_PAGER:-$(git config pager.blame || echo "$_forgit_pager")}
|
||||
_forgit_enter_pager=${FORGIT_ENTER_PAGER:-"LESS='-r' less"}
|
||||
|
||||
_forgit_log_format=${FORGIT_LOG_FORMAT:-%C(auto)%h%d %s %C(black)%C(bold)%cr%Creset}
|
||||
_forgit_log_preview_options="--graph --pretty=format:'$_forgit_log_format' --color=always --abbrev-commit --date=relative"
|
||||
_forgit_fullscreen_context=${FORGIT_FULLSCREEN_CONTEXT:-10}
|
||||
_forgit_preview_context=${FORGIT_PREVIEW_CONTEXT:-3}
|
||||
_forgit_is_file_tracked="(git ls-files {} --error-unmatch) &> /dev/null"
|
||||
|
||||
# git commit viewer
|
||||
_forgit_log() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local opts graph files log_format preview_cmd enter_cmd
|
||||
files=$(sed -nE 's/.*-- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command
|
||||
preview_cmd="echo {} | $_forgit_extract_sha | xargs -I% git show --color=always -U$_forgit_preview_context % -- $files | $_forgit_show_pager"
|
||||
enter_cmd="echo {} | $_forgit_extract_sha | xargs -I% ${FORGIT} diff %^! $files"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"enter:execute($enter_cmd)\"
|
||||
--bind=\"ctrl-y:execute-silent(echo {} | $_forgit_extract_sha | ${FORGIT_COPY_CMD:-pbcopy})\"
|
||||
--preview=\"$preview_cmd\"
|
||||
$FORGIT_LOG_FZF_OPTS
|
||||
"
|
||||
graph=--graph
|
||||
[[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph=
|
||||
log_format=${FORGIT_GLO_FORMAT:-$_forgit_log_format}
|
||||
eval "git log $graph --color=always --format='$log_format' $FORGIT_LOG_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
|
||||
}
|
||||
|
||||
# git diff viewer
|
||||
_forgit_diff() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local files opts commits repo get_files preview_cmd enter_cmd
|
||||
[[ $# -ne 0 ]] && {
|
||||
if git rev-parse "$1" -- &>/dev/null ; then
|
||||
if [[ $# -gt 1 ]] && git rev-parse "$2" -- &>/dev/null; then
|
||||
commits="$1 $2" && files=("${@:3}")
|
||||
else
|
||||
commits="$1" && files=("${@:2}")
|
||||
fi
|
||||
else
|
||||
files=("$@")
|
||||
fi
|
||||
}
|
||||
repo="$(git rev-parse --show-toplevel)"
|
||||
# Construct a null-terminated list of the filenames
|
||||
# The input looks like one of these lines:
|
||||
# [R100] file -> another file
|
||||
# [A] file with spaces
|
||||
# [D] oldfile
|
||||
# And we transform it to this representation for further usage with "xargs -0":
|
||||
# file\0another file\0
|
||||
# file with spaces\0
|
||||
# oldfile\0
|
||||
# We have to do a two-step sed -> tr pipe because OSX's sed implementation does
|
||||
# not support the null-character directly.
|
||||
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}".
|
||||
# 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.
|
||||
# The string is evaluated a few subsequent times, so we need multiple escapes.
|
||||
escaped_commits=${commits//\{/\\\\\{}
|
||||
git_diff="git diff --color=always $FORGIT_DIFF_GIT_OPTS $escaped_commits"
|
||||
preview_cmd="cd '$repo' && $get_files | xargs -0 $git_diff -U$_forgit_preview_context -- | $_forgit_diff_pager"
|
||||
enter_cmd="cd '$repo' && $get_files | xargs -0 $git_diff -U$_forgit_fullscreen_context -- | $_forgit_diff_pager"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+m -0 --bind=\"enter:execute($enter_cmd | $_forgit_enter_pager)\"
|
||||
--preview=\"$preview_cmd\"
|
||||
--bind=\"alt-e:execute-silent($EDITOR \\\"\$\($get_file)\\\" >/dev/tty </dev/tty)+refresh-preview\"
|
||||
$FORGIT_DIFF_FZF_OPTS
|
||||
--prompt=\"$commits > \"
|
||||
"
|
||||
eval "git diff --name-status $FORGIT_DIFF_GIT_OPTS $commits -- ${files[*]} | sed -E 's/^([[:alnum:]]+)[[:space:]]+(.*)$/[\1] \2/'" |
|
||||
sed 's/ / -> /2' | expand -t 8 |
|
||||
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
|
||||
}
|
||||
|
||||
# git add selector
|
||||
_forgit_add() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_add changed unmerged untracked files opts preview extract
|
||||
git_add="git add $FORGIT_ADD_GIT_OPTS"
|
||||
# Add files if passed as arguments
|
||||
[[ $# -ne 0 ]] && { $git_add "$@" && git status -su; return $?; }
|
||||
|
||||
changed=$(git config --get-color color.status.changed red)
|
||||
unmerged=$(git config --get-color color.status.unmerged red)
|
||||
untracked=$(git config --get-color color.status.untracked red)
|
||||
# NOTE: paths listed by 'git status -su' mixed with quoted and unquoted style
|
||||
# remove indicators | remove original path for rename case | remove surrounding quotes
|
||||
extract="
|
||||
sed 's/^.*] //' |
|
||||
sed 's/.* -> //' |
|
||||
sed -e 's/^\\\"//' -e 's/\\\"\$//'"
|
||||
preview="
|
||||
file=\$(echo {} | $extract)
|
||||
if (git status -s -- \\\"\$file\\\" | grep '^??') &>/dev/null; then # diff with /dev/null for untracked files
|
||||
git diff --color=always --no-index -- /dev/null \\\"\$file\\\" | $_forgit_diff_pager | sed '2 s/added:/untracked:/'
|
||||
else
|
||||
git diff --color=always -- \\\"\$file\\\" | $_forgit_diff_pager
|
||||
fi"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-0 -m --nth 2..,..
|
||||
--preview=\"$preview\"
|
||||
--bind=\"alt-e:execute-silent($EDITOR \\\"\$\(echo {} | $extract\)\\\" >/dev/tty </dev/tty)+refresh-preview\"
|
||||
$FORGIT_ADD_FZF_OPTS
|
||||
"
|
||||
files=$(git -c color.status=always -c status.relativePaths=true status -su |
|
||||
grep -F -e "$changed" -e "$unmerged" -e "$untracked" |
|
||||
sed -E 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/' |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf |
|
||||
sh -c "$extract")
|
||||
[[ -n "$files" ]] && echo "$files"| tr '\n' '\0' | $git_add --pathspec-file-nul --pathspec-from-file - && git status -su && return
|
||||
echo 'Nothing to add.'
|
||||
}
|
||||
|
||||
# git reset HEAD (unstage) selector
|
||||
_forgit_reset_head() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_reset_head cmd files opts rootdir
|
||||
git_reset_head="git reset -q $FORGIT_RESET_HEAD_GIT_OPTS HEAD"
|
||||
[[ $# -ne 0 ]] && { $git_reset_head "$@" && git status --short; return $?; }
|
||||
rootdir=$(git rev-parse --show-toplevel)
|
||||
cmd="git diff --staged --color=always -- $rootdir/{} | $_forgit_diff_pager "
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
--preview=\"$cmd\"
|
||||
$FORGIT_RESET_HEAD_FZF_OPTS
|
||||
"
|
||||
files="$(git diff --staged --name-only | FZF_DEFAULT_OPTS="$opts" fzf)"
|
||||
# shellcheck disable=2086
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% $git_reset_head "$rootdir"/% && git status --short && return
|
||||
echo 'Nothing to unstage.'
|
||||
}
|
||||
|
||||
# git stash viewer
|
||||
_forgit_stash_show() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_stash_show git_stash_list cmd opts
|
||||
git_stash_show="git stash show --color=always --ext-diff"
|
||||
[[ $# -ne 0 ]] && { $git_stash_show "$@"; return $?; }
|
||||
git_stash_list="git stash list $FORGIT_STASH_SHOW_GIT_OPTS"
|
||||
cmd="echo {} |cut -d: -f1 |xargs -I% $git_stash_show % |$_forgit_diff_pager"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m -0 --tiebreak=index --bind=\"enter:execute($cmd | $_forgit_enter_pager)\"
|
||||
--bind=\"ctrl-y:execute-silent(echo {} | cut -d: -f1 | tr -d '[:space:]' | ${FORGIT_COPY_CMD:-pbcopy})\"
|
||||
--preview=\"$cmd\"
|
||||
$FORGIT_STASH_FZF_OPTS
|
||||
"
|
||||
$git_stash_list | 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
|
||||
}
|
||||
|
||||
# git stash push selector
|
||||
_forgit_stash_push() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_stash_push msg args
|
||||
git_stash_push="git stash push $FORGIT_STASH_PUSH_GIT_OPTS"
|
||||
args=( "$@" )
|
||||
while (( "$#" )); do
|
||||
case "$1" in
|
||||
# allow message as argument
|
||||
-m|--message)
|
||||
msg="$2"
|
||||
shift 2
|
||||
;;
|
||||
# ignore -u as it's used implicitly
|
||||
-u|--include-untracked) shift ;;
|
||||
# pass to git directly when encountering anything else
|
||||
*) $git_stash_push "${args[@]}"; return $?
|
||||
esac
|
||||
done
|
||||
local opts preview files
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m
|
||||
$FORGIT_STASH_PUSH_FZF_OPTS
|
||||
"
|
||||
preview="
|
||||
if $_forgit_is_file_tracked; then
|
||||
git diff --color=always {} | $_forgit_diff_pager
|
||||
else
|
||||
git diff --color=always /dev/null {} | $_forgit_diff_pager
|
||||
fi
|
||||
"
|
||||
# Show both modified and untracked files
|
||||
files=$(git ls-files --exclude-standard --modified --others | FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview")
|
||||
[[ -z "$files" ]] && return 1
|
||||
echo "${files[@]}" | tr '\n' '\0' | $git_stash_push ${msg:+-m "$msg"} -u --pathspec-file-nul --pathspec-from-file -
|
||||
}
|
||||
|
||||
# git clean selector
|
||||
_forgit_clean() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
_forgit_contains_non_flags "$@" && { git clean -q "$@"; return $?; }
|
||||
local git_clean files opts
|
||||
git_clean="git clean $FORGIT_CLEAN_GIT_OPTS"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
$FORGIT_CLEAN_FZF_OPTS
|
||||
"
|
||||
# Note: Postfix '/' in directory path should be removed. Otherwise the directory itself will not be removed.
|
||||
files=$(git clean -xdffn "$@"| sed 's/^Would remove //' | FZF_DEFAULT_OPTS="$opts" fzf |sed 's#/$##')
|
||||
# shellcheck disable=2086
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | xargs -0 -I% $git_clean -xdff '%' && git status --short && return
|
||||
echo 'Nothing to clean.'
|
||||
}
|
||||
|
||||
_forgit_cherry_pick() {
|
||||
local git_cherry_pick base target preview opts fzf_selection fzf_exitval
|
||||
|
||||
git_cherry_pick="git cherry-pick $FORGIT_CHERRY_PICK_GIT_OPTS"
|
||||
|
||||
base=$(git branch --show-current)
|
||||
[[ -z "$base" ]] && echo "Current commit is not on a branch." && return 1
|
||||
|
||||
[[ -z $1 ]] && echo "Please specify target branch" && return 1
|
||||
target="$1"
|
||||
|
||||
# in this function, we do something interesting to maintain proper ordering as it's assumed
|
||||
# you generally want to cherry pick oldest->newest when you multiselect
|
||||
# The instances of "cut", "nl" and "sort" all serve this purpose
|
||||
# Please see https://github.com/wfxr/forgit/issues/253 for more details
|
||||
|
||||
preview="echo {} | cut -f2- | $_forgit_extract_sha | xargs -I% git show --color=always % | $_forgit_show_pager"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
--preview=\"$preview\"
|
||||
--multi --ansi --with-nth 2.. -0 --tiebreak=index
|
||||
$FORGIT_CHERRY_PICK_FZF_OPTS
|
||||
"
|
||||
# Note: do not add any pipe after the fzf call here, otherwise the fzf_exitval is not propagated properly.
|
||||
# Any eventual post processing can be done afterwards when the "commits" variable is assigned below.
|
||||
fzf_selection=$(git log --right-only --color=always --cherry-pick --oneline "$base"..."$target" | nl |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf)
|
||||
fzf_exitval=$?
|
||||
[[ $fzf_exitval != 0 ]] && return $fzf_exitval
|
||||
[[ -z "$fzf_selection" ]] && return $fzf_exitval
|
||||
|
||||
${IFS+"false"} && unset old_IFS || old_IFS="$IFS"
|
||||
IFS=$'\n'
|
||||
# shellcheck disable=2207
|
||||
commits=($(echo "$fzf_selection" | sort --numeric-sort --key=1 | cut -f2 | cut -d' ' -f1 | _forgit_reverse_lines))
|
||||
${old_IFS+"false"} && unset IFS || IFS="$old_IFS"
|
||||
[ ${#commits[@]} -eq 0 ] && return 1
|
||||
|
||||
$git_cherry_pick "${commits[@]}"
|
||||
}
|
||||
|
||||
_forgit_cherry_pick_from_branch() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local cmd preview opts branch exitval input_branch args base
|
||||
|
||||
base=$(git branch --show-current)
|
||||
[[ -z "$base" ]] && echo "Current commit is not on a branch." && return 1
|
||||
|
||||
args=("$@")
|
||||
if [[ $# -ne 0 ]]; then
|
||||
input_branch=${args[0]}
|
||||
fi
|
||||
cmd="git branch --color=always --all | LC_ALL=C sort -k1.1,1.1 -rs"
|
||||
preview="git log --right-only --color=always --cherry-pick --oneline $base...{1}"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index --header-lines=1
|
||||
--preview=\"$preview\"
|
||||
$FORGIT_CHERRY_PICK_FROM_BRANCH_FZF_OPTS
|
||||
"
|
||||
# loop until either the branch selector is closed or a commit to be cherry
|
||||
# picked has been selected from within a branch
|
||||
while true
|
||||
do
|
||||
if [[ -z $input_branch ]]; then
|
||||
branch="$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $1}')"
|
||||
else
|
||||
branch=$input_branch
|
||||
fi
|
||||
|
||||
unset input_branch
|
||||
[[ -z "$branch" ]] && return 1
|
||||
|
||||
_forgit_cherry_pick "$branch"
|
||||
|
||||
exitval=$?
|
||||
[[ $exitval != 130 ]] || [[ $# -ne 0 ]] && return $exitval
|
||||
done
|
||||
}
|
||||
|
||||
_forgit_rebase() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_rebase cmd preview opts graph files target_commit prev_commit
|
||||
git_rebase="git rebase -i $FORGIT_REBASE_GIT_OPTS"
|
||||
graph=--graph
|
||||
[[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph=
|
||||
cmd="git log $graph --color=always --format='$_forgit_log_format' $* $_forgit_emojify"
|
||||
files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command
|
||||
preview="echo {} | $_forgit_extract_sha | 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 {} | $_forgit_extract_sha | ${FORGIT_COPY_CMD:-pbcopy})\"
|
||||
--preview=\"$preview\"
|
||||
$FORGIT_REBASE_FZF_OPTS
|
||||
"
|
||||
target_commit=$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | eval "$_forgit_extract_sha")
|
||||
if [[ -n "$target_commit" ]]; then
|
||||
prev_commit=$(_forgit_previous_commit "$target_commit")
|
||||
|
||||
$git_rebase "$prev_commit"
|
||||
fi
|
||||
}
|
||||
|
||||
_forgit_fixup() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
git diff --cached --quiet && echo 'Nothing to fixup: there are no staged changes.' && return 1
|
||||
local git_fixup cmd preview opts graph files target_commit prev_commit
|
||||
git_fixup="git commit --fixup $FORGIT_FIXUP_GIT_OPTS"
|
||||
graph=--graph
|
||||
[[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph=
|
||||
cmd="git log $graph --color=always --format='$_forgit_log_format' $* $_forgit_emojify"
|
||||
files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*")
|
||||
preview="echo {} | $_forgit_extract_sha | 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 {} | $_forgit_extract_sha | ${FORGIT_COPY_CMD:-pbcopy})\"
|
||||
--preview=\"$preview\"
|
||||
$FORGIT_FIXUP_FZF_OPTS
|
||||
"
|
||||
target_commit=$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | eval "$_forgit_extract_sha")
|
||||
if [[ -n "$target_commit" ]] && $git_fixup "$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
|
||||
|
||||
}
|
||||
|
||||
# git checkout-file selector
|
||||
_forgit_checkout_file() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_checkout cmd files opts
|
||||
git_checkout="git checkout $FORGIT_CHECKOUT_FILE_GIT_OPTS"
|
||||
[[ $# -ne 0 ]] && { $git_checkout -- "$@"; return $?; }
|
||||
cmd="git diff --color=always -- {} | $_forgit_diff_pager"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m -0
|
||||
--preview=\"$cmd\"
|
||||
$FORGIT_CHECKOUT_FILE_FZF_OPTS
|
||||
"
|
||||
files="$(git ls-files --modified "$(git rev-parse --show-toplevel)"| FZF_DEFAULT_OPTS="$opts" fzf)"
|
||||
[[ -n "$files" ]] && echo "$files" | tr '\n' '\0' | $git_checkout --pathspec-file-nul --pathspec-from-file -
|
||||
}
|
||||
|
||||
# git checkout-branch selector
|
||||
_forgit_checkout_branch() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
# if called with arguments, check if branch exists, else create a new one
|
||||
if [[ $# -ne 0 ]]; then
|
||||
if [[ "$*" == "-" ]] || git show-branch "$@" &>/dev/null; then
|
||||
git switch "$@"
|
||||
else
|
||||
git switch -c "$@"
|
||||
fi
|
||||
checkout_status=$?
|
||||
git status --short
|
||||
return $checkout_status
|
||||
fi
|
||||
|
||||
local git_checkout cmd preview opts branch
|
||||
cmd="git branch --color=always ${FORGIT_CHECKOUT_BRANCH_BRANCH_GIT_OPTS:---all} | LC_ALL=C sort -k1.1,1.1 -rs"
|
||||
preview="git log {1} $_forgit_log_preview_options"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index --header-lines=1
|
||||
--preview=\"$preview\"
|
||||
$FORGIT_CHECKOUT_BRANCH_FZF_OPTS
|
||||
"
|
||||
branch="$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $1}')"
|
||||
[[ -z "$branch" ]] && return 1
|
||||
|
||||
git_checkout="git checkout $FORGIT_CHECKOUT_BRANCH_GIT_OPTS"
|
||||
# track the remote branch if possible
|
||||
if [[ "$branch" == "remotes/origin/"* ]]; then
|
||||
if git branch | grep -qw "${branch#remotes/origin/}"; then
|
||||
# hack to force creating a new branch which tracks the remote if a local branch already exists
|
||||
$git_checkout -b "track/${branch#remotes/origin/}" --track "$branch"
|
||||
elif ! $git_checkout --track "$branch" 2>/dev/null; then
|
||||
$git_checkout "$branch"
|
||||
fi
|
||||
else
|
||||
$git_checkout "$branch"
|
||||
fi
|
||||
}
|
||||
|
||||
# git checkout-tag selector
|
||||
_forgit_checkout_tag() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_checkout cmd opts preview
|
||||
git_checkout="git checkout $FORGIT_CHECKOUT_TAG_GIT_OPTS"
|
||||
[[ $# -ne 0 ]] && { $git_checkout "$@"; return $?; }
|
||||
cmd="git tag -l --sort=-v:refname"
|
||||
preview="git log {1} $_forgit_log_preview_options"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--preview=\"$preview\"
|
||||
$FORGIT_CHECKOUT_TAG_FZF_OPTS
|
||||
"
|
||||
tag="$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf)"
|
||||
[[ -z "$tag" ]] && return 1
|
||||
$git_checkout "$tag"
|
||||
}
|
||||
|
||||
# git checkout-commit selector
|
||||
_forgit_checkout_commit() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_checkout cmd opts graph
|
||||
git_checkout="git checkout $FORGIT_CHECKOUT_COMMIT_GIT_OPTS"
|
||||
[[ $# -ne 0 ]] && { $git_checkout "$@"; return $?; }
|
||||
cmd="echo {} | $_forgit_extract_sha |xargs -I% git show --color=always % | $_forgit_show_pager"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s +m --tiebreak=index
|
||||
--bind=\"ctrl-y:execute-silent(echo {} | $_forgit_extract_sha | ${FORGIT_COPY_CMD:-pbcopy})\"
|
||||
--preview=\"$cmd\"
|
||||
$FORGIT_CHECKOUT_COMMIT_FZF_OPTS
|
||||
"
|
||||
graph=--graph
|
||||
[[ $FORGIT_LOG_GRAPH_ENABLE == false ]] && graph=
|
||||
# shellcheck disable=2086
|
||||
eval "git log $graph --color=always --format='$_forgit_log_format' $_forgit_emojify" |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf | eval "$_forgit_extract_sha" | xargs -I% $git_checkout % --
|
||||
}
|
||||
|
||||
_forgit_branch_delete() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_branch preview opts cmd branches
|
||||
git_branch="git branch $FORGIT_BRANCH_DELETE_GIT_OPTS"
|
||||
[[ $# -ne 0 ]] && { $git_branch -D "$@"; return $?; }
|
||||
preview="git log {1} $_forgit_log_preview_options"
|
||||
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s --multi --tiebreak=index --header-lines=1
|
||||
--preview=\"$preview\"
|
||||
$FORGIT_BRANCH_DELETE_FZF_OPTS
|
||||
"
|
||||
|
||||
cmd="git branch --color=always | LC_ALL=C sort -k1.1,1.1 -rs"
|
||||
branches=$(eval "$cmd" | FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $1}')
|
||||
# shellcheck disable=2086
|
||||
echo -n "$branches" | tr '\n' '\0' | xargs -I{} -0 $git_branch -D {}
|
||||
}
|
||||
|
||||
# git revert-commit selector
|
||||
_forgit_revert_commit() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_revert cmd opts files preview commits IFS
|
||||
git_revert="git revert $FORGIT_REVERT_COMMIT_GIT_OPTS"
|
||||
[[ $# -ne 0 ]] && { $git_revert "$@"; return $?; }
|
||||
|
||||
cmd="git log --graph --color=always --format='$_forgit_log_format' $* $_forgit_emojify"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
+s --tiebreak=index
|
||||
--ansi --with-nth 2..
|
||||
$FORGIT_REVERT_COMMIT_FZF_OPTS
|
||||
"
|
||||
|
||||
# in this function, we do something interesting to maintain proper ordering as it's assumed
|
||||
# you generally want to revert newest->oldest when you multiselect
|
||||
# The instances of "cut", "nl" and "sort" all serve this purpose
|
||||
# Please see https://github.com/wfxr/forgit/issues/253 for more details
|
||||
|
||||
files=$(sed -nE 's/.* -- (.*)/\1/p' <<< "$*") # extract files parameters for `git show` command
|
||||
preview="echo {} | cut -f2- | $_forgit_extract_sha | xargs -I% git show --color=always % -- $files | $_forgit_show_pager"
|
||||
|
||||
${IFS+"false"} && unset old_IFS || old_IFS="$IFS"
|
||||
IFS=$'\n'
|
||||
# shellcheck disable=2207
|
||||
commits=($(eval "$cmd" |
|
||||
nl |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview" -m |
|
||||
sort --numeric-sort --key=1 |
|
||||
cut -f2- |
|
||||
sed 's/^[^a-f^0-9]*\([a-f0-9]*\).*/\1/'))
|
||||
${old_IFS+"false"} && unset IFS || IFS="$old_IFS"
|
||||
|
||||
[ ${#commits[@]} -eq 0 ] && return 1
|
||||
|
||||
$git_revert "${commits[@]}"
|
||||
}
|
||||
|
||||
# git blame viewer
|
||||
_forgit_blame() {
|
||||
_forgit_inside_work_tree || return 1
|
||||
local git_blame opts flags preview file
|
||||
git_blame="git blame $FORGIT_BLAME_GIT_OPTS"
|
||||
_forgit_contains_non_flags "$@" && { $git_blame "$@"; return $?; }
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
$FORGIT_BLAME_FZF_OPTS
|
||||
"
|
||||
flags=$(git rev-parse --flags "$@")
|
||||
preview="
|
||||
if $_forgit_is_file_tracked; then
|
||||
git blame {} --date=short $FORGIT_BLAME_GIT_OPTS $flags | $_forgit_blame_pager
|
||||
else
|
||||
echo File not tracked
|
||||
fi
|
||||
"
|
||||
file=$(FZF_DEFAULT_OPTS="$opts" fzf --preview="$preview")
|
||||
[[ -z "$file" ]] && return 1
|
||||
# shellcheck disable=2086
|
||||
eval $git_blame "$file" "$flags"
|
||||
}
|
||||
|
||||
# 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}"
|
||||
export FORGIT_GI_TEMPLATES=${FORGIT_GI_TEMPLATES:-$FORGIT_GI_REPO_LOCAL/templates}
|
||||
|
||||
_forgit_ignore() {
|
||||
[ -d "$FORGIT_GI_REPO_LOCAL" ] || _forgit_ignore_update
|
||||
local IFS cmd args opts
|
||||
cmd="$_forgit_ignore_pager $FORGIT_GI_TEMPLATES/{2}{,.gitignore} 2>/dev/null"
|
||||
opts="
|
||||
$FORGIT_FZF_DEFAULT_OPTS
|
||||
-m --preview-window='right:70%'
|
||||
--preview=\"eval $cmd\"
|
||||
$FORGIT_IGNORE_FZF_OPTS
|
||||
"
|
||||
${IFS+"false"} && unset old_IFS || old_IFS="$IFS"
|
||||
IFS=$'\n'
|
||||
# shellcheck disable=SC2206,2207
|
||||
args=($@) && [[ $# -eq 0 ]] && args=($(_forgit_ignore_list | nl -nrn -w4 -s' ' |
|
||||
FZF_DEFAULT_OPTS="$opts" fzf | awk '{print $2}'))
|
||||
${old_IFS+"false"} && unset IFS || IFS="$old_IFS"
|
||||
[ ${#args[@]} -eq 0 ] && return 1
|
||||
# shellcheck disable=SC2068
|
||||
_forgit_ignore_get ${args[@]}
|
||||
}
|
||||
_forgit_ignore_update() {
|
||||
if [[ -d "$FORGIT_GI_REPO_LOCAL" ]]; then
|
||||
_forgit_info 'Updating gitignore repo...'
|
||||
(cd "$FORGIT_GI_REPO_LOCAL" && git pull --no-rebase --ff) || return 1
|
||||
else
|
||||
_forgit_info 'Initializing gitignore repo...'
|
||||
git clone --depth=1 "$FORGIT_GI_REPO_REMOTE" "$FORGIT_GI_REPO_LOCAL"
|
||||
fi
|
||||
}
|
||||
_forgit_ignore_get() {
|
||||
local item filename header
|
||||
for item in "$@"; do
|
||||
if filename=$(find -L "$FORGIT_GI_TEMPLATES" -type f \( -iname "${item}.gitignore" -o -iname "${item}" \) -print -quit); then
|
||||
[[ -z "$filename" ]] && _forgit_warn "No gitignore template found for '$item'." && continue
|
||||
header="${filename##*/}" && header="${header%.gitignore}"
|
||||
echo "### $header" && cat "$filename" && echo
|
||||
fi
|
||||
done
|
||||
}
|
||||
_forgit_ignore_list() {
|
||||
find "$FORGIT_GI_TEMPLATES" -print |sed -e 's#.gitignore$##' -e 's#.*/##' | sort -fu
|
||||
}
|
||||
_forgit_ignore_clean() {
|
||||
setopt localoptions rmstarsilent
|
||||
[[ -d "$FORGIT_GI_REPO_LOCAL" ]] && rm -rf "$FORGIT_GI_REPO_LOCAL"
|
||||
}
|
||||
|
||||
valid_commands=(
|
||||
"add"
|
||||
"blame"
|
||||
"branch_delete"
|
||||
"checkout_branch"
|
||||
"checkout_commit"
|
||||
"checkout_file"
|
||||
"checkout_tag"
|
||||
"cherry_pick"
|
||||
"cherry_pick_from_branch"
|
||||
"clean"
|
||||
"diff"
|
||||
"fixup"
|
||||
"ignore"
|
||||
"log"
|
||||
"rebase"
|
||||
"reset_head"
|
||||
"revert_commit"
|
||||
"stash_show"
|
||||
"stash_push"
|
||||
)
|
||||
|
||||
cmd="$1"
|
||||
shift
|
||||
|
||||
# shellcheck disable=SC2076
|
||||
if [[ ! " ${valid_commands[*]} " =~ " ${cmd} " ]]; then
|
||||
if [[ -z "$cmd" ]]; then
|
||||
printf "forgit: missing command\n\n"
|
||||
else
|
||||
printf "forgit: '%s' is not a valid forgit command.\n\n" "$cmd"
|
||||
fi
|
||||
printf "The following commands are supported:\n"
|
||||
printf "\t%s\n" "${valid_commands[@]}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_forgit_"${cmd}" "$@"
|
|
@ -24,7 +24,7 @@ if not status is-interactive
|
|||
exit
|
||||
end
|
||||
|
||||
set -g __done_version 1.19.0
|
||||
set -g __done_version 1.19.3
|
||||
|
||||
function __done_run_powershell_script
|
||||
set -l powershell_exe (command --search "powershell.exe")
|
||||
|
@ -83,7 +83,7 @@ function __done_get_focused_window_id
|
|||
and type -q jq
|
||||
swaymsg --type get_tree | jq '.. | objects | select(.focused == true) | .id'
|
||||
else if test -n "$HYPRLAND_INSTANCE_SIGNATURE"
|
||||
hyprctl activewindow | awk 'NR==13 {print $2}'
|
||||
hyprctl activewindow | awk 'NR==1 {print $2}'
|
||||
else if begin
|
||||
test "$XDG_SESSION_DESKTOP" = gnome; and type -q gdbus
|
||||
end
|
||||
|
@ -118,7 +118,10 @@ function __done_is_tmux_window_active
|
|||
# ppid == "tmux" -> break
|
||||
set tmux_fish_pid $fish_pid
|
||||
while set tmux_fish_ppid (ps -o ppid= -p $tmux_fish_pid | string trim)
|
||||
and ! string match -q "tmux*" (basename (ps -o command= -p $tmux_fish_ppid))
|
||||
# remove leading hyphen so that basename does not treat it as an argument (e.g. -fish), and return only
|
||||
# the actual command and not its arguments so that basename finds the correct command name.
|
||||
# (e.g. '/usr/bin/tmux' from command '/usr/bin/tmux new-session -c /some/start/dir')
|
||||
and ! string match -q "tmux*" (basename (ps -o command= -p $tmux_fish_ppid | string replace -r '^-' '' | string split ' ')[1])
|
||||
set tmux_fish_pid $tmux_fish_ppid
|
||||
end
|
||||
|
||||
|
@ -139,7 +142,7 @@ function __done_is_process_window_focused
|
|||
end
|
||||
|
||||
if set -q __done_kitty_remote_control
|
||||
kitty @ --password="$__done_kitty_remote_control_password" ls | jq -e ".[].tabs.[] | select(any(.windows.[]; .is_self)) | .is_focused" >/dev/null
|
||||
kitty @ --password="$__done_kitty_remote_control_password" ls | jq -e ".[].tabs[] | select(any(.windows[]; .is_self)) | .is_focused" >/dev/null
|
||||
return $status
|
||||
end
|
||||
|
||||
|
@ -149,7 +152,7 @@ function __done_is_process_window_focused
|
|||
string match --quiet --regex "^true" (swaymsg -t get_tree | jq ".. | objects | select(.id == "$__done_initial_window_id") | .visible")
|
||||
return $status
|
||||
else if test -n "$HYPRLAND_INSTANCE_SIGNATURE"
|
||||
and test $__done_initial_window_id -eq (hyprctl activewindow | awk 'NR==13 {print $2}')
|
||||
and test $__done_initial_window_id = (hyprctl activewindow | awk 'NR==1 {print $2}')
|
||||
return $status
|
||||
else if test "$__done_initial_window_id" != "$__done_focused_window_id"
|
||||
return 1
|
||||
|
@ -265,7 +268,6 @@ if set -q __done_enabled
|
|||
set -l message (string replace --all '"' '\"' "$message")
|
||||
set -l title (string replace --all '"' '\"' "$title")
|
||||
|
||||
osascript -e "display notification \"$message\" with title \"$title\""
|
||||
if test "$__done_notify_sound" -eq 1
|
||||
osascript -e "display notification \"$message\" with title \"$title\" sound name \"Glass\""
|
||||
else
|
||||
|
|
|
@ -1,232 +0,0 @@
|
|||
# MIT (c) Chris Apple
|
||||
|
||||
set INSTALL_DIR (dirname (dirname (status -f)))
|
||||
set -x FORGIT_INSTALL_DIR "$INSTALL_DIR/conf.d"
|
||||
set -x FORGIT "$FORGIT_INSTALL_DIR/bin/git-forgit"
|
||||
if [ ! -e "$FORGIT" ]
|
||||
set -x FORGIT_INSTALL_DIR "$INSTALL_DIR/vendor_conf.d"
|
||||
set -x FORGIT "$FORGIT_INSTALL_DIR/bin/git-forgit"
|
||||
end
|
||||
|
||||
function forgit::warn
|
||||
printf "%b[Warn]%b %s\n" '\e[0;33m' '\e[0m' "$argv" >&2
|
||||
end
|
||||
|
||||
# backwards compatibility:
|
||||
# export all user-defined FORGIT variables to make them available in git-forgit
|
||||
set unexported_vars 0
|
||||
set | awk -F ' ' '{ print $1 }' | grep FORGIT_ | while read var
|
||||
if not set -x | grep -q "^$var\b"
|
||||
if test $unexported_vars = 0
|
||||
forgit::warn "Config options have to be exported in future versions of forgit."
|
||||
forgit::warn "Please update your config accordingly:"
|
||||
end
|
||||
forgit::warn " set -x $var \"$$var\""
|
||||
set unexported_vars (math $unexported_vars + 1)
|
||||
set -x $var $$var
|
||||
end
|
||||
end
|
||||
|
||||
function forgit::log -d "git commit viewer"
|
||||
"$FORGIT" log $argv
|
||||
end
|
||||
|
||||
function forgit::diff -d "git diff viewer" --argument-names arg1 arg2
|
||||
"$FORGIT" diff $argv
|
||||
end
|
||||
|
||||
function forgit::add -d "git add selector" --wraps "git add"
|
||||
"$FORGIT" add $argv
|
||||
end
|
||||
|
||||
function forgit::reset::head -d "git reset HEAD (unstage) selector"
|
||||
"$FORGIT" reset_head $argv
|
||||
end
|
||||
|
||||
function forgit::stash::show -d "git stash viewer"
|
||||
"$FORGIT" stash_show $argv
|
||||
end
|
||||
|
||||
function forgit::stash::push -d "git stash push selector" ()
|
||||
"$FORGIT" stash_push $argv
|
||||
end
|
||||
|
||||
function forgit::clean -d "git clean selector"
|
||||
"$FORGIT" clean $argv
|
||||
end
|
||||
|
||||
function forgit::cherry::pick -d "git cherry-picking" --argument-names 'target' --wraps "git cherry-pick"
|
||||
"$FORGIT" cherry_pick $argv
|
||||
end
|
||||
|
||||
function forgit::cherry::pick::from::branch -d "git cherry-picking with interactive branch selection" --wraps "git cherry-pick"
|
||||
"$FORGIT" cherry_pick_from_branch $argv
|
||||
end
|
||||
|
||||
function forgit::rebase -d "git rebase"
|
||||
"$FORGIT" rebase $argv
|
||||
end
|
||||
|
||||
function forgit::fixup -d "git fixup"
|
||||
"$FORGIT" fixup $argv
|
||||
end
|
||||
|
||||
function forgit::checkout::file -d "git checkout-file selector" --argument-names 'file_name' --wraps "git checkout --"
|
||||
"$FORGIT" checkout_file $argv
|
||||
end
|
||||
|
||||
function forgit::checkout::branch -d "git checkout branch selector" --argument-names 'input_branch_name' --wraps "git branch"
|
||||
"$FORGIT" checkout_branch $argv
|
||||
end
|
||||
|
||||
function forgit::checkout::tag -d "git checkout tag selector" --argument-names 'tag_name' --wraps "git checkout"
|
||||
"$FORGIT" checkout_tag $argv
|
||||
end
|
||||
|
||||
function forgit::checkout::commit -d "git checkout commit selector" --argument-names 'commit_id' --wraps "git checkout"
|
||||
"$FORGIT" checkout_commit $argv
|
||||
end
|
||||
|
||||
function forgit::branch::delete -d "git branch deletion selector" --wraps "git branch --delete"
|
||||
"$FORGIT" branch_delete $argv
|
||||
end
|
||||
|
||||
function forgit::revert::commit -d "git revert commit selector" --argument-names 'commit_hash' --wraps "git revert --"
|
||||
"$FORGIT" revert_commit $argv
|
||||
end
|
||||
|
||||
function forgit::blame -d "git blame viewer"
|
||||
"$FORGIT" blame $argv
|
||||
end
|
||||
|
||||
function forgit::ignore -d "git ignore generator"
|
||||
"$FORGIT" ignore $argv
|
||||
end
|
||||
|
||||
function forgit::ignore::update
|
||||
"$FORGIT" ignore_update $argv
|
||||
end
|
||||
|
||||
function forgit::ignore::get
|
||||
"$FORGIT" ignore_get $argv
|
||||
end
|
||||
|
||||
function forgit::ignore::list
|
||||
"$FORGIT" ignore_list $argv
|
||||
end
|
||||
|
||||
function forgit::ignore::clean
|
||||
"$FORGIT" ignore_clean $argv
|
||||
end
|
||||
|
||||
# register aliases
|
||||
if test -z "$FORGIT_NO_ALIASES"
|
||||
if test -n "$forgit_add"
|
||||
alias $forgit_add 'forgit::add'
|
||||
else
|
||||
alias ga 'forgit::add'
|
||||
end
|
||||
|
||||
if test -n "$forgit_reset_head"
|
||||
alias $forgit_reset_head 'forgit::reset::head'
|
||||
else
|
||||
alias grh 'forgit::reset::head'
|
||||
end
|
||||
|
||||
if test -n "$forgit_log"
|
||||
alias $forgit_log 'forgit::log'
|
||||
else
|
||||
alias glo 'forgit::log'
|
||||
end
|
||||
|
||||
if test -n "$forgit_diff"
|
||||
alias $forgit_diff 'forgit::diff'
|
||||
else
|
||||
alias gd 'forgit::diff'
|
||||
end
|
||||
|
||||
if test -n "$forgit_ignore"
|
||||
alias $forgit_ignore 'forgit::ignore'
|
||||
else
|
||||
alias gi 'forgit::ignore'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_file"
|
||||
alias $forgit_checkout_file 'forgit::checkout::file'
|
||||
else
|
||||
alias gcf 'forgit::checkout::file'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_branch"
|
||||
alias $forgit_checkout_branch 'forgit::checkout::branch'
|
||||
else
|
||||
alias gcb 'forgit::checkout::branch'
|
||||
end
|
||||
|
||||
if test -n "$forgit_branch_delete"
|
||||
alias $forgit_branch_delete 'forgit::branch::delete'
|
||||
else
|
||||
alias gbd 'forgit::branch::delete'
|
||||
end
|
||||
|
||||
if test -n "$forgit_clean"
|
||||
alias $forgit_clean 'forgit::clean'
|
||||
else
|
||||
alias gclean 'forgit::clean'
|
||||
end
|
||||
|
||||
if test -n "$forgit_stash_show"
|
||||
alias $forgit_stash_show 'forgit::stash::show'
|
||||
else
|
||||
alias gss 'forgit::stash::show'
|
||||
end
|
||||
|
||||
if test -n "$forgit_stash_push"
|
||||
alias $forgit_stash_push 'forgit::stash::push'
|
||||
else
|
||||
alias gsp 'forgit::stash::push'
|
||||
end
|
||||
|
||||
if test -n "$forgit_cherry_pick"
|
||||
alias $forgit_cherry_pick 'forgit::cherry::pick::from::branch'
|
||||
else
|
||||
alias gcp 'forgit::cherry::pick::from::branch'
|
||||
end
|
||||
|
||||
if test -n "$forgit_rebase"
|
||||
alias $forgit_rebase 'forgit::rebase'
|
||||
else
|
||||
alias grb 'forgit::rebase'
|
||||
end
|
||||
|
||||
if test -n "$forgit_fixup"
|
||||
alias $forgit_fixup 'forgit::fixup'
|
||||
else
|
||||
alias gfu 'forgit::fixup'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_commit"
|
||||
alias $forgit_checkout_commit 'forgit::checkout::commit'
|
||||
else
|
||||
alias gco 'forgit::checkout::commit'
|
||||
end
|
||||
|
||||
if test -n "$forgit_revert_commit"
|
||||
alias $forgit_revert_commit 'forgit::revert::commit'
|
||||
else
|
||||
alias grc 'forgit::revert::commit'
|
||||
end
|
||||
|
||||
if test -n "$forgit_blame"
|
||||
alias $forgit_blame 'forgit::blame'
|
||||
else
|
||||
alias gbl 'forgit::blame'
|
||||
end
|
||||
|
||||
if test -n "$forgit_checkout_tag"
|
||||
alias $forgit_checkout_tag 'forgit::checkout::tag'
|
||||
else
|
||||
alias gct 'forgit::checkout::tag'
|
||||
end
|
||||
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
if test -z "$TO_DIR"
|
||||
set -U TO_DIR ~/.tofish
|
||||
end
|
|
@ -1,9 +1,5 @@
|
|||
franciscolourenco/done
|
||||
acomagu/fish-async-prompt
|
||||
joehillen/to-fish
|
||||
patrickf1/fzf.fish
|
||||
wfxr/forgit
|
||||
danhper/fish-ssh-agent
|
||||
gazorby/fish-abbreviation-tips
|
||||
paldepind/projectdo
|
||||
catppuccin/fish
|
||||
|
|
|
@ -11,20 +11,16 @@ SETUVAR --export XDG_CACHE_HOME:/home/matt/\x2ecache
|
|||
SETUVAR --export XDG_CONFIG_HOME:/home/matt/\x2econfig
|
||||
SETUVAR --export XDG_DATA_HOME:/home/matt/\x2elocal/share
|
||||
SETUVAR --export XDG_SCRIPT_HOME:/home/matt/\x2elocal/script
|
||||
SETUVAR --export __ABBR_TIPS_KEYS:a__bruh\x1ea__cd\x1ea__clock\x1ea__codeinfo\x1ea__disks\x1ea__dots\x1ea__dsize\x1ea__ea\x1ea__ef\x1ea__eg\x1ea__ev\x1ea__f\x1ea__fetch\x1ea__files\x1ea__fsend\x1ea__ga\x1ea__gbd\x1ea__gbl\x1ea__gcb\x1ea__gcf\x1ea__gclean\x1ea__gco\x1ea__gcp\x1ea__gct\x1ea__gd\x1ea__gfetch\x1ea__gfu\x1ea__gi\x1ea__glo\x1ea__gpt\x1ea__grb\x1ea__grc\x1ea__grh\x1ea__gsp\x1ea__gss\x1ea__h\x1ea__info\x1ea__install\x1ea__ip\x1ea__l\x1ea__ld\x1ea__ldh\x1ea__lh\x1ea__ls\x1ea__lsh\x1ea__lt\x1ea__lth\x1ea__matrix\x1ea__q\x1ea__svn\x1ea__uninstall\x1ea__update\x1ea__yarn\x1ea__yc\x1ea__ym\x1ea__yp\x1ea__yst\x1ea__ysw\x1ea__z\x1ea__zi\x1ea__\x1ea__pse\x1ea__fe\x1ea__ni\x1ea__nis\x1ea__nid\x1ea__nu\x1ea__nup\x1ea__nls\x1ea__c\x1ea__cl\x1ea__s\x1ea__vc\x1ea__ex\x1ea__r\x1ea__r\x1ea__r\x1ea__ctp
|
||||
SETUVAR --export __ABBR_TIPS_VALUES:genact\x20\x2ds\x204\x1ez\x1etty\x2dclock\x20\x2dsbc\x1escc\x20\x2e/\x1eduf\x1eyadm\x20enter\x20lazygit\x1edua\x20i\x1envim\x20\x7e/\x2econfig/fish/aliases\x2efish\x1envim\x20\x7e/\x2econfig/fish/config\x2efish\x1envim\x20\x7e/\x2egitconfig\x1envim\x20\x7e/\x2econfig/fish/variables\x2efish\x1efzf\x1eneofetch\x1explr\x1efloaterm\x1eforgit\x3a\x3aadd\x1eforgit\x3a\x3abranch\x3a\x3adelete\x1eforgit\x3a\x3ablame\x1eforgit\x3a\x3acheckout\x3a\x3abranch\x1eforgit\x3a\x3acheckout\x3a\x3afile\x1eforgit\x3a\x3aclean\x1eforgit\x3a\x3acheckout\x3a\x3acommit\x1eforgit\x3a\x3acherry\x3a\x3apick\x3a\x3afrom\x3a\x3abranch\x1eforgit\x3a\x3acheckout\x3a\x3atag\x1eforgit\x3a\x3adiff\x1eonefetch\x1eforgit\x3a\x3afixup\x1eforgit\x3a\x3aignore\x1eforgit\x3a\x3alog\x1etgpt\x20\x2di\x1eforgit\x3a\x3arebase\x1eforgit\x3a\x3arevert\x3a\x3acommit\x1eforgit\x3a\x3areset\x3a\x3ahead\x1eforgit\x3a\x3astash\x3a\x3apush\x1eforgit\x3a\x3astash\x3a\x3ashow\x1ezi\x1etldr\x1eyay\x20\x2dS\x20\x1eip\x20\x2dc\x20a\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2da\x20\x2d\x2dicons\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2da\x20\x2d\x2dicons\x20\x2dD\x20\x2d\x2dgit\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2d\x2dicons\x20\x2dD\x20\x2d\x2dgit\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2d\x2dicons\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2da\x20\x2d\x2dicons\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dicons\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2da\x20\x2d\x2dicons\x20\x2d\x2dtree\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2d\x2dicons\x20\x2d\x2dtree\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eunimatrix\x20\x2ds\x2095\x1eexit\x1esvn\x5c\x5c\x5c\x20\x2d\x2dconfig\x2ddir\x5c\x5c\x5c\x20\x5c\x5c\x5c\x5c\x5c\x5c\x5c\x22\x5c\x5c\x5c\x24XDG_CONFIG_HOME\x5c\x5c\x5c\x5c\x5c\x5c\x5c\x22/subversion\x1eyay\x20\x2dR\x20\x1eyay\x20\x2dSyu\x1eyarn\x20\x2d\x2duse\x2dyarnrc\x20\x22\x24XDG_CONFIG_HOME/yarn/config\x22\x1eyadm\x20commit\x20\x2dS\x20\x2da\x20\x2dm\x1eyadm\x20merge\x1eyadm\x20pull\x1eyadm\x20status\x1eyadm\x20switch\x1e__zoxide_z\x1e__zoxide_zi\x1e\x1epacseek\x1eyazi\x1enpm\x1enpm\x1enpm\x1enpm\x1enpm\x1enpm\x1ez\x1ez\x1esudo\x1envim\x1esudo\x1emise\x1esource\x1emise\x1ebat
|
||||
SETUVAR --export __ABBR_TIPS_KEYS:y\x1eg\x1et\x1ega\x1egrh\x1eglo\x1egd\x1egi\x1egcf\x1egcb\x1egbd\x1egclean\x1egss\x1egsp\x1egcp\x1egrb\x1egfu\x1egco\x1egrc\x1egbl\x1egct\x1ea__bruh\x1ea__c\x1ea__cl\x1ea__clock\x1ea__codeinfo\x1ea__ct\x1ea__ctp\x1ea__cv\x1ea__disks\x1ea__dots\x1ea__dsize\x1ea__ea\x1ea__ef\x1ea__eg\x1ea__ev\x1ea__ex\x1ea__f\x1ea__fetch\x1ea__ga\x1ea__gbd\x1ea__gbl\x1ea__gcb\x1ea__gcf\x1ea__gclean\x1ea__gco\x1ea__gcp\x1ea__gct\x1ea__gd\x1ea__gfetch\x1ea__gfu\x1ea__gi\x1ea__git\x2dforgit\x1ea__glo\x1ea__gpt\x1ea__grb\x1ea__grc\x1ea__grh\x1ea__gsp\x1ea__gss\x1ea__i\x1ea__info\x1ea__ip\x1ea__l\x1ea__ld\x1ea__ldh\x1ea__lg\x1ea__lh\x1ea__ls\x1ea__lsh\x1ea__lt\x1ea__lth\x1ea__matrix\x1ea__ni\x1ea__nid\x1ea__nis\x1ea__nls\x1ea__nlsg\x1ea__no\x1ea__nu\x1ea__nud\x1ea__nup\x1ea__nus\x1ea__pages\x1ea__proc\x1ea__pse\x1ea__q\x1ea__r\x1ea__s\x1ea__sc\x1ea__svn\x1ea__u\x1ea__up\x1ea__upall\x1ea__v\x1ea__vcl\x1ea__vv\x1ea__vvl\x1ea__vvn\x1ea__yarn\x1ea__z\x1ea__zi\x1ea__gf
|
||||
SETUVAR --export __ABBR_TIPS_VALUES:yadm\x1egit\x1egtrash\x1egit\x2dforgit\x20add\x1egit\x2dforgit\x20reset_head\x1egit\x2dforgit\x20log\x1egit\x2dforgit\x20diff\x1egit\x2dforgit\x20ignore\x1egit\x2dforgit\x20checkout_file\x1egit\x2dforgit\x20checkout_branch\x1egit\x2dforgit\x20branch_delete\x1egit\x2dforgit\x20clean\x1egit\x2dforgit\x20stash_show\x1egit\x2dforgit\x20stash_push\x1egit\x2dforgit\x20cherry_pick_from_branch\x1egit\x2dforgit\x20rebase\x1egit\x2dforgit\x20fixup\x1egit\x2dforgit\x20checkout_commit\x1egit\x2dforgit\x20revert_commit\x1egit\x2dforgit\x20blame\x1egit\x2dforgit\x20checkout_tag\x1egenact\x20\x2ds\x204\x1ez\x1eclear\x1etty\x2dclock\x20\x2dsbc\x1escc\x20\x2e/\x1ebat\x1ebat\x20\x2d\x2dpaging\x3dalways\x1ez\x20\x26\x26\x20v\x1eduf\x1eyadm\x20enter\x20lazygit\x1edua\x20i\x1envim\x20\x7e/\x2econfig/fish/aliases\x2efish\x1envim\x20\x7e/\x2econfig/fish/config\x2efish\x1envim\x20\x7e/\x2egitconfig\x1envim\x20\x7e/\x2econfig/fish/variables\x2efish\x1esudo\x20chmod\x20\x2bx\x1efzf\x1efastfetch\x1eforgit\x3a\x3aadd\x1eforgit\x3a\x3abranch\x3a\x3adelete\x1eforgit\x3a\x3ablame\x1eforgit\x3a\x3acheckout\x3a\x3abranch\x1eforgit\x3a\x3acheckout\x3a\x3afile\x1eforgit\x3a\x3aclean\x1eforgit\x3a\x3acheckout\x3a\x3acommit\x1eforgit\x3a\x3acherry\x3a\x3apick\x3a\x3afrom\x3a\x3abranch\x1eforgit\x3a\x3acheckout\x3a\x3atag\x1eforgit\x3a\x3adiff\x1eonefetch\x1eforgit\x3a\x3afixup\x1eforgit\x3a\x3aignore\x1e/home/matt/\x2econfig/fish/conf\x2ed/bin/git\x2dforgit\x1eforgit\x3a\x3alog\x1etgpt\x20\x2di\x1eforgit\x3a\x3arebase\x1eforgit\x3a\x3arevert\x3a\x3acommit\x1eforgit\x3a\x3areset\x3a\x3ahead\x1eforgit\x3a\x3astash\x3a\x3apush\x1eforgit\x3a\x3astash\x3a\x3ashow\x1eyay\x20\x2dS\x20\x1etldr\x1eip\x20\x2dc\x20a\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2da\x20\x2d\x2dicons\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2da\x20\x2d\x2dicons\x20\x2dD\x20\x2d\x2dgit\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2d\x2dicons\x20\x2dD\x20\x2d\x2dgit\x1elazygit\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2d\x2dicons\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2da\x20\x2d\x2dicons\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dicons\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2da\x20\x2d\x2dicons\x20\x2d\x2dtree\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eeza\x20\x2d\x2dlong\x20\x2d\x2dheader\x20\x2d\x2dicons\x20\x2d\x2dtree\x20\x2d\x2dgit\x20\x2d\x2dgroup\x2ddirectories\x2dfirst\x1eunimatrix\x20\x2ds\x2095\x1enpm\x20install\x1enpm\x20install\x20\x2d\x2dsave\x2ddev\x1enpm\x20install\x20\x2d\x2dsave\x1enpm\x20list\x1enpm\x20list\x20\x2d\x2dglobal\x1efloaterm\x1enpm\x20uninstall\x1enpm\x20uninstall\x20\x2d\x2dsave\x2ddev\x1enpm\x20update\x1enpm\x20uninstall\x20\x2d\x2dsave\x1enavi\x1esysz\x1epacseek\x1eexit\x1emise\x20run\x1esudo\x1er\x3dsource\x20\x24XDG_CONFIG_HOME/fish/config\x2efish\x1esvn\x5c\x5c\x5c\x20\x2d\x2dconfig\x2ddir\x5c\x5c\x5c\x20\x5c\x5c\x5c\x5c\x5c\x5c\x5c\x22\x5c\x5c\x5c\x24XDG_CONFIG_HOME\x5c\x5c\x5c\x5c\x5c\x5c\x5c\x22/subversion\x1eyay\x20\x2dR\x20\x1eyay\x20\x2dSyu\x1etopgrade\x1envim\x1envim\x20\x2d\x2dclean\x1ebob\x1ebob\x20use\x20latest\x1ebob\x20use\x20nightly\x1eyarn\x20\x2d\x2duse\x2dyarnrc\x20\x22\x24XDG_CONFIG_HOME/yarn/config\x22\x1e__zoxide_z\x1e__zoxide_zi\x1egit\x2dforgit
|
||||
SETUVAR __fish_initialized:3400
|
||||
SETUVAR _fisher_acomagu_2F_fish_2D_async_2D_prompt_files:\x7e/\x2econfig/fish/conf\x2ed/__async_prompt\x2efish
|
||||
SETUVAR _fisher_catppuccin_2F_fish_files:\x7e/\x2econfig/fish/themes/Catppuccin\x20Frappe\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Latte\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Macchiato\x2etheme\x1e\x7e/\x2econfig/fish/themes/Catppuccin\x20Mocha\x2etheme
|
||||
SETUVAR _fisher_danhper_2F_fish_2D_ssh_2D_agent_files:\x7e/\x2econfig/fish/functions/__ssh_agent_is_started\x2efish\x1e\x7e/\x2econfig/fish/functions/__ssh_agent_start\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fish\x2dssh\x2dagent\x2efish
|
||||
SETUVAR _fisher_franciscolourenco_2F_done_files:\x7e/\x2econfig/fish/conf\x2ed/done\x2efish
|
||||
SETUVAR _fisher_gazorby_2F_fish_2D_abbreviation_2D_tips_files:\x7e/\x2econfig/fish/functions/__abbr_tips_bind_newline\x2efish\x1e\x7e/\x2econfig/fish/functions/__abbr_tips_bind_space\x2efish\x1e\x7e/\x2econfig/fish/functions/__abbr_tips_clean\x2efish\x1e\x7e/\x2econfig/fish/functions/__abbr_tips_init\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/abbr_tips\x2efish
|
||||
SETUVAR _fisher_joehillen_2F_to_2D_fish_files:\x7e/\x2econfig/fish/functions/to\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/to\x2efish\x1e\x7e/\x2econfig/fish/completions/to\x2efish
|
||||
SETUVAR _fisher_paldepind_2F_projectdo_files:\x7e/\x2econfig/fish/functions/projectdo_build\x2efish\x1e\x7e/\x2econfig/fish/functions/projectdo_run\x2efish\x1e\x7e/\x2econfig/fish/functions/projectdo_test\x2efish\x1e\x7e/\x2econfig/fish/functions/projectdo_tool\x2efish\x1e\x7e/\x2econfig/fish/completions/projectdo\x2efish
|
||||
SETUVAR _fisher_patrickf1_2F_fzf_2E_fish_files:\x7e/\x2econfig/fish/functions/_fzf_configure_bindings_help\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_extract_var_info\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_changed_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_preview_file\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_diff_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_report_file_type\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_directory\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_log\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_git_status\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_history\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_processes\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_search_variables\x2efish\x1e\x7e/\x2econfig/fish/functions/_fzf_wrapper\x2efish\x1e\x7e/\x2econfig/fish/functions/fzf_configure_bindings\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/fzf\x2efish\x1e\x7e/\x2econfig/fish/completions/fzf_configure_bindings\x2efish
|
||||
SETUVAR _fisher_plugins:franciscolourenco/done\x1eacomagu/fish\x2dasync\x2dprompt\x1ejoehillen/to\x2dfish\x1epatrickf1/fzf\x2efish\x1ewfxr/forgit\x1edanhper/fish\x2dssh\x2dagent\x1egazorby/fish\x2dabbreviation\x2dtips\x1epaldepind/projectdo\x1ecatppuccin/fish
|
||||
SETUVAR _fisher_plugins:franciscolourenco/done\x1epatrickf1/fzf\x2efish\x1edanhper/fish\x2dssh\x2dagent\x1egazorby/fish\x2dabbreviation\x2dtips\x1ecatppuccin/fish
|
||||
SETUVAR _fisher_upgraded_to_4_4:\x1d
|
||||
SETUVAR _fisher_wfxr_2F_forgit_files:\x7e/\x2econfig/fish/conf\x2ed/bin\x1e\x7e/\x2econfig/fish/conf\x2ed/forgit\x2eplugin\x2efish\x1e\x7e/\x2econfig/fish/completions/_git\x2dforgit\x1e\x7e/\x2econfig/fish/completions/git\x2dforgit\x2ebash\x1e\x7e/\x2econfig/fish/completions/git\x2dforgit\x2ezsh
|
||||
SETUVAR fish_color_autosuggestion:6e738d
|
||||
SETUVAR fish_color_cancel:ed8796
|
||||
SETUVAR fish_color_command:8aadf4
|
||||
|
|
|
@ -1,24 +1,14 @@
|
|||
function __ssh_agent_is_started -d "check if ssh agent is already started"
|
||||
if begin
|
||||
test -n "$SSH_AUTH_SOCK"; and test -e "$SSH_AUTH_SOCK"
|
||||
end
|
||||
return 0
|
||||
end
|
||||
if begin; test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"; end
|
||||
source $SSH_ENV > /dev/null
|
||||
end
|
||||
|
||||
if begin
|
||||
test -f $SSH_ENV; and test -z "$SSH_AGENT_PID"
|
||||
end
|
||||
source $SSH_ENV >/dev/null
|
||||
end
|
||||
if begin; test -z "$SSH_AGENT_PID"; and test -z "$SSH_CONNECTION"; end
|
||||
return 1
|
||||
end
|
||||
|
||||
if begin
|
||||
test -z "$SSH_AGENT_PID"; and test -z "$SSH_CONNECTION"
|
||||
end
|
||||
return 1
|
||||
end
|
||||
|
||||
ssh-add -l >/dev/null 2>&1
|
||||
if test $status -eq 2
|
||||
return 1
|
||||
end
|
||||
ssh-add -l > /dev/null 2>&1
|
||||
if test $status -eq 2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ DESCRIPTION
|
|||
|
||||
Pass -h or --help to print this help message and exit.
|
||||
|
||||
ezaMPLES
|
||||
EXAMPLES
|
||||
Default bindings but bind Search Directory to Ctrl+F and Search Variables to Ctrl+Alt+V
|
||||
\$ fzf_configure_bindings --directory=\cf --variables=\e\cv
|
||||
Default bindings but disable Search History
|
||||
|
|
|
@ -6,7 +6,7 @@ function _fzf_search_directory --description "Search the current directory. Repl
|
|||
set -f --append fd_cmd --color=always $fzf_fd_opts
|
||||
|
||||
# $fzf_dir_opts is the deprecated version of $fzf_directory_opts
|
||||
set -f fzf_arguments --multi --ansi $fzf_dir_opts $fzf_directory_opts
|
||||
set -f fzf_arguments --multi --ansi $fzf_directory_opts
|
||||
set -f token (commandline --current-token)
|
||||
# expand any variables or leading tilde (~) in the token
|
||||
set -f expanded_token (eval echo -- $token)
|
||||
|
|
|
@ -6,13 +6,19 @@ function _fzf_search_git_log --description "Search the output of git log and pre
|
|||
# %h gives you the abbreviated commit hash, which is useful for saving screen space, but we will have to expand it later below
|
||||
set -f fzf_git_log_format '%C(bold blue)%h%C(reset) - %C(cyan)%ad%C(reset) %C(yellow)%d%C(reset) %C(normal)%s%C(reset) %C(dim normal)[%an]%C(reset)'
|
||||
end
|
||||
|
||||
set -f preview_cmd 'git show --color=always --stat --patch {1}'
|
||||
if set --query fzf_diff_highlighter
|
||||
set preview_cmd "$preview_cmd | $fzf_diff_highlighter"
|
||||
end
|
||||
|
||||
set -f selected_log_lines (
|
||||
git log --no-show-signature --color=always --format=format:$fzf_git_log_format --date=short | \
|
||||
_fzf_wrapper --ansi \
|
||||
--multi \
|
||||
--scheme=history \
|
||||
--prompt="Search Git Log> " \
|
||||
--preview='git show --color=always --stat --patch {1}' \
|
||||
--prompt="Git Log> " \
|
||||
--preview=$preview_cmd \
|
||||
--query=(commandline --current-token) \
|
||||
$fzf_git_log_opts
|
||||
)
|
||||
|
|
|
@ -2,14 +2,19 @@ function _fzf_search_git_status --description "Search the output of git status.
|
|||
if not git rev-parse --git-dir >/dev/null 2>&1
|
||||
echo '_fzf_search_git_status: Not in a git repository.' >&2
|
||||
else
|
||||
set -f preview_cmd '_fzf_preview_changed_file {}'
|
||||
if set --query fzf_diff_highlighter
|
||||
set preview_cmd "$preview_cmd | $fzf_diff_highlighter"
|
||||
end
|
||||
|
||||
set -f selected_paths (
|
||||
# Pass configuration color.status=always to force status to use colors even though output is sent to a pipe
|
||||
git -c color.status=always status --short |
|
||||
_fzf_wrapper --ansi \
|
||||
--multi \
|
||||
--prompt="Search Git Status> " \
|
||||
--prompt="Git Status> " \
|
||||
--query=(commandline --current-token) \
|
||||
--preview='_fzf_preview_changed_file {}' \
|
||||
--preview=$preview_cmd \
|
||||
--nth="2.." \
|
||||
$fzf_git_status_opts
|
||||
)
|
||||
|
|
|
@ -10,6 +10,10 @@ function _fzf_search_history --description "Search command history. Replace the
|
|||
set -f fzf_history_time_format "%m-%d %H:%M:%S"
|
||||
end
|
||||
|
||||
# Delinate time from command in history entries using the vertical box drawing char (U+2502).
|
||||
# Then, to get raw command from history entries, delete everything up to it. The ? on regex is
|
||||
# necessary to make regex non-greedy so it won't match into commands containing the char.
|
||||
set -f time_prefix_regex '^.*? │ '
|
||||
# Delinate commands throughout pipeline using null rather than newlines because commands can be multi-line
|
||||
set -f commands_selected (
|
||||
builtin history --null --show-time="$fzf_history_time_format │ " |
|
||||
|
@ -17,14 +21,14 @@ function _fzf_search_history --description "Search command history. Replace the
|
|||
--print0 \
|
||||
--multi \
|
||||
--scheme=history \
|
||||
--prompt="Search History> " \
|
||||
--prompt="History> " \
|
||||
--query=(commandline) \
|
||||
--preview="echo -- {} | string replace --regex '^.*? │ ' '' | fish_indent --ansi" \
|
||||
--preview="string replace --regex '$time_prefix_regex' '' -- {} | fish_indent --ansi" \
|
||||
--preview-window="bottom:3:wrap" \
|
||||
$fzf_history_opts |
|
||||
string split0 |
|
||||
# remove timestamps from commands selected
|
||||
string replace --regex '^.*? │ ' ''
|
||||
string replace --regex $time_prefix_regex ''
|
||||
)
|
||||
|
||||
if test $status -eq 0
|
||||
|
|
|
@ -8,7 +8,7 @@ function _fzf_search_processes --description "Search all running processes. Repl
|
|||
set -f processes_selected (
|
||||
$ps_cmd -A -opid,command | \
|
||||
_fzf_wrapper --multi \
|
||||
--prompt="Search Processes> " \
|
||||
--prompt="Processes> " \
|
||||
--query (commandline --current-token) \
|
||||
--ansi \
|
||||
# first line outputted by ps is a header, so we need to mark it as so
|
||||
|
|
|
@ -12,7 +12,7 @@ function _fzf_search_variables --argument-names set_show_output set_names_output
|
|||
# Exclude the history variable from being piped into fzf because
|
||||
# 1. it's not included in $set_names_output
|
||||
# 2. it tends to be a very large value => increases computation time
|
||||
# 3._fzf_search_history is a much better way to ezamine history anyway
|
||||
# 3._fzf_search_history is a much better way to examine history anyway
|
||||
set -f all_variable_names (string match --invert history <$set_names_output)
|
||||
|
||||
set -f current_token (commandline --current-token)
|
||||
|
@ -23,12 +23,11 @@ function _fzf_search_variables --argument-names set_show_output set_names_output
|
|||
set -f variable_names_selected (
|
||||
printf '%s\n' $all_variable_names |
|
||||
_fzf_wrapper --preview "_fzf_extract_var_info {} $set_show_output" \
|
||||
--prompt="Search Variables> " \
|
||||
--prompt="Variables> " \
|
||||
--preview-window="wrap" \
|
||||
--multi \
|
||||
--query=$cleaned_curr_token \
|
||||
# $fzf_shell_vars_opts is the deprecated version of $fzf_variables_opts
|
||||
$fzf_shell_vars_opts $fzf_variables_opts
|
||||
$fzf_variables_opts
|
||||
)
|
||||
|
||||
if test $status -eq 0
|
||||
|
|
|
@ -4,9 +4,10 @@ function _fzf_wrapper --description "Prepares some environment variables before
|
|||
# Use --function so that it doesn't clobber SHELL outside this function.
|
||||
set -f --export SHELL (command --search fish)
|
||||
|
||||
# If FZF_DEFAULT_OPTS is not set, then set some sane defaults.
|
||||
# If neither FZF_DEFAULT_OPTS nor FZF_DEFAULT_OPTS_FILE are set, then set some sane defaults.
|
||||
# See https://github.com/junegunn/fzf#environment-variables
|
||||
if not set --query FZF_DEFAULT_OPTS
|
||||
set --query FZF_DEFAULT_OPTS FZF_DEFAULT_OPTS_FILE
|
||||
if test $status -eq 2
|
||||
# cycle allows jumping between the first and last results, making scrolling faster
|
||||
# layout=reverse lists results top to bottom, mimicking the familiar layouts of git log, history, and env
|
||||
# border shows where the fzf window begins and ends
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
function fgit --description 'List forgit options with fzf'
|
||||
set selected_command (functions | rg -o 'forgit::[^ ]*' | cut -d ':' -f 2- | sd '^:' '' | fzf)
|
||||
if [ -n "$selected_command" ]
|
||||
eval "forgit::$selected_command"
|
||||
end
|
||||
commandline -f repaint
|
||||
end
|
|
@ -8,7 +8,6 @@ function fish_user_key_bindings
|
|||
|
||||
fzf_configure_bindings --directory=\e\cf --history=\ch --variables=\e\cv
|
||||
|
||||
bind \e\cg fgit
|
||||
bind \e\cw rga-fzf
|
||||
bind \e\z cdzi
|
||||
bind \e\cn navi
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# name: 'Catppuccin frappe'
|
||||
# name: 'Catppuccin Frappé'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 303446
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# name: 'Catppuccin latte'
|
||||
# name: 'Catppuccin Latte'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: eff1f5
|
||||
|
||||
|
@ -21,8 +21,8 @@ fish_color_autosuggestion 9ca0b0
|
|||
fish_color_cancel d20f39
|
||||
fish_color_cwd df8e1d
|
||||
fish_color_user 179299
|
||||
fish_color_host_remote 40a02b
|
||||
fish_color_host 1e66f5
|
||||
fish_color_host_remote 40a02b
|
||||
fish_color_status d20f39
|
||||
fish_pager_color_progress 9ca0b0
|
||||
fish_pager_color_prefix ea76cb
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# name: 'Catppuccin macchiato'
|
||||
# name: 'Catppuccin Macchiato'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 24273a
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# name: 'Catppuccin mocha'
|
||||
# name: 'Catppuccin Mocha'
|
||||
# url: 'https://github.com/catppuccin/fish'
|
||||
# preferred_background: 1e1e2e
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue