Skip to content

Instantly share code, notes, and snippets.

@dashmug
Created October 1, 2024 18:50
Show Gist options
  • Save dashmug/7bb9c43fbd0c3987ca247e70bc1c6c00 to your computer and use it in GitHub Desktop.
Save dashmug/7bb9c43fbd0c3987ca247e70bc1c6c00 to your computer and use it in GitHub Desktop.
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
# Aliases
alias wget='wget -c'
alias c='clear'
alias pm='poetry run python manage.py'
alias gnpm='npm --global'
alias st='stree'
alias rm="rm -i"
alias md5sum='md5 -q'
alias cat='bat'
alias ls='eza'
alias ping='prettyping --nolegend'
alias preview="fzf --preview 'bat --color \"always\" {}'"
alias top="htop"
alias ncdu="ncdu --color dark -x"
alias dc="docker compose"
alias vim="nvim"
alias tf="terraform"
alias myip="curl ifconfig.me"
# add support for ctrl+o to open selected file in VS Code
export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'"
alias zshconfig='code ~/.zshrc'
alias awsconfig='code ~/.aws'
# Begin git aliases
alias gst='git status'
alias glog='git log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit --date=relative'
alias gl='git pull --prune'
alias glu='git pull upstream `git rev-parse --abbrev-ref HEAD`'
alias gds='git diff --stat'
alias gfum='git fetch upstream master'
alias grh='git reset --hard'
alias ga='git add'
alias gco='git checkout'
alias gc='git commit'
alias gp='git push'
alias gpf='git push --force-with-lease'
alias gm='git merge'
alias gr='git rebase'
alias gcp='git cherry-pick'
alias gf='git fetch'
alias gb='git branch'
# direnv
eval "$(direnv hook zsh)"
# Custom functions
function mkdircd() {
mkdir -p "$@" && eval cd "\"\$$#\"";
}
function up() {
echo "Updating Homebrew..."
brew update
brew upgrade
brew cleanup
echo "pipx packages"
pipx upgrade-all
echo "Done."
}
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
if type brew &>/dev/null; then
FPATH=$(brew --prefix)/share/zsh-completions:$FPATH
autoload -Uz compinit
compinit
fi
eval "$(starship init zsh)"
eval "$(mcfly init zsh)"
export AWS_SDK_LOAD_CONFIG=1
autoload -U +X bashcompinit && bashcompinit
# Invoke tab-completion script to be sourced with the Z shell.
# Known to work on zsh 5.0.x, probably works on later 4.x releases as well (as
# it uses the older compctl completion system).
_complete_invoke() {
# `words` contains the entire command string up til now (including
# program name).
#
# We hand it to Invoke so it can figure out the current context: spit back
# core options, task names, the current task's options, or some combo.
#
# Before doing so, we attempt to tease out any collection flag+arg so we
# can ensure it is applied correctly.
collection_arg=''
if [[ "${words}" =~ "(-c|--collection) [^ ]+" ]]; then
collection_arg=$MATCH
fi
# `reply` is the array of valid completions handed back to `compctl`.
# Use ${=...} to force whitespace splitting in expansion of
# $collection_arg
reply=( $(invoke ${=collection_arg} --complete -- ${words}) )
}
# Tell shell builtin to use the above for completing our given binary name(s).
# * -K: use given function name to generate completions.
# * +: specifies 'alternative' completion, where options after the '+' are only
# used if the completion from the options before the '+' result in no matches.
# * -f: when function generates no results, use filenames.
# * positional args: program names to complete for.
compctl -K _complete_invoke + -f invoke inv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment