Provide shortcut to find personal bin exes

This commit is contained in:
Andrew Tomaka 2022-02-02 23:17:43 -05:00
parent 686a06e2b6
commit 662063f37b
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
5 changed files with 43 additions and 3 deletions

13
bin/bin/, Executable file
View file

@ -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

View file

@ -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

View file

@ -0,0 +1,6 @@
#compdef ,
found_bin_dir=$(find-local-bin aet)
_files -g "^," -W $found_bin_dir
_files -g "^," -W $HOME/bin

View file

@ -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 $@

View file

@ -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