dotwryn/zsh/rc
2023-11-11 16:16:34 -07:00

47 lines
1.2 KiB
Bash

#!/bin/zsh
source "$HOME/.config/wryn/env.zsh"
#####################################################################
INTERNAL_PLUGINS=(
"$DOTWRYN/zsh/config" # must load first
$(find "$DOTWRYN/zsh" -mindepth 1 -maxdepth 1 -type f \
| grep -v '/rc$' \
| grep -v '/config$' \
| grep -v '/\.[^/]\+$' \
)
)
SET_PREFERRED_EDITOR() {
# load preference from environment
[[ ${#PREFERRED_EDITOR[@]} -eq 0 ]] && {
echo 'unable to find $PREFERRED_EDITOR environment variable'
return 1
}
[[ $EDITOR == "${PREFERRED_EDITOR[-1]}" ]] \
&& [[ $VISUAL == "${PREFERENCE[-1]}" ]] \
&& return 0
local AVAILABLE_EDITOR=$EDITOR
for program in $PREFERRED_EDITOR
do
which $program >/dev/null 2>&1 \
&& AVAILABLE_EDITOR="$program" \
&& break
done
export EDITOR="$AVAILABLE_EDITOR"
export VISUAL="$AVAILABLE_EDITOR"
}
#####################################################################
for p in $INTERNAL_PLUGINS; do source $p; done
for p in $EXTERNAL_PLUGINS; do [ -f $p ] && source $p; done
SET_PREFERRED_EDITOR
WELCOME
echo $PATH | grep -q "^\\(.*:\\|\\)$HOME/.local/bin\\(:.*\\|\\)$" \
|| export PATH="$HOME/.local/bin:$PATH"
#####################################################################
true