mirror of
https://github.com/danielepintore/dotfiles.git
synced 2026-06-15 20:25:13 +02:00
now config alias is a function, autocomplete for paths is now working
This commit is contained in:
@@ -7,8 +7,13 @@ if [[ -o interactive ]]; then
|
||||
zstyle ':completion:*' menu select
|
||||
zmodload zsh/complist
|
||||
compinit
|
||||
_comp_options+=(globdots) # Include hidden files.
|
||||
unset -f setup_completion # cleanup the function
|
||||
_comp_options+=(globdots) # Include hidden files.
|
||||
unset -f setup_completion # cleanup the function
|
||||
|
||||
# dotfiles manager autocompletition trick for add and rm command
|
||||
# definition on the config functions file (functions/config.zsh)
|
||||
compdef _config config
|
||||
|
||||
# Use vim keys in tab complete menu:
|
||||
bindkey -M menuselect 'h' vi-backward-char
|
||||
bindkey -M menuselect 'k' vi-up-line-or-history
|
||||
|
||||
@@ -14,6 +14,3 @@ alias podrun='podman run -v $(pwd):/chall/ --rm -it registry.fedoraproject.org/f
|
||||
|
||||
## pwninit alias
|
||||
alias pwninit='pwninit --template-path /home/daniele/.config/pwninit/pwninit-template.py'
|
||||
|
||||
## alias for managing dotfiles
|
||||
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
|
||||
|
||||
22
.config/zsh/functions/config.zsh
Normal file
22
.config/zsh/functions/config.zsh
Normal file
@@ -0,0 +1,22 @@
|
||||
config() {
|
||||
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME "$@"
|
||||
}
|
||||
|
||||
# 3) custom completer
|
||||
_config() {
|
||||
local context state line
|
||||
|
||||
if ! (( $+functions[_git] )); then
|
||||
autoload -U _git
|
||||
fi
|
||||
|
||||
if [[ $words[2] == "add" || $words[2] == "rm" ]]; then
|
||||
_files
|
||||
else
|
||||
# Set up git completion context
|
||||
local -x GIT_DIR="$HOME/.cfg"
|
||||
local -x GIT_WORK_TREE="$HOME"
|
||||
service=git
|
||||
_git "$@"
|
||||
fi
|
||||
}
|
||||
Reference in New Issue
Block a user