Created
March 5, 2026 06:04
-
-
Save tusharhqq/9693d5adf2666f1b6c9d287e4c260be4 to your computer and use it in GitHub Desktop.
zshrc for mac
This file contains hidden or 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
| ########## | |
| # HISTORY | |
| ########## | |
| typeset -U PATH | |
| HISTFILE=$HOME/.zsh_history | |
| HISTSIZE=50000 | |
| SAVEHIST=50000 | |
| setopt INC_APPEND_HISTORY | |
| setopt EXTENDED_HISTORY | |
| setopt HIST_EXPIRE_DUPS_FIRST | |
| setopt HIST_IGNORE_DUPS | |
| setopt HIST_IGNORE_ALL_DUPS | |
| setopt HIST_FIND_NO_DUPS | |
| setopt HIST_IGNORE_SPACE | |
| setopt HIST_SAVE_NO_DUPS | |
| setopt SHARE_HISTORY | |
| unsetopt HIST_VERIFY | |
| ############# | |
| # COMPLETION | |
| ############# | |
| if type brew &>/dev/null; then | |
| FPATH=/usr/local/share/zsh/site-functions:$FPATH | |
| fi | |
| autoload -Uz compinit | |
| for dump in ~/.zcompdump(N.mh+24); do | |
| compinit | |
| done | |
| compinit -C | |
| unsetopt flowcontrol | |
| setopt auto_menu | |
| setopt complete_in_word | |
| setopt always_to_end | |
| setopt auto_pushd | |
| zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' | |
| ############### | |
| # KEY BINDINGS | |
| ############### | |
| bindkey -v | |
| bindkey "^[[91;5u" vi-cmd-mode | |
| autoload -U edit-command-line | |
| zle -N edit-command-line | |
| bindkey -M vicmd v edit-command-line | |
| bindkey "^Q" push-input | |
| bindkey "\eOA" up-line-or-history | |
| bindkey "\eOB" down-line-or-history | |
| bindkey "\eOC" forward-char | |
| bindkey "\eOD" backward-char | |
| bindkey '^R' history-incremental-search-backward | |
| bindkey '^S' history-incremental-search-forward | |
| bindkey '^Y' accept-search | |
| bindkey '^[[A' history-search-backward | |
| bindkey '^[[B' history-search-forward | |
| bindkey '^P' history-search-backward | |
| bindkey '^N' history-search-forward | |
| bindkey '^?' backward-delete-char | |
| bindkey '^[[3~' delete-char | |
| bindkey '^A' beginning-of-line | |
| bindkey '^E' end-of-line | |
| bindkey -s '^F' "tmux-sessionizer\n" | |
| ######### | |
| # Aliases | |
| ######### | |
| case $OSTYPE in | |
| darwin*) | |
| local aliasfile="${HOME}/.zsh.d/aliases.Darwin.sh" | |
| [[ -e ${aliasfile} ]] && source ${aliasfile} | |
| ;; | |
| esac | |
| alias lls='ls -lh --sort=size --reverse' | |
| alias llt='ls -lrt' | |
| alias bear='clear && echo "Clear as a bear!"' | |
| alias history='history 1' | |
| alias hs='history | grep ' | |
| alias rsyncssh='rsync -Pr --rsh=ssh' | |
| alias ez='vi ~/.zshrc' | |
| alias sz='source ~/.zshrc' | |
| alias ea='nvim $(fzf --preview="cat {}")' | |
| alias gst='git status' | |
| alias gaa='git add -A' | |
| alias ga='git add' | |
| alias gc='git commit' | |
| alias gcm='git checkout trunk || git checkout main || git checkout master' | |
| alias gd='git diff' | |
| alias gdc='git diff --cached' | |
| alias co='git checkout' | |
| fo() { | |
| git branch --no-color --sort=-committerdate --format='%(refname:short)' | fzf --header 'git checkout' | xargs git checkout | |
| } | |
| po() { | |
| gh pr list --author "@me" | fzf --header 'checkout PR' | awk '{print $(NF-5)}' | xargs git checkout | |
| } | |
| alias up='git push' | |
| alias upf='git push --force' | |
| alias pu='git pull' | |
| alias pur='git pull --rebase' | |
| alias fe='git fetch' | |
| alias re='git rebase' | |
| alias lr='git l -30' | |
| alias cdr='cd $(git rev-parse --show-toplevel)' | |
| alias hs='git rev-parse --short HEAD' | |
| alias hm='git log --format=%B -n 1 HEAD' | |
| alias tma='tmux attach -t' | |
| alias tmn='tmux new -s' | |
| alias tmm='tmux new -s main' | |
| alias -g ...='../..' | |
| alias -g ....='../../..' | |
| alias -g .....='../../../..' | |
| alias got='go test ./...' | |
| alias k='kubectl' | |
| alias -g withcolors="| sed '/PASS/s//$(printf "\033[32mPASS\033[0m")/' | sed '/FAIL/s//$(printf "\033[31mFAIL\033[0m")/'" | |
| alias zedn='/Applications/Zed\ Nightly.app/Contents/MacOS/cli' | |
| alias r='cargo run' | |
| alias rr='cargo run --release' | |
| ########## | |
| # FUNCTIONS | |
| ########## | |
| mkdircd() { | |
| mkdir -p $1 && cd $1 | |
| } | |
| spinner() { | |
| while | |
| do | |
| for i in "-" "\\" "|" "/" | |
| do | |
| echo -n " $i \r\r" | |
| sleep .1 | |
| done | |
| done | |
| } | |
| pr() { | |
| if type gh &> /dev/null; then | |
| gh pr view -w | |
| else | |
| echo "gh is not installed" | |
| fi | |
| } | |
| ######### | |
| # PROMPT | |
| ######### | |
| setopt prompt_subst | |
| git_prompt_info() { | |
| local dirstatus=" OK" | |
| local dirty="%{$fg_bold[red]%} X%{$reset_color%}" | |
| if [[ ! -z $(git status --porcelain 2> /dev/null | tail -n1) ]]; then | |
| dirstatus=$dirty | |
| fi | |
| ref=$(git symbolic-ref HEAD 2> /dev/null) || \ | |
| ref=$(git rev-parse --short HEAD 2> /dev/null) || return | |
| echo " %{$fg_bold[green]%}${ref#refs/heads/}$dirstatus%{$reset_color%}" | |
| } | |
| local dir_info_color="%B" | |
| local dir_info_color_file="${HOME}/.zsh.d/dir_info_color" | |
| if [ -r ${dir_info_color_file} ]; then | |
| source ${dir_info_color_file} | |
| fi | |
| local dir_info="%{$dir_info_color%}%(5~|%-1~/.../%2~|%4~)%{$reset_color%}" | |
| local promptnormal="φ %{$reset_color%}" | |
| PROMPT='$(git_prompt_info)${dir_info} $promptnormal' | |
| ######## | |
| # ENV | |
| ######## | |
| export COLOR_PROFILE="dark" | |
| case $OSTYPE in | |
| darwin*) | |
| local envfile="${HOME}/.zsh.d/env.Darwin.sh" | |
| [[ -e ${envfile} ]] && source ${envfile} | |
| ;; | |
| esac | |
| export LSCOLORS="Gxfxcxdxbxegedabagacad" | |
| export KEYTIMEOUT=1 | |
| export PATH="$HOME/neovim/bin:$PATH" | |
| if type nvim &> /dev/null; then | |
| alias vi="nvim" | |
| export EDITOR="nvim" | |
| export PSQL_EDITOR="nvim -c"set filetype=sql"" | |
| export GIT_EDITOR="nvim" | |
| else | |
| export EDITOR='vi' | |
| export PSQL_EDITOR='vi -c"set filetype=sql"' | |
| export GIT_EDITOR='vi' | |
| fi | |
| # NOTE: | |
| # This path has been intentionally modified for security/privacy reasons | |
| # before sharing this configuration publicly. | |
| if [[ -e "$HOME/code/lua-language-server/3rd/luamake/luamake" ]]; then | |
| alias luamake="$HOME/code/lua-language-server/3rd/luamake/luamake" | |
| fi | |
| if type fzf &> /dev/null && type rg &> /dev/null; then | |
| export FZF_DEFAULT_COMMAND='rg --files --hidden --follow --glob "!.git/*" --glob "!vendor/*"' | |
| export FZF_CTRL_T_COMMAND='rg --files --hidden --follow --glob "!.git/*" --glob "!vendor/*"' | |
| export FZF_ALT_C_COMMAND="$FZF_DEFAULT_COMMAND" | |
| fi | |
| if type direnv &> /dev/null; then | |
| eval "$(direnv hook zsh)" | |
| fi | |
| export PATH=$PATH:$HOME/go/bin | |
| [ -s "$HOME/.bun/_bun" ] && source "$HOME/.bun/_bun" | |
| export BUN_INSTALL="$HOME/.bun" | |
| export PATH="$BUN_INSTALL/bin:$PATH" | |
| [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
| PQ_LIB_DIR="/opt/homebrew/opt/libpq/lib" | |
| export PATH="/opt/homebrew/opt/libpq/bin:$PATH" | |
| [ -s "$HOME/.config/envman/load.sh" ] && source "$HOME/.config/envman/load.sh" | |
| export JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home" | |
| export PATH="$JAVA_HOME/bin:$PATH" | |
| export ANDROID_HOME=$HOME/Library/Android/sdk | |
| export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH | |
| export PNPM_HOME="$HOME/Library/pnpm" | |
| case ":$PATH:" in | |
| *":$PNPM_HOME:"*) ;; | |
| *) export PATH="$PNPM_HOME:$PATH" ;; | |
| esac | |
| export PATH=$PATH:/opt/homebrew/bin | |
| export GPG_TTY=$(tty) | |
| export PATH="$HOME/.codeium/windsurf/bin:$PATH" | |
| export PATH="/opt/homebrew/opt/lua@5.1/bin:$PATH" | |
| export PATH="/opt/homebrew/Cellar/sevenzip/24.09/bin:$PATH" | |
| alias c="open $1 -a \"Cursor\"" | |
| alias v="open $1 -a \"Visual Studio Code\"" | |
| if command -v rbenv >/dev/null; then | |
| eval "$(rbenv init - --no-rehash zsh)" | |
| fi | |
| export PATH="$HOME/.opencode/bin:$PATH" | |
| fpath=($HOME/.docker/completions $fpath) | |
| autoload -U +X bashcompinit && bashcompinit | |
| complete -o nospace -C /opt/homebrew/bin/terraform terraform | |
| source <(COMPLETE=zsh jj) | |
| alias g++="/opt/homebrew/bin/g++-15" | |
| alias clang+++="clang++ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1" | |
| export PATH="$HOME/.antigravity/antigravity/bin:$PATH" | |
| [[ ! -r "$HOME/.opam/opam-init/init.zsh" ]] || source "$HOME/.opam/opam-init/init.zsh" > /dev/null 2> /dev/null | |
| export PATH="/opt/homebrew/opt/llvm/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment