Skip to content

Instantly share code, notes, and snippets.

@larzconwell
Created January 15, 2013 03:49
Show Gist options
  • Save larzconwell/4535894 to your computer and use it in GitHub Desktop.
Save larzconwell/4535894 to your computer and use it in GitHub Desktop.
# Display prompt
#PS1='%~:%# '
setopt prompt_subst
autoload colors
autoload -Uz vcs_info
colors
# Set colors for easier reading
for COLOR in RED GREEN YELLOW BLUE WHITE BLACK CYAN; do
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
done
PR_RESET="%{${PR_WHITE}%}"
PR_BRIGHT_RESET="%{${PR_BRIGHT_WHITE}%}"
# Set formats
# %b - branchname
# %u - unstagedstr (see below)
# %c - stangedstr (see below)
# %a - action (e.g. rebase-i)
# %R - repository path
# %S - path in the repository
FMT_BRANCH="${PR_RESET}${PR_CYAN}[%b%u%c]${PR_RESET}" # e.g. [master¹²]
FMT_ACTION="${PR_RESET}${PR_GREEN}(%a)${PR_RESET}" # e.g. (rebase-i)
FMT_PATH="%R/%S" # e.g. ~/repo/subdir
# check-for-changes can be really slow.
# you should disable it, if you work with large repositories
# zstyle ':vcs_info:*:prompt:*' check-for-changes true
# zstyle ':vcs_info:*:prompt:*' unstagedstr "¹" # display ¹ if there are unstaged changes
# zstyle ':vcs_info:*:prompt:*' stagedstr "²" # display ² if there are staged changes
#
zstyle ':vcs_info:*:prompt:*' actionformats "${FMT_BRANCH}${FMT_ACTION}" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' formats "${FMT_BRANCH}" "${FMT_PATH}"
zstyle ':vcs_info:*:prompt:*' nvcsformats "" "%~"
precmd() { vcs_info 'prompt' }
lprompt() {
local git='$vcs_info_msg_0_'
local cwd="%1~" # Removing the 1 from %1~ will show full path
#PROMPT="${PR_BRIGHT_RESET}${cwd}${git}${PR_BRIGHT_RESET}%# ${PR_RESET}"
PROMPT="%#:${cwd}${git} ⵗ "
}
rprompt() {
local cwd="%w %T" # Adding 1 to %~ will show short path
# RPROMPT="${PR_RESET}(${cwd})${PR_RESET}"
RPROMPT="(${cwd})"
}
lprompt
rprompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment