Skip to content

Instantly share code, notes, and snippets.

@EthanJStark
Last active August 27, 2024 18:24
Show Gist options
  • Save EthanJStark/7a45c30fe202b5b80b494a14e2f062d9 to your computer and use it in GitHub Desktop.
Save EthanJStark/7a45c30fe202b5b80b494a14e2f062d9 to your computer and use it in GitHub Desktop.
.zshrc
## PATH
export N_PREFIX=$HOME/.n
export PATH=$N_PREFIX/bin:$HOME/bin:$PATH
## VS Code
## Shell integration
[[ "$TERM_PROGRAM" == "vscode" ]] && . "$(code --locate-shell-integration-path zsh)"
## Plugins
source ~/.zsh/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh
fpath=(~/.zsh/zsh-completions/ $fpath)
## Auto-complete
autoload -Uz compinit
typeset -i updated_at=$(date +'%j' -r ~/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)
if [ $(date +'%j') != $updated_at ]; then
compinit -i
else
compinit -C -i
fi
zmodload -i zsh/complist
HISTFILE=$HOME/.zsh_history
HISTSIZE=100000
SAVEHIST=$HISTSIZE
setopt hist_ignore_all_dups # remove older duplicate entries from history
setopt hist_reduce_blanks # remove superfluous blanks from history items
setopt inc_append_history # save history entries as soon as they are entered
setopt share_history # share history between different instances of the shell
setopt auto_cd # cd by typing directory name if it's not a command
setopt correct_all # autocorrect commands
setopt auto_list # automatically list choices on ambiguous completion
setopt auto_menu # automatically use menu completion
setopt always_to_end # move cursor to end if word had one match
zstyle ':completion:*' menu select # select completions with arrow keys
zstyle ':completion:*' group-name '' # group results by category
zstyle ':completion:::::' completer _expand _complete _ignored _approximate # enable approximate matches for completion
bindkey '^[[3~' delete-char
bindkey '^[3;5~' delete-char
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
### Ethan's custom aliases
function current_branch() {
git rev-parse --abbrev-ref HEAD
}
alias ca="code ."
# Docker
alias dcu="docker compose up"
alias dcd="docker compose down"
alias dc="docker compose"
alias d="docker"
alias ds='docker stop $(docker ps -a -q)'
alias dsrm='docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q)'
alias dsd='docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -q) -f'
alias dde='docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -q) -f && docker volume prune -f'
alias dps="docker ps --format '{{ .ID }}\t{{.Image}}\t{{ .Names }}'"
alias yyd="yarn && yarn dev"
alias yd="yarn dev"
alias ys="yarn start"
alias gs='git status'
alias yt='yarn test'
alias grh='git reset --hard origin/$(current_branch)'
alias y='yarn'
alias ghc='gh copilot'
alias ghs='gh copilot suggest -s'
alias gcm='git commit -m'
alias gpu='git push -u origin HEAD'
alias gma='git checkout master'
alias gt='git checkout trunk'
# git / oh-my-zsh aliases
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gb='git branch'
alias gbr="git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:iso8601) %(refname:short)'"
alias gc='git commit -v'
alias gco='git checkout'
alias gf='git fetch'
alias gl='git pull'
alias glog='git log --oneline --decorate --graph'
alias gp='git push'
# network
alias wifi='networksetup -ordernetworkservices Wi-Fi "USB 10/100/1000 LAN" "Thunderbolt Bridge"'
alias ethernet='networksetup -ordernetworkservices "USB 10/100/1000 LAN" Wi-Fi "Thunderbolt Bridge"'
# Nearpod
alias np='nptools'
alias cdn='cd ~/workspace/nptools'
alias cdl='cd ~/workspace/localenv && source ./bin/activate'
export NPTOOLS_DISABLE_METRICS=true
# Load Starship prompt
eval "$(starship init zsh)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment