fish
This commit is contained in:
parent
9642597265
commit
356b45ecd6
8 changed files with 1571 additions and 3 deletions
131
.config/fish/completions/_git-forgit
Normal file
131
.config/fish/completions/_git-forgit
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
#compdef git-forgit -p 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.
|
||||||
|
|
||||||
|
_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-reflog() {
|
||||||
|
declare -a cmds
|
||||||
|
cmds=('expire:prune old reflog entries' 'delete:delete entries from reflog' 'show:show log of ref' 'exists:check whether a ref has a reflog')
|
||||||
|
_alternative 'cmds:: _describe -t cmds cmd cmds' 'refs:: __git_references'
|
||||||
|
}
|
||||||
|
|
||||||
|
_git-forgit() {
|
||||||
|
local subcommand 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)
|
||||||
|
else
|
||||||
|
# The last word is the relevant command
|
||||||
|
cmd=${words[(( ${#words} - 1 ))]}
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${cmd} in
|
||||||
|
forgit)
|
||||||
|
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'
|
||||||
|
'reflog:git reflog 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
|
||||||
|
;;
|
||||||
|
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 ;;
|
||||||
|
reflog) _git-forgit-reflog ;;
|
||||||
|
rebase) _git-rebase ;;
|
||||||
|
reset_head) _git-staged ;;
|
||||||
|
revert_commit) __git_recent_commits ;;
|
||||||
|
stash_show) _git-stash-show ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
# 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-reflog forgit::reflog
|
||||||
|
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
|
||||||
|
|
||||||
|
# this is the case of calling the command and pressing tab
|
||||||
|
# the very first time of a shell session, we have to manually
|
||||||
|
# call the dispatch function
|
||||||
|
if [[ $funcstack[1] == "_git-forgit" ]]; then
|
||||||
|
_git-forgit "$@"
|
||||||
|
fi
|
159
.config/fish/completions/git-forgit.bash
Executable file
159
.config/fish/completions/git-forgit.bash
Executable file
|
@ -0,0 +1,159 @@
|
||||||
|
# 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
|
||||||
|
reflog
|
||||||
|
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 ;;
|
||||||
|
reflog) _git_reflog ;;
|
||||||
|
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::reflog _git_reflog
|
||||||
|
__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_reflog}" _git_reflog
|
||||||
|
__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
|
61
.config/fish/completions/git-forgit.fish
Normal file
61
.config/fish/completions/git-forgit.fish
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#
|
||||||
|
# forgit completions for fish plugin
|
||||||
|
#
|
||||||
|
# Place this file inside your <fish_config_dir>/completions/ directory.
|
||||||
|
# It's usually located at ~/.config/fish/completions/. The file is lazily
|
||||||
|
# sourced when git-forgit command or forgit subcommand of git is invoked.
|
||||||
|
|
||||||
|
function __fish_forgit_needs_subcommand
|
||||||
|
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 \
|
||||||
|
revert_commit stash_show stash_push
|
||||||
|
if contains -- $subcmd (commandline -opc)
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load helper functions in git completion file
|
||||||
|
not functions -q __fish_git && source $__fish_data_dir/completions/git.fish
|
||||||
|
|
||||||
|
# No file completion by default
|
||||||
|
complete -c git-forgit -x
|
||||||
|
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a add -d 'git add selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a blame -d 'git blame viewer'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a branch_delete -d 'git branch deletion selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a checkout_branch -d 'git checkout branch selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a checkout_commit -d 'git checkout commit selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a checkout_file -d 'git checkout-file selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a checkout_tag -d 'git checkout tag selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a cherry_pick -d 'git cherry-picking'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a cherry_pick_from_branch -d 'git cherry-picking with interactive branch selection'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a clean -d 'git clean selector'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a diff -d 'git diff viewer'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a fixup -d 'git fixup'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a ignore -d 'git ignore generator'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a log -d 'git commit viewer'
|
||||||
|
complete -c git-forgit -n __fish_forgit_needs_subcommand -a reflog -d 'git reflog viewer'
|
||||||
|
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 revert_commit -d 'git revert commit selector'
|
||||||
|
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_seen_subcommand_from add' -a "(complete -C 'git add ')"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from branch_delete' -a "(__fish_git_local_branches)"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from checkout_branch' -a "(complete -C 'git switch ')"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from checkout_commit' -a "(__fish_git_commits)"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from checkout_file' -a "(__fish_git_files modified)"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from checkout_tag' -a "(__fish_git_tags)" -d Tag
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from cherry_pick' -a "(complete -C 'git cherry-pick ')"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from clean' -a "(__fish_git_files untracked ignored)"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from fixup' -a "(__fish_git_local_branches)"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from log' -a "(complete -C 'git log ')"
|
||||||
|
complete -c git-forgit -n '__fish_seen_subcommand_from reflog' -a "(complete -C 'git reflog ')"
|
||||||
|
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 revert_commit' -a "(__fish_git_commits)"
|
||||||
|
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)"
|
1070
.config/fish/conf.d/bin/git-forgit
Executable file
1070
.config/fish/conf.d/bin/git-forgit
Executable file
File diff suppressed because it is too large
Load diff
54
.config/fish/conf.d/forgit.plugin.fish
Normal file
54
.config/fish/conf.d/forgit.plugin.fish
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# MIT (c) Chris Apple
|
||||||
|
|
||||||
|
set -l install_dir (dirname (status dirname))
|
||||||
|
set -x FORGIT_INSTALL_DIR "$install_dir/conf.d"
|
||||||
|
set -x FORGIT "$FORGIT_INSTALL_DIR/bin/git-forgit"
|
||||||
|
if not test -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
|
||||||
|
|
||||||
|
# alias `git-forgit` to the full-path of the command
|
||||||
|
alias git-forgit "$FORGIT"
|
||||||
|
|
||||||
|
# register abbreviations
|
||||||
|
if test -z "$FORGIT_NO_ALIASES"
|
||||||
|
abbr -a -- (string collect $forgit_add; or string collect "ga") git-forgit add
|
||||||
|
abbr -a -- (string collect $forgit_reset_head; or string collect "grh") git-forgit reset_head
|
||||||
|
abbr -a -- (string collect $forgit_log; or string collect "glo") git-forgit log
|
||||||
|
abbr -a -- (string collect $forgit_reflog; or string collect "grl") git-forgit reflog
|
||||||
|
abbr -a -- (string collect $forgit_diff; or string collect "gd") git-forgit diff
|
||||||
|
abbr -a -- (string collect $forgit_ignore; or string collect "gi") git-forgit ignore
|
||||||
|
abbr -a -- (string collect $forgit_checkout_file; or string collect "gcf") git-forgit checkout_file
|
||||||
|
abbr -a -- (string collect $forgit_checkout_branch; or string collect "gcb") git-forgit checkout_branch
|
||||||
|
abbr -a -- (string collect $forgit_branch_delete; or string collect "gbd") git-forgit branch_delete
|
||||||
|
abbr -a -- (string collect $forgit_clean; or string collect "gclean") git-forgit clean
|
||||||
|
abbr -a -- (string collect $forgit_stash_show; or string collect "gss") git-forgit stash_show
|
||||||
|
abbr -a -- (string collect $forgit_stash_push; or string collect "gsp") git-forgit stash_push
|
||||||
|
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_fixup; or string collect "gfu") git-forgit fixup
|
||||||
|
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_blame; or string collect "gbl") git-forgit blame
|
||||||
|
abbr -a -- (string collect $forgit_checkout_tag; or string collect "gct") git-forgit checkout_tag
|
||||||
|
end
|
|
@ -1,3 +1,4 @@
|
||||||
jorgebucaran/fisher
|
jorgebucaran/fisher
|
||||||
jhillyerd/plugin-git
|
jhillyerd/plugin-git
|
||||||
jorgebucaran/nvm.fish
|
jorgebucaran/nvm.fish
|
||||||
|
wfxr/forgit
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# This file contains fish universal variable definitions.
|
# This file contains fish universal variable definitions.
|
||||||
# VERSION: 3.0
|
# VERSION: 3.0
|
||||||
SETUVAR --export ELECTRON_OZONE_PLATFORM_HINT:auto
|
SETUVAR --export ELECTRON_OZONE_PLATFORM_HINT:auto
|
||||||
SETUVAR --export FZF_DEFAULT_OPTS:\x2d\x2dwalker\x2dskip\x3d\x2esteam\x2c\x2evscode\x2c\x2ecargo\x2c\x2enpm\x2c\x2envm\x2cSteam
|
SETUVAR --export FZF_DEFAULT_OPTS:\x2d\x2dwalker\x2dskip\x3d\x2esteam\x2c\x2evscode\x2c\x2ecargo\x2c\x2enpm\x2c\x2envm\x2cSteam\x2cgo\x2c\x2ecache\x2c\x2epub\x2dcache\x2c\x2erustup
|
||||||
SETUVAR --export --path PATH:/usr/local/bin\x1e/usr/local/sbin\x1e/usr/bin\x1e/usr/sbin\x1e/usr/local/go/bin
|
SETUVAR --export --path PATH:/usr/local/bin\x1e/usr/local/sbin\x1e/usr/bin\x1e/usr/sbin\x1e/usr/local/go/bin
|
||||||
SETUVAR --export RANGER_LOAD_DEFAULT_RC:FALSE
|
SETUVAR --export RANGER_LOAD_DEFAULT_RC:FALSE
|
||||||
SETUVAR Z_DATA_DIR:/home/foton/\x2elocal/share/z
|
SETUVAR Z_DATA_DIR:/home/foton/\x2elocal/share/z
|
||||||
|
@ -9,8 +9,9 @@ SETUVAR __fish_initialized:3400
|
||||||
SETUVAR _fisher_jhillyerd_2F_plugin_2D_git_files:\x7e/\x2econfig/fish/functions/__git\x2ebranch_has_wip\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2ecurrent_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2edefault_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2edestroy\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2einit\x2efish\x1e\x7e/\x2econfig/fish/functions/gbage\x2efish\x1e\x7e/\x2econfig/fish/functions/gbda\x2efish\x1e\x7e/\x2econfig/fish/functions/gdv\x2efish\x1e\x7e/\x2econfig/fish/functions/gignored\x2efish\x1e\x7e/\x2econfig/fish/functions/glp\x2efish\x1e\x7e/\x2econfig/fish/functions/grename\x2efish\x1e\x7e/\x2econfig/fish/functions/grt\x2efish\x1e\x7e/\x2econfig/fish/functions/gtest\x2efish\x1e\x7e/\x2econfig/fish/functions/gtl\x2efish\x1e\x7e/\x2econfig/fish/functions/gunwip\x2efish\x1e\x7e/\x2econfig/fish/functions/gwip\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/git\x2efish
|
SETUVAR _fisher_jhillyerd_2F_plugin_2D_git_files:\x7e/\x2econfig/fish/functions/__git\x2ebranch_has_wip\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2ecurrent_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2edefault_branch\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2edestroy\x2efish\x1e\x7e/\x2econfig/fish/functions/__git\x2einit\x2efish\x1e\x7e/\x2econfig/fish/functions/gbage\x2efish\x1e\x7e/\x2econfig/fish/functions/gbda\x2efish\x1e\x7e/\x2econfig/fish/functions/gdv\x2efish\x1e\x7e/\x2econfig/fish/functions/gignored\x2efish\x1e\x7e/\x2econfig/fish/functions/glp\x2efish\x1e\x7e/\x2econfig/fish/functions/grename\x2efish\x1e\x7e/\x2econfig/fish/functions/grt\x2efish\x1e\x7e/\x2econfig/fish/functions/gtest\x2efish\x1e\x7e/\x2econfig/fish/functions/gtl\x2efish\x1e\x7e/\x2econfig/fish/functions/gunwip\x2efish\x1e\x7e/\x2econfig/fish/functions/gwip\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/git\x2efish
|
||||||
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
SETUVAR _fisher_jorgebucaran_2F_fisher_files:\x7e/\x2econfig/fish/functions/fisher\x2efish\x1e\x7e/\x2econfig/fish/completions/fisher\x2efish
|
||||||
SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish
|
SETUVAR _fisher_jorgebucaran_2F_nvm_2E_fish_files:\x7e/\x2econfig/fish/functions/_nvm_index_update\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_list\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_activate\x2efish\x1e\x7e/\x2econfig/fish/functions/_nvm_version_deactivate\x2efish\x1e\x7e/\x2econfig/fish/functions/nvm\x2efish\x1e\x7e/\x2econfig/fish/conf\x2ed/nvm\x2efish\x1e\x7e/\x2econfig/fish/completions/nvm\x2efish
|
||||||
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejhillyerd/plugin\x2dgit\x1ejorgebucaran/nvm\x2efish
|
SETUVAR _fisher_plugins:jorgebucaran/fisher\x1ejhillyerd/plugin\x2dgit\x1ejorgebucaran/nvm\x2efish\x1ewfxr/forgit
|
||||||
SETUVAR _fisher_upgraded_to_4_4:\x1d
|
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\x2efish
|
||||||
SETUVAR fish_color_autosuggestion:4c566a
|
SETUVAR fish_color_autosuggestion:4c566a
|
||||||
SETUVAR fish_color_cancel:\x2d\x2dreverse
|
SETUVAR fish_color_cancel:\x2d\x2dreverse
|
||||||
SETUVAR fish_color_command:81a1c1
|
SETUVAR fish_color_command:81a1c1
|
||||||
|
@ -50,4 +51,4 @@ SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dbrblack
|
||||||
SETUVAR fish_pager_color_selected_completion:\x1d
|
SETUVAR fish_pager_color_selected_completion:\x1d
|
||||||
SETUVAR fish_pager_color_selected_description:\x1d
|
SETUVAR fish_pager_color_selected_description:\x1d
|
||||||
SETUVAR fish_pager_color_selected_prefix:\x1d
|
SETUVAR fish_pager_color_selected_prefix:\x1d
|
||||||
SETUVAR fish_user_paths:/home/foton/\x2ebin\x1e/opt/Obsidian\x1e/home/foton/go/bin\x1e/home/foton/code/dart\x2dsdk/bin\x1e/home/greg/\x2elocal/bin\x1e/home/greg/\x2ebin\x1e/home/greg/\x2ecargo/bin\x1e/home/greg/go/bin\x1e/usr/local/go/bin
|
SETUVAR fish_user_paths:/home/foton/\x2escripts\x1e/home/foton/\x2ebin\x1e/opt/Obsidian\x1e/home/foton/go/bin\x1e/home/foton/code/dart\x2dsdk/bin\x1e/home/greg/\x2elocal/bin\x1e/home/greg/\x2ebin\x1e/home/greg/\x2ecargo/bin\x1e/home/greg/go/bin\x1e/usr/local/go/bin
|
||||||
|
|
91
.scripts/dnf.sh
Executable file
91
.scripts/dnf.sh
Executable file
|
@ -0,0 +1,91 @@
|
||||||
|
|
||||||
|
#!/usr/bin/bash
|
||||||
|
readonly basename="$(basename "$0")"
|
||||||
|
|
||||||
|
if ! hash fzf &> /dev/null; then
|
||||||
|
printf 'Error: Missing dep: fzf is required to use %s.\n' "${basename}" >&2
|
||||||
|
exit 64
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Colors
|
||||||
|
declare -r esc=$'\033'
|
||||||
|
declare -r BLUE="${esc}[1m${esc}[34m"
|
||||||
|
declare -r RED="${esc}[31m"
|
||||||
|
declare -r GREEN="${esc}[32m"
|
||||||
|
declare -r YELLOW="${esc}[33m"
|
||||||
|
declare -r CYAN="${esc}[36m"
|
||||||
|
# Base commands
|
||||||
|
readonly QRY="dnf --cacheonly --quiet repoquery "
|
||||||
|
readonly PRVW="dnf --cacheonly --quiet --color=always info"
|
||||||
|
readonly QRY_PRFX=' '
|
||||||
|
readonly QRY_SFFX=' > '
|
||||||
|
# Install mode
|
||||||
|
readonly INS_QRYS="${QRY} --qf '${CYAN}%{name}'"
|
||||||
|
readonly INS_PRVW="${PRVW}"
|
||||||
|
readonly INS_PRMPT="${CYAN}${QRY_PRFX}Install packages${QRY_SFFX}"
|
||||||
|
# Remove mode
|
||||||
|
readonly RMV_QRYS="${QRY} --installed --qf '${RED}%{name}'"
|
||||||
|
readonly RMV_PRVW="${PRVW} --installed"
|
||||||
|
readonly RMV_PRMPT="${RED}${QRY_PRFX}Remove packages${QRY_SFFX}"
|
||||||
|
# Remove-userinstalled mode
|
||||||
|
readonly RUI_QRYS="${QRY} --userinstalled --qf '${YELLOW}%{name}'"
|
||||||
|
readonly RUI_PRVW="${PRVW} --installed"
|
||||||
|
readonly RUI_PRMPT="${YELLOW}${QRY_PRFX}Remove User-Installed${QRY_SFFX}"
|
||||||
|
# Updates mode
|
||||||
|
readonly UPD_QRY="${QRY} --upgrades --qf '${GREEN}%{name}'"
|
||||||
|
readonly UPD_QRYS="if [[ $(${UPD_QRY} | wc -c) -ne 0 ]]; then ${UPD_QRY}; else echo ${GREEN}No updates available.; echo Try refreshing metadata cache...; fi"
|
||||||
|
readonly UPD_PRVW="${PRVW}"
|
||||||
|
readonly UPD_PRMPT="${GREEN}${QRY_PRFX}Upgrade packages${QRY_SFFX}"
|
||||||
|
|
||||||
|
mapfile -d '' fhelp <<-EOF
|
||||||
|
|
||||||
|
"${basename}"
|
||||||
|
Interactive package manager for Fedora
|
||||||
|
|
||||||
|
Alt-i Install mode (default)
|
||||||
|
Alt-r Remove mode
|
||||||
|
Alt-e Remove User-Installed mode
|
||||||
|
Alt-u Updates mode
|
||||||
|
Alt-m Update package metadata cache
|
||||||
|
|
||||||
|
Enter Confirm selection
|
||||||
|
Tab Mark package ()
|
||||||
|
Shift-Tab Unmark package
|
||||||
|
Ctrl-a Select all
|
||||||
|
|
||||||
|
? Help (this page)
|
||||||
|
ESC Quit
|
||||||
|
EOF
|
||||||
|
|
||||||
|
declare tmp_file
|
||||||
|
if tmp_file="$(mktemp --tmpdir "${basename}".XXXXXX)"; then
|
||||||
|
printf 'in' > "${tmp_file}" &&
|
||||||
|
SHELL='/bin/bash' \
|
||||||
|
FZF_DEFAULT_COMMAND="${INS_QRYS}" \
|
||||||
|
fzf \
|
||||||
|
--ansi \
|
||||||
|
--multi \
|
||||||
|
--query=$* \
|
||||||
|
--header=" ${basename} | Press Alt+? for help or ESC to quit" \
|
||||||
|
--header-first \
|
||||||
|
--prompt="${INS_PRMPT}" \
|
||||||
|
--marker=' ' \
|
||||||
|
--preview-window='right,67%,wrap' \
|
||||||
|
--preview="${INS_PRVW} {1}" \
|
||||||
|
--bind="enter:execute(if grep -q 'in' \"${tmp_file}\"; then sudo dnf install {+};
|
||||||
|
elif grep -q 'rm' \"${tmp_file}\"; then sudo dnf remove {+}; \
|
||||||
|
elif grep -q 'up' \"${tmp_file}\"; then sudo dnf upgrade {+}; fi; \
|
||||||
|
read -s -r -n1 -p $'\n${BLUE}Press any key to continue...' && printf '\n')" \
|
||||||
|
--bind="alt-i:unbind(alt-i)+reload(${INS_QRYS})+change-preview(${INS_PRVW} {1})+change-prompt(${INS_PRMPT})+execute-silent(printf 'in' > \"${tmp_file}\")+first+rebind(alt-r,alt-e,alt-u)" \
|
||||||
|
--bind="alt-r:unbind(alt-r)+reload(${RMV_QRYS})+change-preview(${RMV_PRVW} {1})+change-prompt(${RMV_PRMPT})+execute-silent(printf 'rm' > \"${tmp_file}\")+first+rebind(alt-i,alt-e,alt-u)" \
|
||||||
|
--bind="alt-e:unbind(alt-e)+reload(${RUI_QRYS})+change-preview(${RUI_PRVW} {1})+change-prompt(${RUI_PRMPT})+execute-silent(printf 'rm' > \"${tmp_file}\")+first+rebind(alt-i,alt-r,alt-u)" \
|
||||||
|
--bind="alt-u:unbind(alt-u)+reload(${UPD_QRYS})+change-preview(${UPD_PRVW} {1})+change-prompt(${UPD_PRMPT})+execute-silent(printf 'up' > \"${tmp_file}\")+first+rebind(alt-i,alt-r,alt-e)" \
|
||||||
|
--bind="alt-m:execute(sudo dnf makecache;read -s -r -n1 -p $'\n${BLUE}Press any key to continue...' && printf '\n')" \
|
||||||
|
--bind="alt-?:preview(printf \"${fhelp[0]}\")" \
|
||||||
|
--bind="ctrl-a:select-all"
|
||||||
|
|
||||||
|
rm -f "${tmp_file}" &> /dev/null
|
||||||
|
else
|
||||||
|
printf 'Error: Failed to create tmp file. $TMPDIR (or /tmp if $TMPDIR is unset) may not be writable.\n' >&2
|
||||||
|
exit 65
|
||||||
|
fi
|
Loading…
Reference in a new issue