programmatically load os-specific plugin and set preferred EDITOR/VISUAL
This commit is contained in:
parent
324f8fa285
commit
e4dbe394f4
40
zsh/rc
40
zsh/rc
@ -4,30 +4,36 @@ source "$HOME/.wryn/env/env.zsh"
|
|||||||
|
|
||||||
RC_DIR="$DOTWRYN/zsh"
|
RC_DIR="$DOTWRYN/zsh"
|
||||||
|
|
||||||
# zsh plugins
|
# --- load custom plugins ------------------------------------------
|
||||||
|
|
||||||
for file in $(find $RC_DIR -maxdepth 1 -type f ! -name 'rc'); do source $file; done;
|
for file in $(find $RC_DIR -maxdepth 1 -type f ! -name 'rc'); do source $file; done;
|
||||||
|
|
||||||
# linux-specific plugins
|
# operating system specific plugins
|
||||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
case "$OSTYPE" in
|
||||||
|
linux-gnu )
|
||||||
for file in $(find $RC_DIR/linux -type f); do source $file; done;
|
for file in $(find $RC_DIR/linux -type f); do source $file; done;
|
||||||
fi
|
;;
|
||||||
|
darwin* )
|
||||||
# osx-specific plugins
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
for file in $(find $RC_DIR/osx -type f); do source $file; done;
|
for file in $(find $RC_DIR/osx -type f); do source $file; done;
|
||||||
fi
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
# --- vi / vim as default editor (vim preferred) -------------------
|
# --- set default editor -------------------------------------------
|
||||||
which vi >/dev/null 2>&1 && {
|
SET_PREFERRED_EDITOR() {
|
||||||
export EDITOR='vi';
|
local PREFERENCE="$PREFERRED_EDITOR"; # load preference from environment (vi vim) by default
|
||||||
export VISUAL='vi';
|
[ -z $PREFERENCE ] && { echo 'unable to find $PREFERRED_EDITOR environment variable'; return 1; }
|
||||||
}
|
|
||||||
|
[[ $EDITOR == "${PREFERENCE[-1]}" ]] && [[ $VISUAL == "${PREFERENCE[-1]}" ]] && return 0;
|
||||||
which vim >/dev/null 2>&1 && {
|
|
||||||
export EDITOR='vim';
|
local AVAILABLE_EDITOR="$EDITOR";
|
||||||
export VISUAL='vim';
|
|
||||||
|
for program in $PREFERENCE; do which $program >/dev/null 2>&1 && AVAILABLE_EDITOR="$program"; done
|
||||||
|
|
||||||
|
export EDITOR="$AVAILABLE_EDITOR";
|
||||||
|
export VISUAL="$AVAILABLE_EDITOR";
|
||||||
}
|
}
|
||||||
|
SET_PREFERRED_EDITOR
|
||||||
|
|
||||||
|
|
||||||
# --- welcome message ----------------------------------------------
|
# --- welcome message ----------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user