fix(zsh): g
function not autocompleting
This commit is contained in:
parent
6dc90947a5
commit
6de17552a4
|
@ -1,10 +1,13 @@
|
|||
for function in $ZDOTDIR/functions/*; do
|
||||
source "${function}"
|
||||
done
|
||||
|
||||
sources=(
|
||||
'aliases'
|
||||
'colour'
|
||||
'functions'
|
||||
'fzf'
|
||||
'general'
|
||||
'git'
|
||||
'history'
|
||||
'navigation'
|
||||
'nvm'
|
||||
|
@ -13,8 +16,10 @@ sources=(
|
|||
'platformsh'
|
||||
'plugins'
|
||||
'prompt'
|
||||
|
||||
'post/completion'
|
||||
)
|
||||
|
||||
for s in "${sources[@]}"; do
|
||||
source $ZDOTDIR/configs/${s}.zsh
|
||||
done
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
compdef g=git
|
||||
|
||||
# No arguments: `git status`
|
||||
# With arguments: acts like `git`
|
||||
g() {
|
||||
if [[ $# > 0 ]];
|
||||
then
|
||||
git $@
|
||||
else
|
||||
git status --short --branch
|
||||
fi
|
||||
}
|
|
@ -1,17 +1,7 @@
|
|||
# load our own completion functions
|
||||
fpath=(~/.zsh/completion-scripts /usr/local/share/zsh/site-functions $fpath)
|
||||
fpath=(~/.config/zsh/completion-scripts $fpath)
|
||||
|
||||
# completion; use cache if updated within 24h
|
||||
autoload -Uz compinit
|
||||
if [[ -n $HOME/.zcompdump(#qN.mh+24) ]]; then
|
||||
compinit -d $HOME/.zcompdump;
|
||||
else
|
||||
compinit -C;
|
||||
fi;
|
||||
|
||||
# disable zsh bundled function mtools command mcd
|
||||
# which causes a conflict.
|
||||
compdef -d mcd
|
||||
autoload -Uz compinit && compinit
|
||||
|
||||
## case-insensitive (all), partial-word and then substring completion
|
||||
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' \
|
||||
|
|
|
@ -3,13 +3,13 @@ setopt prompt_subst
|
|||
git_branch() {
|
||||
local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)"
|
||||
|
||||
[ -n "${branch}" ] && echo " (${branch})"
|
||||
[ -n "${branch}" ] && echo " ${branch}"
|
||||
}
|
||||
|
||||
git_commit() {
|
||||
local commit_sha="$(git rev-parse --short HEAD 2> /dev/null)"
|
||||
|
||||
[ -n "${commit_sha}" ] && echo " [${commit_sha}]"
|
||||
[ -n "${commit_sha}" ] && echo " [%{$fg[yellow]%}${commit_sha}%{$reset_color%}]"
|
||||
}
|
||||
|
||||
export PS1='%{$fg[blue]%}%1d%{$reset_color%}%{$fg[green]%}$(git_branch)%{$reset_color%}%{$fg[yellow]%}$(git_commit)%{$reset_color%} $ '
|
||||
export PS1='%{$fg[blue]%}%~%{$reset_color%}%{$fg[green]%}$(git_branch)%{$reset_color%}$(git_commit) $ '
|
||||
|
|
9
roles/zsh/files/config/functions/g
Normal file
9
roles/zsh/files/config/functions/g
Normal file
|
@ -0,0 +1,9 @@
|
|||
# No arguments: `git status`
|
||||
# With arguments: acts like `git`
|
||||
g() {
|
||||
if [[ $# -gt 0 ]]; then
|
||||
git "$@"
|
||||
else
|
||||
git status
|
||||
fi
|
||||
}
|
Loading…
Reference in a new issue