From 2d3e13e5c23fe616ce111fbc48ffb08dc0c86bc5 Mon Sep 17 00:00:00 2001 From: Wryn Wagner Date: Thu, 16 Sep 2021 15:33:35 -0600 Subject: [PATCH] rc simplification --- env/env.zsh | 7 +++--- zsh/rc | 66 +++++++++++++++++++++++------------------------------ 2 files changed, 32 insertions(+), 41 deletions(-) diff --git a/env/env.zsh b/env/env.zsh index 34f32e3..f51ce7e 100644 --- a/env/env.zsh +++ b/env/env.zsh @@ -10,14 +10,12 @@ WALLPAPER_PATH="$HOME/Pictures/bg" ### Application Settings ############################################ ##################################################################### -# ordered from least-preferred to most-preferred -PREFERRED_EDITOR=(vi vim) - # should play an audio file argument MEDIA_ENGINE='canberra-gtk-play -f' RIPGREP_CONFIG_PATH="$HOME/.config/ripgrep/config" TMUX_DEFAULT_SESSION_NAME='wryn' +PREFERRED_EDITOR=(vim vi) WEBBROWSER='google-chrome-stable' PS1_BRANCH_SYMBOL='' @@ -25,12 +23,13 @@ PS1_INDICATOR_SYMBOL='☕' PS1_SEPARATOR='::' PS1_USER='%n' +WELCOME () { { figlet 'Welcome, beautiful'; cowsay -p 'damn u sexy' } | lolcat } ##################################################################### ### External Plugins / Settings ##################################### ##################################################################### -EXTERNAL_PLUGIN_LIST=( +EXTERNAL_PLUGINS=( "$DOTWRYN/zsh/plugins/z/z.sh" '/usr/share/fzf/key-bindings.zsh' '/usr/share/fzf/completion.zsh' diff --git a/zsh/rc b/zsh/rc index 424e0a4..6d71c5f 100644 --- a/zsh/rc +++ b/zsh/rc @@ -1,49 +1,41 @@ #!/bin/zsh - source "$HOME/.config/wryn/env/env.zsh" +# --------------------------------------------------------------------- +INTERNAL_PLUGINS=( + "$DOTWRYN/zsh/config" # must load first + $(find "$DOTWRYN/zsh" -maxdepth 1 -type f \ + ! -name 'rc' \ + ! -name 'config' \ + ) +) -# --- load custom plugins ------------------------------------------ - -# zsh config : must load first for zsh-plugins to work -source "$DOTWRYN/zsh/config" - -for file in $(find "$DOTWRYN/zsh" -maxdepth 1 -type f ! -name 'rc' ! -name 'config'); do source $file; done; - -# operating system specific plugins -case "$OSTYPE" in - linux-gnu ) - for file in $(find "$DOTWRYN/zsh/linux" -type f); do source $file; done; - ;; - darwin* ) - for file in $(find "$DOTWRYN/zsh/osx" -type f); do source $file; done; - ;; -esac - - -# --- set default editor ------------------------------------------- SET_PREFERRED_EDITOR() { - # load preference from environment (vi vim) by default - [[ -z $PREFERRED_EDITOR ]] && { echo 'unable to find $PREFERRED_EDITOR environment variable'; return 1; } + # 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; + [[ $EDITOR == "${PREFERRED_EDITOR[-1]}" ]] \ + && [[ $VISUAL == "${PREFERENCE[-1]}" ]] \ + && return 0 - local AVAILABLE_EDITOR="$EDITOR"; + local AVAILABLE_EDITOR=$EDITOR - for program in $PREFERRED_EDITOR; do which $program >/dev/null 2>&1 && AVAILABLE_EDITOR="$program"; done + 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 source $p; done SET_PREFERRED_EDITOR - -# --- load external plugins ---------------------------------------- - -for PLUGIN in $EXTERNAL_PLUGIN_LIST; do - [ -f "$PLUGIN" ] && source "$PLUGIN" -done - -# --- welcome message ---------------------------------------------- -CUSTOM_WELCOME="$HOME/.config/wryn/welcome" -[ -f "$CUSTOM_WELCOME" ] \ - && { source "$CUSTOM_WELCOME" } \ - || { { figlet 'Welcome, beautiful'; cowsay -p 'damn u sexy' } | lolcat; } +WELCOME +# --------------------------------------------------------------------- +return 0