mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-12-22 15:21:30 +01:00
zsh: cleanup functions completions
This commit is contained in:
parent
73ef8d928a
commit
c6b110b325
|
@ -253,11 +253,34 @@ function retry() {
|
|||
# Creats a gitignore for the given argument (e.g. python, cpp, etc)
|
||||
function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@; }
|
||||
|
||||
|
||||
__completion_wrapper(){
|
||||
# Wrapper for completion functions.
|
||||
# These can be used to force loading of all completions
|
||||
# for the given command in order to access specialized
|
||||
# completion functions
|
||||
#
|
||||
# See `__git_completion_wrapper()` below for usage
|
||||
local _completion_function=$1
|
||||
local _completion_base=$2
|
||||
if ! command -v $_completion_function; then
|
||||
$_completion_base
|
||||
fi
|
||||
$_completion_function
|
||||
}
|
||||
|
||||
__git_completion_wrapper() {
|
||||
# Wrapper for `__git_*` completion functions
|
||||
# Can be used to force loading of specialized git completions
|
||||
# When defining custom commands. See below for usage examples.
|
||||
__completion_wrapper $1 _git
|
||||
}
|
||||
|
||||
# Runs git log with fzf with preview
|
||||
compdef _git fgitlog=git-log
|
||||
function fgitlog() {
|
||||
git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60%
|
||||
}
|
||||
compdef _git fgitlog=git-log
|
||||
|
||||
git-commit-show() {
|
||||
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" |
|
||||
|
@ -273,23 +296,28 @@ git-commit-show() {
|
|||
{} FZF-EOF" \
|
||||
--preview-window=right:60%
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_commits" git-commit-show
|
||||
|
||||
compdef __git_recent_commits git-fixup
|
||||
git-fixup() {
|
||||
git commit --fixup=$1
|
||||
git -c sequence.editor=true rebase --interactive --autosquash $1^
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_commits" git-fixup
|
||||
|
||||
compdef __git_branch_names git-diff-branch
|
||||
git-diff-branch() {
|
||||
git diff $@
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_branch_names" git-diff-branch
|
||||
|
||||
if command -v pacman &>/dev/null ; then
|
||||
compdef _pacman_completions_installed_packages pacbins
|
||||
pacbins() {
|
||||
pacman -Ql $1 | sed -n -e 's/.*\/bin\///p' | tail -n +2
|
||||
}
|
||||
_pacbins(){
|
||||
# fix completion
|
||||
__completion_wrapper _pacman_completions_installed_packages _pacman
|
||||
}
|
||||
compdef _pacbins pacbins
|
||||
fi
|
||||
|
||||
if command -v rustc &>/dev/null
|
||||
|
@ -300,7 +328,6 @@ then
|
|||
fi
|
||||
|
||||
if command -v fzf &>/dev/null ; then
|
||||
compdef _fzf_complete
|
||||
falias() {
|
||||
alias | fzf $@ | cut -d= -f 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user