[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
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 "$@"
|
||||
Loading…
Add table
Add a link
Reference in a new issue