Zsh files; node files; brew.zsh; functions/

This commit is contained in:
Marley 2024-01-21 21:32:20 -08:00
parent 697a1b931e
commit 70b93f81dc
8 changed files with 237 additions and 0 deletions

3
homebrew/brew.zsh Normal file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env zsh
export HOMEBREW_NO_ANALYTICS=1

4
node/nvm.zsh Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env zsh
export NVM_HOMEBREW="$(brew --prefix nvm)"
zstyle ':omz:plugins:nvm' autoload yes

6
zsh/.curlrc.symlink Normal file
View file

@ -0,0 +1,6 @@
connect-timeout = 60 # limit the timeout in seconds
location # follow HTTP redirects
show-error # show error messages
# send a fake UA string for the HTTP servers that sniff it
user-agent = "Mozilla/5.0 Gecko"

94
zsh/.zshrc.symlink Normal file
View file

@ -0,0 +1,94 @@
#!/usr/bin/env zsh
# Base path.
export PATH="$HOME/bin:/usr/local/bin:$PATH"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Dotfiles root dir.
export DOT="$HOME/dotfiles"
# Projects dir.
export HACK="$HOME/hackin"
# Theme.
ZSH_THEME="typewritten"
# Use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"
# Auto-update behavior.
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the
# default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
COMPLETION_WAITING_DOTS="true"
# Plugins to load.
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
plugins=(git zsh-syntax-highlighting zsh-autosuggestions colored-man-pages gh gulp iterm2 laravel macos npm nvm sudo thefuck)
# iTerm2 Shell Integration
if [[ "$(uname)" == "Darwin" ]] && [[ $(mdfind "iTerm.app") ]]; then
zstyle ':omz:plugins:iterm2' shell-integration yes
fi
# the fuck
eval $(thefuck --alias)
# zsh completions
fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src
source $ZSH/oh-my-zsh.sh
# Local environment variables.
if [[ -e $HOME/.local.env ]]; then
source ~/.local.env
fi
# All zsh dotfiles.
typeset -U config_files
config_files=($DOT/**/*.zsh)
# Load path files first.
for file in ${(M)config_files:#*/path.zsh}; do
source $file
done
# Load everything else, except completion.
for file in ${${config_files:#*/path.zsh}:#*/completion.zsh}; do
source $file
done
# Initialize autocomplete.
autoload -U compinit
compinit
# Load autocompletions.
for file in ${(M)config_files:#*/completion.zsh}; do
source $file
done
unset config_files
# Herd injected PHP binary.
export PATH="/Users/marley/Library/Application Support/Herd/bin/":$PATH
# Herd injected PHP 8.2 configuration.
export HERD_PHP_82_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/82/"
# Herd injected PHP 8.3 configuration.
export HERD_PHP_83_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/83/"
# Herd injected PHP 8.1 configuration.
export HERD_PHP_81_INI_SCAN_DIR="/Users/marley/Library/Application Support/Herd/config/php/81/"

87
zsh/aliases.zsh Normal file
View file

@ -0,0 +1,87 @@
#!/usr/bin/env zsh
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Shell aliases
alias zshconfig="$EDITOR ~/.zshrc"
alias ohmyzsh="$EDITOR ~/.oh-my-zsh"
alias rl=". ~/.zshrc"
alias c="clear"
alias e="$EDITOR"
# Help alias
autoload -Uz run-help
autoload -Uz run-help-git
alias help=run-help
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Location alias
alias hack="cd ~/hackin"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Default command options
alias cp="cp -iv"
# │└─ list copied files
# └─ prompt before overwriting an existing file
alias mkdir="mkdir -pv"
# │└─ list created directories
# └─ create intermediate directories
alias mv="mv -iv"
# │└─ list moved files
# └─ prompt before overwriting an existing file
alias rm="rm -rf --"
# Colored grep output
alias grep="grep --color=auto"
alias fgrep="fgrep --color=auto"
alias egrep="egrep --color=auto"
# Recursively delete `.DS_Store` files
alias dscleanup="find . -type f -name '*.DS_Store' -ls -delete"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
shared_update_cmds="brew update && brew upgrade && brew cleanup; \
npm install npm -g && npm update -g; \
sudo gem update --system && sudo gem update && sudo gem cleanup"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Mac aliases
if [[ "$(uname)" == "Darwin" ]]; then
alias clear-dns-cache="sudo dscacheutil -flushcache; \
sudo killall -HUP mDNSResponder"
alias o="open"
alias u="sudo softwareupdate --install --all; $shared_update_cmds"
# Show/hide hidden files in Finder
alias showhid="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hidehid="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
# Merge PDF files, preserving hyperlinks
# Usage: `mergepdf input{1,2,3}.pdf`
alias mergepdf='gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=_merged.pdf'
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Ubuntu aliases
if [[ "$(uname)" == "Linux" ]]; then
alias 0="xdg-open"
alias u="sudo apt update && sudo apt upgrade; $shared_update_cmds"
fi

4
zsh/completion.zsh Normal file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env zsh
# Make matches case insensitive for lowercase
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

23
zsh/config.zsh Normal file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env zsh
export EDITOR=nvim
export VISUAL="$EDITOR"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
# https://linux.die.net/man/1/zshoptions
setopt LOCAL_OPTIONS # allow functions to have local options
setopt LOCAL_TRAPS # allow functions to have local traps
setopt PROMPT_SUBST # perform expansion & subsitution in prompts
setopt HIST_VERIFY # perform history expansion (see man page linked above)
setopt HIST_IGNORE_ALL_DUPS # delete older duplicates
setopt HIST_REDUCE_BLANKS # remove superfluous blanks
setopt SHARE_HISTORY # share history between sessions via the $HISTFILE
setopt COMPLETE_ALIASES # don't expand aliases before attempting completion

16
zsh/fpath.zsh Normal file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env zsh
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if [[ -d "$DOT/functions" ]]; then
fpath=($DOT/functions $fpath)
autoload -U $DOT/functions/*(:t)
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Add each topic folder to fpath so that they can
# add functions and completion scripts.
for topic_folder ($ZSH/*) if [ -d $topic_folder ]; then
fpath=($topic_folder $fpath)
fi