Last active
March 30, 2023 16:16
-
-
Save TravisBernard/98669fcefbca224cabafd72c4fba4483 to your computer and use it in GitHub Desktop.
Git Prompt for ZSH
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
#### | |
# Some of my favorite things | |
#### | |
alias g="git" | |
alias app="code ~/Development/app" | |
#### | |
# GIT PROMPT | |
# adapted from: https://www.themoderncoder.com/add-git-branch-information-to-your-zsh-prompt/ | |
# with additions from: https://salferrarello.com/zsh-git-status-prompt/ | |
#### | |
# Load version control information | |
autoload -Uz vcs_info | |
precmd() { vcs_info } | |
# Format the vcs_info_msg_0_ variable | |
# Will turn red if there are unstaged files and yellow if there are modified files - like git status | |
# Will trim branch names to 25 characters (%25.25b) | |
zstyle ':vcs_info:*' check-for-changes true | |
zstyle ':vcs_info:*' unstagedstr '%F{red}!' | |
zstyle ':vcs_info:*' stagedstr '%F{yellow}+' | |
zstyle ':vcs_info:git:*' formats '%c%u%25.25b' | |
# Set up the prompt (with git branch name) | |
setopt PROMPT_SUBST | |
PROMPT='${PWD/#$HOME/~} %# ' | |
RPROMPT='%F{green}${vcs_info_msg_0_}%f' | |
#### | |
# Set up context aware history similar to oh-my-zsh | |
# see https://unix.stackexchange.com/questions/97843/how-can-i-search-history-with-text-already-entered-at-the-prompt-in-zsh | |
#### | |
autoload -U history-search-end | |
zle -N history-beginning-search-backward-end history-search-end | |
zle -N history-beginning-search-forward-end history-search-end | |
bindkey "^[[A" history-beginning-search-backward-end | |
bindkey "^[[B" history-beginning-search-forward-end | |
source /Users/travisbernard/.docker/init-zsh.sh || true # Added by Docker Desktop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment