Skip to content

Instantly share code, notes, and snippets.

@akunzai
Last active March 22, 2024 15:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save akunzai/616796de59282c8bfdae3005511c588e to your computer and use it in GitHub Desktop.
Save akunzai/616796de59282c8bfdae3005511c588e to your computer and use it in GitHub Desktop.
My ZSH profile
# https://www.cyberciti.biz/faq/apple-mac-osx-terminal-color-ls-output-option/
export CLICOLOR=1
export EDITOR=vi
# https://learn.microsoft.com/dotnet/core/tools/dotnet-environment-variables#dotnet_cli_ui_language
export DOTNET_CLI_UI_LANGUAGE='en-us'
# https://learn.microsoft.com/aspnet/core/fundamentals/environments
export DOTNET_ENVIRONMENT=Development
export ASPNETCORE_ENVIRONMENT=Development
# https://github.com/dotnet/runtime/issues/68018
export DOTNET_ReadyToRun=0
# https://docs.npmjs.com/cli/v9/using-npm/config
export NPM_CONFIG_FUND=false
export NPM_CONFIG_AUDIT=false
# https://nodejs.dev/en/learn/nodejs-the-difference-between-development-and-production/
export NODE_ENV=development
# https://github.com/docker/compose/pull/9200
export COMPOSE_REMOVE_ORPHANS=true
# https://docs.brew.sh/FAQ#why-should-i-install-homebrew-in-the-default-location
if [[ $(uname -m) == 'arm64' ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
else
eval "$(/usr/local/bin/brew shellenv)"
fi
# https://www.topbug.net/blog/2016/10/11/speed-test-check-the-existence-of-a-command-in-bash-and-zsh/
if [[ (( $+commands[brew] )) ]]; then
# https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh
FPATH="$HOMEBREW_PREFIX/share/zsh/site-functions:$FPATH"
autoload -Uz compinit
compinit
# https://github.com/zsh-users/zsh-autosuggestions
[ -e "$HOMEBREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh" ] && . "$HOMEBREW_PREFIX/share/zsh-autosuggestions/zsh-autosuggestions.zsh"
# https://github.com/zdharma-continuum/fast-syntax-highlighting
[ -e "$HOMEBREW_PREFIX/opt/zsh-fast-syntax-highlighting" ] && . "$HOMEBREW_PREFIX/opt/zsh-fast-syntax-highlighting/share/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"
fi
# https://ohmyposh.dev/
if [[ -x "$HOMEBREW_PREFIX/bin/oh-my-posh" ]]; then
eval "$(oh-my-posh init zsh)"
enable_poshtransientprompt
POSH_THEME="$(brew --prefix oh-my-posh)/themes/dracula.omp.json"
fi
# https://www.sublimetext.com/docs/command_line.html#mac
if [[ -e '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' ]]; then
export PATH="$PATH:/Applications/Sublime Text.app/Contents/SharedSupport/bin"
[ -z "$VISUAL" ] && export VISUAL=subl
fi
# https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line
if [[ -d '/Applications/Visual Studio Code.app/Contents/Resources/app/bin' ]]; then
export PATH="$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
[ -z "$VISUAL" ] && export VISUAL=code
fi
# https://youtrack.jetbrains.com/issue/TBX-7889
if [[ -d "$HOME/Library/Application Support/JetBrains/Toolbox/scripts" ]]; then
export PATH="$PATH:$HOME/Library/Application Support/JetBrains/Toolbox/scripts"
fi
# https://github.com/dotnet/sdk/issues/9415
[[ -d "$HOME/.dotnet/tools" ]] && export PATH="$PATH:$HOME/.dotnet/tools"
if [[ -d "$HOME/bin" ]]; then
export PATH="$PATH:$HOME/bin"
fi
# https://blog.miniasp.com/post/2020/05/04/How-to-use-GPG-sign-git-commit-and-tag-object
if [[ -x "$HOMEBREW_PREFIX/bin/gpg-agent" ]]; then
export GPG_TTY=$(tty)
fi
# https://remysharp.com/2018/08/23/cli-improved
if [[ -x "$HOMEBREW_PREFIX/bin/bat" ]]; then
export BAT_THEME='Dracula'
alias cat='bat'
alias less='bat'
fi
# https://github.com/nvm-sh/nvm
if [[ -e "$HOMEBREW_PREFIX/opt/nvm" ]]; then
[ -e "$HOME/.nvm" ] || mkdir "$HOME/.nvm"
export NVM_DIR="$HOME/.nvm"
[ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && source "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" # This loads nvm
[ -s "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" ] && source "$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
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
fi
# https://www.jbang.dev/
if [[ -x "$HOMEBREW_PREFIX/bin/jbang" ]]; then
alias j!=jbang
export PATH="$HOME/.jbang/bin:$PATH"
fi
# https://www.jenv.be/
if [[ -x "$HOMEBREW_PREFIX/bin/jenv" ]]; then
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"
fi
# https://developers.google.com/web/updates/2017/04/headless-chrome
if [[ -e '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome' ]]; then
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
# Make sure all chrome processes are killed before running the command
alias chrome-xss='chrome --disable-xss-auditor'
fi
if [[ -d "$HOMEBREW_PREFIX/share/google-cloud-sdk" ]]; then
source "$HOMEBREW_PREFIX/share/google-cloud-sdk/path.zsh.inc"
source "$HOMEBREW_PREFIX/share/google-cloud-sdk/completion.zsh.inc"
if [[ (( $+commands[python3] )) ]]; then
export CLOUDSDK_PYTHON=$(which python3 2>/dev/null)
fi
fi
# https://github.com/dotnet/runtime/issues/46071
if [[ -d "$HOMEBREW_PREFIX/opt/openssl@3/lib" ]]; then
export DYLD_LIBRARY_PATH=$HOMEBREW_PREFIX/opt/openssl@3/lib
fi
# https://jimkang.medium.com/install-go-on-mac-with-homebrew-5fa421fc55f5
if [ -e "$HOMEBREW_PREFIX/opt/go/libexec" ]; then
export GOROOT="$HOMEBREW_PREFIX/opt/go/libexec"
export GOPATH="$HOME/go"
[ -x $GOROOT/bin ] && export PATH="$PATH:$GOROOT/bin"
[ -x $GOPATH/bin ] && export PATH="$PATH:$GOPATH/bin"
fi
# https://ngrok.com/docs/secure-tunnels/ngrok-agent/reference/ngrok/#ngrok-completion
if command -v ngrok &>/dev/null; then
eval "$(ngrok completion)"
fi
# https://github.com/kaplanelad/shellfirm
if [ -e "$HOME/.shellfirm-plugin.sh" ] && command -v shellfirm &>/dev/null; then
source ~/.shellfirm-plugin.sh
fi
# https://pnpm.io/installation#using-a-shorter-alias
if command -v pnpm &>/dev/null; then
alias pn=pnpm
export PNPM_HOME="$HOME/Library/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
fi
alias ls='ls -G'
alias ll='ls -lG'
# https://stackoverflow.com/a/70528020
alias python=python3
# https://hub.docker.com/_/composer
alias composer='docker run -it --rm -v $PWD:/app -v ${COMPOSER_HOME:-$HOME/.composer}:/tmp composer'
# https://github.com/wagoodman/dive
alias dive='docker run -ti --rm -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive'
# https://github.com/phpstan/phpstan/pkgs/container/phpstan
alias phpstan='docker run -it --rm --init -v $PWD:/app ghcr.io/phpstan/phpstan'
# https://hub.docker.com/r/oskarstark/php-cs-fixer-ga
alias php-cs-fixer='docker run -it --rm --init -v $PWD:/app -w /app --entrypoint='' oskarstark/php-cs-fixer-ga php-cs-fixer'
# https://hub.docker.com/r/instrumentisto/nmap
alias nmap='docker run -it --rm instrumentisto/nmap'
# https://hub.docker.com/r/curlimages/curl
alias ccurl='docker run -it --rm curlimages/curl'
alias net.stats='lsof -Pni'
alias dns.flush='sudo killall -HUP mDNSResponder'
function up() {
brew upgrade
}
function rgit() { find . -name '.git' -execdir bash -c "pwd && git $@" \; }
# https://docs.gitignore.io/install/command-line
function gi() { curl -sLw "\n" https://www.toptal.com/developers/gitignore/api/$@ ;}
# https://stackoverflow.com/a/24657630
function jver(){
if [ -n "$1" ]; then
unset JAVA_HOME; export JAVA_HOME=$(/usr/libexec/java_home -v $1)
else
/usr/libexec/java_home -V
fi
java --version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment