I have the following lines in my ~/.aliases
:
function __function_exists() {
declare -f -F $1 > /dev/null
return $?
}
# git aliases (need to have git bash completion installed)
for al in `__git_aliases`; do
alias g$al="git $al"
complete_func=_git_$(__git_aliased_command $al)
__function_exists $complete_fnc && __git_complete g$al $complete_func
done
And in my ~/.gitconfig
i have:
[alias]
# one-line log
l = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
a = add
ap = add -p
c = commit --verbose
ca = commit -a --verbose
cm = commit -m
cam = commit -a -m
m = commit --amend --verbose
d = diff
ds = diff --stat
dc = diff --cached
s = status -s
co = checkout
cob = checkout -b
# list branches sorted by last modified
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"
# list aliases
la = "!git config -l | grep alias | cut -c 7-"
And in my ~/.zshrc
:
zstyle :compinstall filename '/home/giuliani/.zshrc'
autoload -Uz compinit
compinit
[[ -f $HOME/.aliases ]] && source "$HOME/.aliases"
So, for each alias in my gitconfig i will define a shell alias like gl
for git log
and so on.
Trying to port this to zsh i'm having a problem: zsh autoload
built-in only loads the file /usr/share/zsh/functions/Completion/Unix/_git
the first time i try to complete some git command.
I've tried to call/load _git
file directly from the .zshrc
but other them a few warnings, it didn't work.
What is the proper way to have the same funcionality that i have in bash, using zsh ?