dotfiles/env
Eryn Wells 75760856af [zsh] Fix path setup
- Add setup-path function that allows resetting the path at any time.
- macOS does a dumb thing where it resets your path with some helper binary in
  /etc/zprofile. Disable GLOBAL_RCS in .zshenv so it doesn't read system init
  files.
2018-04-14 09:41:42 -07:00

86 lines
2.1 KiB
Bash

# .env
# vim: ft=zsh:
#
# Environment settings for bash and derivatives. The env scripts are sourced by
# Zsh for every shell, even the non-interactive ones, so this needs to be small
# and quick. Any configuration that will only be used for interactive sessions
# should be in the rc scripts.
#
# Eryn Wells <eryn@erynwells.me>
[[ -e "$HOME/.shell-functions" ]] && source "$HOME/.shell-functions"
export SYS=`uname -s | tr A-Z a-z`
# Set this to a non-zero integer to see startup messages
export NOISY=0
print_heading -l 1 'Initializing environment'
export PAGER="less"
export MANPAGER=$PAGER
export EDITOR="vim"
export VISUAL=$EDITOR
export LESSHISTFILE="-"
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="1;32"
function prepend-to-path
{
if [[ -d "$1" ]]; then
path=("$1" $path)
export path
fi
}
function append-to-path
{
if [[ -d "$1" ]]; then
path+="$1"
export path
fi
}
function setup-path
{
export path=()
append-to-path "/usr/local/bin"
append-to-path "/usr/bin"
append-to-path "/bin"
append-to-path "/usr/local/sbin"
append-to-path "/usr/sbin"
append-to-path "/sbin"
prepend-to-path "/usr/X11/bin"
prepend-to-path "/opt/local/bin"
prepend-to-path "$HOME/.local/bin"
prepend-to-path "$HOME/.gem/ruby/2.2.0/bin"
prepend-to-path "$HOME/.cargo/bin"
prepend-to-path "$HOME/bin"
}
setup-path
if which virtualenvwrapper.sh 1>/dev/null 2>&1; then
export WORKON_HOME="$HOME/src/py/.envs"
source `which virtualenvwrapper.sh`
fi
# Make sure gpg2 knows what to do with the curses-based smartcard PIN prompt.
export GPG_TTY=`tty`
# System-specific settings
if [[ -e "$HOME/.env.$SYS" ]]; then
print_info -l 2 "Sourcing system-specific environment settings for $SYS"
source "$HOME/.env.$SYS"
fi
host_env="$HOME/.env.`hostname -s`"
if [[ -e "$host_env" ]]; then
print_info -l 2 "Sourcing host-specific environment settings: $host_env"
source "$host_env"
fi
# Local environment settings
if [[ -e "$HOME/.env.local" ]]; then
print_info -l 2 "Sourcing local environment setup"
source "$HOME/.env.local"
fi