[zsh] Update shell init; use ZSH autoloaded functions instead of a bunch of files
This commit is contained in:
		
							parent
							
								
									2b584f97cf
								
							
						
					
					
						commit
						b09d523218
					
				
					 13 changed files with 208 additions and 138 deletions
				
			
		| 
						 | 
					@ -12,11 +12,19 @@ import os.path
 | 
				
			||||||
_LOGFILE = os.path.expanduser('~/.shell.log')
 | 
					_LOGFILE = os.path.expanduser('~/.shell.log')
 | 
				
			||||||
_LOGGER = None
 | 
					_LOGGER = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					LOG_LEVELS = {
 | 
				
			||||||
 | 
					    'crit': logging.CRITICAL,
 | 
				
			||||||
 | 
					    'error': logging.ERROR,
 | 
				
			||||||
 | 
					    'warn': logging.WARNING,
 | 
				
			||||||
 | 
					    'info': logging.INFO,
 | 
				
			||||||
 | 
					    'debug': logging.DEBUG
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def parse_args():
 | 
					def parse_args():
 | 
				
			||||||
    parser = argparse.ArgumentParser()
 | 
					    parser = argparse.ArgumentParser()
 | 
				
			||||||
    parser.add_argument('-b', '--bold', action='store_true')
 | 
					    parser.add_argument('-b', '--bold', action='store_true')
 | 
				
			||||||
    parser.add_argument('-f', '--file', default=LOGFILE)
 | 
					    parser.add_argument('-f', '--file', default=_LOGFILE)
 | 
				
			||||||
    parser.add_argument('-l', '--level', type=int, default=logging.INFO)
 | 
					    parser.add_argument('-l', '--level', default='info', choices=list(LOG_LEVELS.keys()))
 | 
				
			||||||
    parser.add_argument('-n', '--noeol', action='store_true')
 | 
					    parser.add_argument('-n', '--noeol', action='store_true')
 | 
				
			||||||
    parser.add_argument('msg')
 | 
					    parser.add_argument('msg')
 | 
				
			||||||
    parser.add_argument('args', nargs=argparse.REMAINDER)
 | 
					    parser.add_argument('args', nargs=argparse.REMAINDER)
 | 
				
			||||||
| 
						 | 
					@ -31,19 +39,23 @@ def logger(args):
 | 
				
			||||||
    stdout_handler.setFormatter(formatter)
 | 
					    stdout_handler.setFormatter(formatter)
 | 
				
			||||||
    logger.addHandler(stdout_handler)
 | 
					    logger.addHandler(stdout_handler)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # TODO: Add file handler
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return logger
 | 
					    return logger
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    # Set up.
 | 
					 | 
				
			||||||
    args = parse_args()
 | 
					    args = parse_args()
 | 
				
			||||||
    log = logger(args)
 | 
					    log = logger(args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Set the level from the shell.
 | 
					    level = os.environ.get('SHELL_LOG_LEVEL', logging.INFO)
 | 
				
			||||||
    level = int(os.environ.get('NOISY', logging.INFO))
 | 
					 | 
				
			||||||
    log.setLevel(level)
 | 
					    log.setLevel(level)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Log it.
 | 
					    try:
 | 
				
			||||||
    log.log(args.level, args.msg, *args.args)
 | 
					        message_log_level = LOG_LEVELS[args.level] 
 | 
				
			||||||
 | 
					    except KeyError:
 | 
				
			||||||
 | 
					        message_log_level = logging.INFO
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    log.log(message_log_level, args.msg, *args.args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if __name__ == '__main__':
 | 
					if __name__ == '__main__':
 | 
				
			||||||
    main()
 | 
					    main()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										87
									
								
								env
									
										
									
									
									
								
							
							
						
						
									
										87
									
								
								env
									
										
									
									
									
								
							| 
						 | 
					@ -1,87 +0,0 @@
 | 
				
			||||||
# .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
 | 
					 | 
				
			||||||
							
								
								
									
										26
									
								
								env.darwin
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								env.darwin
									
										
									
									
									
								
							| 
						 | 
					@ -1,26 +0,0 @@
 | 
				
			||||||
# vim: set ft=zsh:
 | 
					 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export OSBUILD=`sysctl -n kern.osversion`
 | 
					 | 
				
			||||||
export OSVERSION=`sysctl -n kern.osproductversion`
 | 
					 | 
				
			||||||
export HWMODEL=`sysctl -n hw.model`
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
pythonroot="$HOME/Library/Python"
 | 
					 | 
				
			||||||
if [[ -d "$pythonroot" ]]; then
 | 
					 | 
				
			||||||
    for f in `ls "$pythonroot"`; do
 | 
					 | 
				
			||||||
        prepend-to-path "$pythonroot/$f/bin"
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
prepend-to-path "/usr/local/go/bin"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
py27local="$pythonroot/2.7/lib/python/site-packages"
 | 
					 | 
				
			||||||
if [[ -d "$py27local" ]]; then
 | 
					 | 
				
			||||||
    if [[ ! -z $PYTHONPATH ]]; then
 | 
					 | 
				
			||||||
        PYTHONPATH=$py27local:$PYTHONPATH
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
        PYTHONPATH=$py27local
 | 
					 | 
				
			||||||
    fi
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
unset py27local
 | 
					 | 
				
			||||||
unset pythonroot
 | 
					 | 
				
			||||||
export PYTHONPATH
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,5 +0,0 @@
 | 
				
			||||||
# vim: set ft=zsh:
 | 
					 | 
				
			||||||
# Linux specific environment settings
 | 
					 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export MAIL="/var/mail/$USER"
 | 
					 | 
				
			||||||
| 
						 | 
					@ -1,5 +0,0 @@
 | 
				
			||||||
# .env.local
 | 
					 | 
				
			||||||
# vim: set ft=zsh:
 | 
					 | 
				
			||||||
# Local environment customizations
 | 
					 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
							
								
								
									
										13
									
								
								zsh/func/append_to_path
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								zsh/func/append_to_path
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# vim:ft=zsh:
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function append_to_path
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if [[ -d "$1" ]]; then
 | 
				
			||||||
 | 
					        path+="$1"
 | 
				
			||||||
 | 
					        export path
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					append_to_path "$@"
 | 
				
			||||||
							
								
								
									
										21
									
								
								zsh/func/init_env
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								zsh/func/init_env
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# vim:ft=zsh:
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function init_env
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    shell-log 'Initializing basic 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"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # Make sure gpg2 knows what to do with the curses-based smartcard PIN prompt.
 | 
				
			||||||
 | 
					    export GPG_TTY=`tty`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					init_env "$@"
 | 
				
			||||||
							
								
								
									
										38
									
								
								zsh/func/init_env_darwin
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								zsh/func/init_env_darwin
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,38 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# vim:ft=zsh:
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					autoload append_to_path
 | 
				
			||||||
 | 
					autoload prepend_to_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function init_env_darwin
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    shell-log "Initializing Darwin environment"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    export OSBUILD=`sysctl -n kern.osversion`
 | 
				
			||||||
 | 
					    export OSVERSION=`sysctl -n kern.osproductversion`
 | 
				
			||||||
 | 
					    export HWMODEL=`sysctl -n hw.model`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    local pythonRoot
 | 
				
			||||||
 | 
					    local python27SitePackages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pythonRoot="$HOME/Library/Python"
 | 
				
			||||||
 | 
					    if [[ -d "$pythonRoot" ]]; then
 | 
				
			||||||
 | 
					        for f in `ls "$pythonRoot"`; do
 | 
				
			||||||
 | 
					            prepend_to_path "$pythonRoot/$f/bin"
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
 | 
				
			||||||
 | 
					    if [[ -d "$python27SitePackages" ]]; then
 | 
				
			||||||
 | 
					        if [[ ! -z $PYTHONPATH ]]; then
 | 
				
			||||||
 | 
					            PYTHONPATH=$python27SitePackages:$PYTHONPATH
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            PYTHONPATH=$python27SitePackages
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    export PYTHONPATH
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					init_env_darwin "$@"
 | 
				
			||||||
							
								
								
									
										29
									
								
								zsh/func/init_env_darwin_python
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								zsh/func/init_env_darwin_python
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,29 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# vim:ft=zsh:
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function init_env_darwin_python
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    local pythonRoot
 | 
				
			||||||
 | 
					    local python27SitePackages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pythonRoot="$HOME/Library/Python"
 | 
				
			||||||
 | 
					    if [[ -d "$pythonRoot" ]]; then
 | 
				
			||||||
 | 
					        for f in `ls "$pythonRoot"`; do
 | 
				
			||||||
 | 
					            prepend_to_path "$pythonRoot/$f/bin"
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
 | 
				
			||||||
 | 
					    if [[ -d "$python27SitePackages" ]]; then
 | 
				
			||||||
 | 
					        if [[ ! -z $PYTHONPATH ]]; then
 | 
				
			||||||
 | 
					            PYTHONPATH=$python27SitePackages:$PYTHONPATH
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            PYTHONPATH=$python27SitePackages
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    export PYTHONPATH
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					init_env_darwin_python "$@"
 | 
				
			||||||
							
								
								
									
										34
									
								
								zsh/func/init_env_python
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								zsh/func/init_env_python
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# vim:ft=zsh:
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function init_env_python
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    local pythonRoot
 | 
				
			||||||
 | 
					    local python27SitePackages
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pythonRoot="$HOME/Library/Python"
 | 
				
			||||||
 | 
					    if [[ -d "$pythonRoot" ]]; then
 | 
				
			||||||
 | 
					        for f in `ls "$pythonRoot"`; do
 | 
				
			||||||
 | 
					            prepend_to_path "$pythonRoot/$f/bin"
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    python27SitePackages="$pythonroot/2.7/lib/python/site-packages"
 | 
				
			||||||
 | 
					    if [[ -d "$python27SitePackages" ]]; then
 | 
				
			||||||
 | 
					        if [[ ! -z $PYTHONPATH ]]; then
 | 
				
			||||||
 | 
					            PYTHONPATH=$python27SitePackages:$PYTHONPATH
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            PYTHONPATH=$python27SitePackages
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    export PYTHONPATH
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if which virtualenvwrapper.sh 1>/dev/null 2>&1; then
 | 
				
			||||||
 | 
					        export WORKON_HOME="$HOME/src/py/.envs"
 | 
				
			||||||
 | 
					        source `which virtualenvwrapper.sh`
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					init_env_python "$@"
 | 
				
			||||||
							
								
								
									
										25
									
								
								zsh/func/init_path
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								zsh/func/init_path
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# Initialize the path to a standard default
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					autoload prepend_to_path
 | 
				
			||||||
 | 
					autoload append_to_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function init_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"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					init_path
 | 
				
			||||||
							
								
								
									
										13
									
								
								zsh/func/prepend_to_path
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								zsh/func/prepend_to_path
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					#!/usr/bin/env zsh
 | 
				
			||||||
 | 
					# vim:ft=zsh:
 | 
				
			||||||
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function prepend_to_path
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    if [[ -d "$1" ]]; then
 | 
				
			||||||
 | 
					        path=("$1" $path)
 | 
				
			||||||
 | 
					        export path
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					prepend_to_path "$@"
 | 
				
			||||||
							
								
								
									
										24
									
								
								zshenv
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								zshenv
									
										
									
									
									
								
							| 
						 | 
					@ -1,16 +1,24 @@
 | 
				
			||||||
# .zshenv
 | 
					# .zshenv
 | 
				
			||||||
# vim: ft=zsh
 | 
					# vim: ft=zsh
 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Environment settings for zsh
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Eryn Wells <eryn@erynwells.me>
 | 
					# Eryn Wells <eryn@erynwells.me>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Don't read global startup. It messes things up...
 | 
					# Don't read global startup. It messes things up...
 | 
				
			||||||
unsetopt GLOBAL_RCS
 | 
					unsetopt GLOBAL_RCS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ -e $HOME/.env ] && source $HOME/.env
 | 
					export SYS=`uname -s | tr A-Z a-z`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# System specific environment settings
 | 
					fpath=("$HOME/.zsh/func" $fpath)
 | 
				
			||||||
[ -e $HOME/.zshenv.$SYS ] && source $HOME/.zshenv.$SYS
 | 
					autoload +X prepend_to_path
 | 
				
			||||||
# Local environment settings
 | 
					autoload +X append_to_path
 | 
				
			||||||
[ -e $HOME/.zshenv.local ] && source $HOME/.zshenv.local
 | 
					autoload +X init_env
 | 
				
			||||||
 | 
					autoload +X init_env_python
 | 
				
			||||||
 | 
					autoload +X init_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					init_path
 | 
				
			||||||
 | 
					init_env
 | 
				
			||||||
 | 
					init_env_python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					autoload +X init_env_$SYS
 | 
				
			||||||
 | 
					if [[ $? ]]; then
 | 
				
			||||||
 | 
					    init_env_$SYS
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue