From d7b5ab30d2abc5f8dcd86868e657bfd1b7e15a67 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 27 Mar 2017 22:24:20 -0400 Subject: [PATCH] Refactor shell env initialization --- shell/bash/.bash_profile | 15 ++++----------- shell/env.sh | 11 ++--------- shell/zsh/.zshenv | 10 +++------- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/shell/bash/.bash_profile b/shell/bash/.bash_profile index 7939444c..4c965e86 100644 --- a/shell/bash/.bash_profile +++ b/shell/bash/.bash_profile @@ -8,19 +8,12 @@ fi ## Bash rcfiles ########################### -source $HOME/.dotfiles/.common.sh +source $HOME/.dotfiles/common.sh -declare -a paths=( - "$DOTFILES/{bin,scripts}" - "$HOME/.{rb,py}env/{shims,bin}" - "/usr/local/{bin,sbin}" -) -[[ "$OSTYPE" == "darwin"* ]] && paths+="$(brew --prefix coreutils)/libexec/gnubin" - -for index in ${!paths[*]}; do - [ -d ${paths[$index]} ] && PATH="${paths[$index]}:$PATH" +PATH="$DOTFILES/bin:/usr/local/{bin,sbin}:$PATH" +for bin in "$ENABLED_DIR"/*/bin; do + [[ -e "$bin" ]] && PATH="$bin:$PATH" done -unset paths export PATH diff --git a/shell/env.sh b/shell/env.sh index d9abbb30..61a3175d 100644 --- a/shell/env.sh +++ b/shell/env.sh @@ -1,15 +1,8 @@ # Loaded at the end of the initialization process -# export EDITOR=$(is-callable nvim && echo 'nvim' || echo 'vim') export VISUAL=$EDITOR - -# export GPG_TTY=$(tty) -PATH="$DOTFILES/bin:$PATH" -bins=( "$ENABLED_DIR"/*/bin ) -for bin in "${bins[@]}"; do - [[ -e "$bin" ]] && PATH="$bin:$PATH" -done -export PATH +[[ $LANG ]] || export LANG='en_US.UTF-8' +export TERMINFO="$HOME/.terminfo" diff --git a/shell/zsh/.zshenv b/shell/zsh/.zshenv index 4367d5a2..46dca8e4 100644 --- a/shell/zsh/.zshenv +++ b/shell/zsh/.zshenv @@ -1,9 +1,9 @@ ## Paths +source "$HOME/.dotfiles/shell/common.sh" + # Ensure path arrays do not contain duplicates. typeset -gU cdpath fpath mailpath path -path=( /usr/local/{,s}bin $path ) - -source "$HOME/.dotfiles/shell/common.sh" +path=( $DOTFILES/bin "$ENABLED_DIR"/*/bin /usr/local/{,s}bin $path ) load shell/zsh/config.zsh loadall env.zsh @@ -17,7 +17,3 @@ export LESS='-g -i -M -R -S -w -z-4' if is-callable lesspipe; then export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-' fi - -[[ $LANG ]] || export LANG='en_US.UTF-8' - -export TERMINFO="$HOME/.terminfo"