Move zsh init functions to corresponding directories

This commit is contained in:
Eryn Wells 2024-10-02 19:19:29 -07:00
parent ae514e9a07
commit c664ca3b9d
8 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,21 @@
# Eryn Wells <eryn@erynwells.me>
autoload -Uz binary_exists
function init-env
{
export PAGER=less
export GREP_OPTIONS="--color=auto"
export GREP_COLOR="1;32"
if binary_exists gpg2; then
# Make sure gpg2 knows what to do with the curses-based smartcard PIN prompt.
export GPG_TTY=`tty`
fi
# Some helpful aliases for scripting
alias local-array="local -a"
alias local-map="local -A"
}
init-env "$@"

View file

@ -0,0 +1,17 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
function init-env-darwin
{
local -r xcode_library="$HOME/Library/Developer/Xcode"
if [[ -d "$xcode_library" ]]; then
export XCODE_LIBRARY="$xcode_library"
export XCODE_DERIVED_DATA="$XCODE_LIBRARY/DerivedData"
export XCODE_INSTALLS="$XCODE_LIBRARY/Installs"
export dd="$XCODE_DERIVED_DATA"
fi
export df=~/.dotfiles
}
init-env-darwin "$@"

View file

@ -0,0 +1,27 @@
# Eryn Wells <eryn@erynwells.me>
autoload -Uz update-path
function init-env-path
{
path=()
update-path \
"$HOME/bin" \
"$HOME/.local/bin" \
"$HOME/.cargo/bin" \
"$HOME/.ghcup/bin" \
"$HOME/.gem/ruby/2.2.0/bin" \
"$HOME/.vim/bundle/vim-tidal/bin" \
/opt/local/bin \
/usr/X11/bin \
/opt/brew/bin \
/opt/homebrew/bin \
/usr/local/bin \
/usr/bin \
/bin \
/usr/local/sbin \
/usr/sbin \
/sbin
}
init-env-path "$@"

View file

@ -0,0 +1,15 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
autoload -Uz prepend_to_path
function init-env-playdate
{
local -r sdk_path="$HOME/Developer/PlaydateSDK"
if [[ -d "$sdk_date" ]]; then
export PLAYDATE_SDK_PATH="$sdk_path"
prepend_to_path "$PLAYDATE_SDK_PATH/bin"
fi
}
init-env-playdate "$@"

View file

@ -0,0 +1,15 @@
# Eryn Wells <eryn@erynwells.me>
autoload -Uz prepend_to_path
function init-env-python
{
local -r user_python_root="$HOME/Library/Python"
if [[ -d "$pythonRoot" ]]; then
for f in $pythonRoot/*; do
prepend_to_path "$f/bin"
done
fi
}
init-env-python "$@"

View file

@ -0,0 +1,20 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
function init-env-tilde-paths
{
for candidate_code_path in \
"$HOME/Code" \
"$HOME/Developer" \
"$HOME/Documents/Code"
do
if [[ ! -d "$candidate_code_path" ]]; then
continue
fi
c="$candidate_code_path"
break
done
}
init-env-tilde-paths "$@"

View file

@ -0,0 +1,20 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
function init-env-vi
{
# Prefer nvim and vim, in that order, over standard vi, which is insufferable.
if whence -cp nvim &> /dev/null; then
alias vi=nvim
export EDITOR=nvim
elif whence -cp vim &> /dev/null; then
alias vi=vim
export EDITOR=vim
else
export EDITOR=vi
fi
export VISUAL=$EDITOR
}
init-env-vi "$@"

View file

@ -0,0 +1,39 @@
#!/usr/bin/env zsh
# Eryn Wells <eryn@erynwells.me>
autoload -Uz binary_exists
function init-rc-darwin
{
alias acls='command ls -le'
# These things might have been installed by Homebrew, and I like the GNU
# versions better.
binary_exists gdircolors && alias dircolors='gdircolors'
binary_exists gfind && alias find='gfind'
binary_exists gnuindent && alias indent='gnuindent'
binary_exists gls && init_rc_configure_ls `which gls`
# ldd doesn't exist on OS X, but otool -L does the same thing.
alias ldd='otool -L'
# From macOS's system zshrc.
# Disable the log builtin, so we don't conflict with /usr/bin/log
disable log
local sounds=/System/Library/Sounds
alias glass="afplay $sounds/Glass.aiff"
alias funk="afplay $sounds/Funk.aiff"
autoload -Uz darwin_init_once
autoload -Uz darwin-icloud-drive-path
autoload -Uz darwin_configure_screenshots_directory
autoload -Uz finder
alias -s app='open'
alias -s xcodeproj='open-xcode'
alias -s xcworkspace='open-xcode'
}
init-rc-darwin "$@"