Skip to content

Instantly share code, notes, and snippets.

@carpusherw
Last active March 14, 2024 06:09
Show Gist options
  • Save carpusherw/8349b31d80d55c42de86d2ffc3b32532 to your computer and use it in GitHub Desktop.
Save carpusherw/8349b31d80d55c42de86d2ffc3b32532 to your computer and use it in GitHub Desktop.
zsh

.zshrc

DEPRECATED Moved to https://github.com/carpusherw/dotfiles

alias g="git"
autoload -Uz compinit && compinit

alias tf="terraform"
complete -F _minimal tf

alias sz="source ~/.zshrc"
alias update="brew update && brew upgrade && brew cleanup && brew doctor"


# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }

# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '%b'

# Show branch name if and only if it exists
branch_name() {
    [ -z "$vcs_info_msg_0_" ] || echo "[$vcs_info_msg_0_]"
}

# Get PR number with gh
gh_pr() {
    number=$(gh pr status --json number --jq ".currentBranch.number" 2> /dev/null)
    [ -z "$number" ] || echo "#$number"
}

# Set up the prompt
setopt PROMPT_SUBST
PROMPT='%F{blue}[%n@ %1~]%F{green}$(branch_name)%F{white}%F{yellow}$(gh_pr)%F{white}$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment