diff --git a/bin/bin/, b/bin/bin/, new file mode 100755 index 0000000..229e6d0 --- /dev/null +++ b/bin/bin/, @@ -0,0 +1,13 @@ +#!/usr/bin/env zsh + +source $ZDOTDIR/functions + +dir=$(find-local-bin aet) + +if [[ -f $dir/$@ ]]; then + exec $dir/$@ +elif [[ -f $HOME/bin/$@ ]]; then + exec $HOME/bin/$@ +else + echo "Nothing to execute" +fi diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index c25978e..a3c429b 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -36,7 +36,7 @@ fi autoload compinit -Uz setopt EXTENDEDGLOB -if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then +if [[ -n ${ZDOTDIR}/.zcompdump(#qN.m+1) ]]; then compinit else compinit -C diff --git a/zsh/.config/zsh/completions/_comma b/zsh/.config/zsh/completions/_comma new file mode 100755 index 0000000..8b1f301 --- /dev/null +++ b/zsh/.config/zsh/completions/_comma @@ -0,0 +1,6 @@ + #compdef , + +found_bin_dir=$(find-local-bin aet) + +_files -g "^," -W $found_bin_dir +_files -g "^," -W $HOME/bin diff --git a/zsh/.config/zsh/functions b/zsh/.config/zsh/functions index edc1299..7cd7a01 100644 --- a/zsh/.config/zsh/functions +++ b/zsh/.config/zsh/functions @@ -25,6 +25,25 @@ function docker-compose-call { fi } +function find-local-bin { + local prefix=$1 + local bin_dir="$prefix-bin" + local found_bin_dir="" + + current_dir=$(pwd) + found_bin_dir=$current_dir/$bin_dir + while [ ! -d $found_bin_dir ]; do + if [[ $current_dir == $HOME ]]; then + break + fi + + current_dir=$(realpath "$current_dir/..") + found_bin_dir=$current_dir/$bin_dir + done + + echo $found_bin_dir +} + function g { if [[ $# > 0 ]]; then git $@ diff --git a/zsh/.zshenv b/zsh/.zshenv index bf1476e..aab858d 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,10 +1,11 @@ +ZDOTDIR=$HOME/.config/zsh + PERSONAL_BIN_PATH="$HOME/bin" +PERSONAL_FPATH="$ZDOTDIR/completions" NODENV_PATH="$HOME/.nodenv/bin" RBENV_PATH="$HOME/.rbenv/bin" -ZDOTDIR=$HOME/.config/zsh - if [[ "$OSTYPE" == darwin* ]]; then HOMEBREW_PREFIX="/opt/homebrew" HOMEBREW_CELLAR="/opt/homebrew/Cellar" @@ -28,6 +29,7 @@ fi [[ -d "$RBENV_PATH" ]] && PATH="$RBENV_PATH:$PATH" [[ -d "$NODENV_PATH" ]] && PATH="$NODENV_PATH:$PATH" [[ -d "$PERSONAL_BIN_PATH" ]] && PATH="$PERSONAL_BIN_PATH:$PATH" +[[ -d "$PERSONAL_FPATH" ]] && FPATH="$PERSONAL_FPATH:$FPATH" # EDITOR EDITOR=vim