Last active
December 12, 2023 03:21
-
-
Save tannerhodges/5576b1f75a39c19ebe7279507ddc8580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------ | |
# Appearance | |
# ------------------------------ | |
# Enable colors | |
CLICOLOR=1 | |
# Custom prompt | |
# - Git branch: https://www.mfitzp.com/article/add-git-branch-name-to-terminal-prompt-mac/ | |
# - Current folder: https://superuser.com/a/142129, http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html | |
# - Adding color: https://scriptingosx.com/2019/07/moving-to-zsh-06-customizing-the-zsh-prompt/ | |
# - Fix prompt not updating: https://askubuntu.com/a/896698 | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
# `%1d` = Current folder (aka, the "trailing component of the current working directory") | |
# `%F{green}...%f` = Make `...` green! | |
setopt PROMPT_SUBST | |
PROMPT='%1d%F{green}$(parse_git_branch)%f > ' | |
# Format `time` | |
# https://superuser.com/a/71890 | |
TIMEFMT=$'\nreal\t%E\nuser\t%U\nsys\t%S' | |
# ------------------------------ | |
# General | |
# ------------------------------ | |
# Profile settings | |
alias profile="open -e ~/.zshrc" | |
alias profile_reload=". ~/.zshrc" | |
# Refresh the terminal session | |
alias refresh="exec zsh -l" | |
# Update all the things | |
alias update="sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update" | |
# Safeguard rm | |
# https://github.com/sindresorhus/trash-cli | |
alias rm=trash | |
# Bat (Better Cat) | |
# https://github.com/sharkdp/bat#readme | |
alias cat="bat --paging=never" | |
# Chrome | |
# https://stackoverflow.com/a/41956095 | |
alias chrome="open -a 'Google Chrome'" | |
# Fix Safari redirecting HTTP sites to HTTPS | |
# https://apple.stackexchange.com/a/215099/282260 | |
alias fix_https="rm ~/Library/Cookies/HSTS.plist" | |
# Flush DNS | |
alias flush_dns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder" | |
# McFly | |
# Fuzzy search for terminal history. | |
# https://github.com/cantino/mcfly#readme | |
eval "$(mcfly init zsh)" | |
# Please! | |
# https://twitter.com/zzaaho/status/1160825118597292032 | |
# alias please="sudo $(fc -ln -1)" | |
# z (Faster cd) | |
# https://github.com/rupa/z | |
. /opt/homebrew/etc/profile.d/z.sh | |
# ------------------------------ | |
# Apache | |
# ------------------------------ | |
alias apache_start="brew services restart httpd; sudo apachectl -k restart" | |
alias apache_stop="brew services stop httpd; sudo apachectl -k stop" | |
# ------------------------------ | |
# Gifs | |
# ------------------------------ | |
alias mov_to_gif="ffmpeg -i in.mov -s 1280x800 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 --delay=4 > out.gif" | |
alias mp4_to_gif="ffmpeg -i in.mp4 -s 1280x800 -pix_fmt rgb8 -r 10 -f gif - | gifsicle --optimize=3 --delay=4 > out.gif" | |
# ------------------------------ | |
# Git | |
# ------------------------------ | |
alias gs="git status" | |
alias ga="git add -p" | |
alias gaa="git add --all" | |
alias gc="git commit" | |
alias gca="git commit --amend" | |
alias gd="git diff" | |
alias gdc="git diff --cached" | |
alias gm="git merge" | |
alias gk="git checkout" | |
alias gp="git push" | |
alias gpf="git push --force-with-lease" | |
alias gl="git pull" | |
alias gb="git branch" | |
alias gr="git reset HEAD" | |
alias gy="git --no-pager log --reverse --author='Tanner' --date=short --since='yesterday' --pretty=format:'%h%x09%ad%x09%s' > log.txt && open log.txt" | |
# ------------------------------ | |
# Docker (Colima) | |
# ------------------------------ | |
alias colima_start="colima start --cpu 4 --memory 8 --disk 60" | |
# ------------------------------ | |
# Docker | |
# ------------------------------ | |
alias docker_ls="docker ps -aq" | |
alias docker_stop="docker ps -aq | xargs docker stop" | |
# # How to Reset Docker | |
# # Delete all your Docker containers, images, and volumes. | |
# docker stop $(docker ps -a -q) | |
# docker rm $(docker ps -a -q) | |
# docker rmi $(docker images -q) --force | |
# docker system prune -f | |
# docker image prune -f | |
# docker volume prune -f | |
# | |
# # Delete your Lando cached settings. | |
# rm -rf ~/.lando/ | |
# | |
# # Uninstall Docker & Lando. | |
# brew cask uninstall lando | |
# brew cask uninstall docker | |
# | |
# # But for real, make sure everything's gone. | |
# rm -rf ~/Library/Caches/Homebrew/Cask/docker* | |
# rm -rf ~/Library/Caches/Homebrew/Cask/lando* | |
# brew cleanup | |
# ------------------------------ | |
# Lando | |
# ------------------------------ | |
alias li="lando info --service database --format table" | |
alias lp="lando pull" | |
alias lpa="lando pull --code=live --database=live --files=live" | |
alias lpc="lando pull --code=live --database=none --files=none" | |
alias lpd="lando pull --code=none --database=live --files=none" | |
alias lpf="lando pull --code=none --database=none --files=live" | |
alias lc="lando wp cache flush && lando wp rewrite flush && lando wp pantheon cache purge-all --yes" | |
# ------------------------------ | |
# Vagrant | |
# ------------------------------ | |
alias vu="vagrant up" | |
alias vs="vagrant suspend" | |
alias vss="vagrant ssh" | |
# ------------------------------ | |
# Homebrew | |
# ------------------------------ | |
# brew | |
PATH="/usr/local/sbin:$PATH" | |
# ------------------------------ | |
# Node / NVM | |
# ------------------------------ | |
# nvm | |
# https://github.com/creationix/nvm | |
# https://stackoverflow.com/a/35774067/1786459 | |
# https://github.com/ohmyzsh/ohmyzsh/issues/7171#issuecomment-428310627 | |
. "$(brew --prefix nvm)/nvm.sh" | |
NVM_DIR="$HOME/.nvm" | |
# Calling nvm use automatically in a directory with a .nvmrc file | |
# https://github.com/nvm-sh/nvm#zsh | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
local node_version="$(nvm version)" | |
local nvmrc_path="$(nvm_find_nvmrc)" | |
if [ -n "$nvmrc_path" ]; then | |
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
if [ "$nvmrc_node_version" = "N/A" ]; then | |
nvm install | |
elif [ "$nvmrc_node_version" != "$node_version" ]; then | |
nvm use | |
fi | |
elif [ "$node_version" != "$(nvm version default)" ]; then | |
echo "Reverting to nvm default version" | |
nvm use default | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc | |
load-nvmrc | |
# ------------------------------ | |
# Gulp | |
# ------------------------------ | |
# Auto-completion | |
# https://github.com/gulpjs/gulp-cli#completion | |
# TODO: Why is this throwing `(eval):25: command not found: compdef`? | |
# eval "$(gulp --completion=zsh)" | |
# ------------------------------ | |
# PHP / Composer | |
# ------------------------------ | |
# composer | |
# https://getcomposer.org | |
PATH="$PATH:$HOME/.composer/vendor/bin" | |
# ------------------------------ | |
# Python / pyenv | |
# ------------------------------ | |
export PYENV_ROOT="$HOME/.pyenv" | |
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" | |
# ------------------------------ | |
# Ruby / rbenv | |
# ------------------------------ | |
# rbenv | |
# https://github.com/rbenv/rbenv | |
eval "$(rbenv init -)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment