184 lines
9.2 KiB
Bash
184 lines
9.2 KiB
Bash
if [[ -o 'aliases' ]]; then
|
|
'builtin' 'unsetopt' 'aliases'
|
|
local p9k_classic_restore_aliases=1
|
|
else
|
|
local p9k_classic_restore_aliases=0
|
|
fi
|
|
|
|
() {
|
|
emulate -L zsh
|
|
setopt no_unset
|
|
|
|
# The list of segments shown on the left. Fill it with the most important segments.
|
|
typeset -ga POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
|
|
# =========================[ Line #1 ]=========================
|
|
dir # current directory
|
|
vcs
|
|
# =========================[ Line #2 ]=========================
|
|
newline
|
|
prompt_char
|
|
)
|
|
|
|
# The list of segments shown on the right. Fill it with less important segments.
|
|
# Right prompt on the last prompt line (where you are typing your commands) gets
|
|
# automatically hidden when the input line reaches it. Right prompt above the
|
|
# last prompt line gets hidden if it would overlap with left prompt.
|
|
typeset -ga POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
|
|
# =========================[ Line #1 ]=========================
|
|
background_jobs # presence of background jobs
|
|
root_indicator
|
|
context
|
|
# =========================[ Line #2 ]=========================
|
|
newline
|
|
status # exit code of the last command
|
|
#public_ip # public IP address
|
|
command_execution_time
|
|
time # current time
|
|
|
|
)
|
|
|
|
typeset -g POWERLEVEL9K_MODE=powerline
|
|
typeset -g POWERLEVEL9K_BACKGROUND= # transparent background
|
|
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace
|
|
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space
|
|
typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol
|
|
typeset -g POWERLEVEL9K_VISUAL_IDENTIFIER_EXPANSION= # disable segment icons
|
|
# Magenta prompt symbol if the last command succeeded.
|
|
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=yellow
|
|
# Red prompt symbol if the last command failed.
|
|
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=red
|
|
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='> '
|
|
|
|
# Blue current directory.
|
|
typeset -g POWERLEVEL9K_DIR_FOREGROUND=blue
|
|
|
|
# Make Git prompt grey in all states. Also make stale prompts appear indistinguishable from
|
|
# fresh ones. This is unlikely to be desired by anyone but that's how Pure does it.
|
|
#typeset -g POWERLEVEL9K_VCS_FOREGROUND=242
|
|
typeset -g POWERLEVEL9K_VCS_FOREGROUND=yellow
|
|
|
|
# Show previous command duration only if it's >= 5s.
|
|
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5
|
|
# Don't show fractional seconds. Thus, 7s rather than 7.3s.
|
|
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
|
|
# Duration format: 1d 2h 3m 4s.
|
|
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
|
|
# Yellow previous command duration.
|
|
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=yellow
|
|
|
|
# Git status: feature:master#tag ⇣42⇡42 *42 merge ~42 +42 !42 ?42.
|
|
# We are using parameters defined by the gitstatus plugin. See reference:
|
|
# https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
|
|
local vcs=''
|
|
# 'feature' or '@72f5c8a' if not on a branch.
|
|
vcs+='%76F${${VCS_STATUS_LOCAL_BRANCH//\%/%%}:-%f@%76F${VCS_STATUS_COMMIT[1,8]}}'
|
|
# ':master' if the tracking branch name differs from local branch.
|
|
vcs+='${${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH}:+%f:%76F${VCS_STATUS_REMOTE_BRANCH//\%/%%}}'
|
|
# '#tag' if on a tag.
|
|
vcs+='${VCS_STATUS_TAG:+%f#%76F${VCS_STATUS_TAG//\%/%%}}'
|
|
# ⇣42 if behind the remote.
|
|
vcs+='${${VCS_STATUS_COMMITS_BEHIND:#0}:+ %76F↓${VCS_STATUS_COMMITS_BEHIND}}'
|
|
# ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
|
|
# If you want '⇣42 ⇡42' instead, replace '${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }' with ' '.
|
|
vcs+='${${VCS_STATUS_COMMITS_AHEAD:#0}:+${${(M)VCS_STATUS_COMMITS_BEHIND:#0}:+ }%76F↑${VCS_STATUS_COMMITS_AHEAD}}'
|
|
# *42 if have stashes.
|
|
vcs+='${${VCS_STATUS_STASHES:#0}:+ %76F*${VCS_STATUS_STASHES}}'
|
|
# 'merge' if the repo is in an unusual state.
|
|
vcs+='${VCS_STATUS_ACTION:+ %196F${VCS_STATUS_ACTION//\%/%%}}'
|
|
# ~42 if have merge conflicts.
|
|
vcs+='${${VCS_STATUS_NUM_CONFLICTED:#0}:+ %196F~${VCS_STATUS_NUM_CONFLICTED}}'
|
|
# +42 if have staged changes.
|
|
vcs+='${${VCS_STATUS_NUM_STAGED:#0}:+ %11F+${VCS_STATUS_NUM_STAGED}}'
|
|
# !42 if have unstaged changes.
|
|
vcs+='${${VCS_STATUS_NUM_UNSTAGED:#0}:+ %11F!${VCS_STATUS_NUM_UNSTAGED}}'
|
|
# ?42 if have untracked files.
|
|
vcs+='${${VCS_STATUS_NUM_UNTRACKED:#0}:+ %12F?${VCS_STATUS_NUM_UNTRACKED}}'
|
|
# If P9K_CONTENT is not empty, leave it unchanged. It's either "loading" or from vcs_info.
|
|
vcs="\${P9K_CONTENT:-$vcs}"
|
|
|
|
# Disable the default Git status formatting.
|
|
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
|
|
# Install our own Git status formatter.
|
|
typeset -g POWERLEVEL9K_VCS_{CLEAN,UNTRACKED,MODIFIED}_CONTENT_EXPANSION=$vcs
|
|
# When Git status is being refreshed asynchronously, display the last known repo status in grey.
|
|
typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION=${${vcs//\%f}//\%<->F}
|
|
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=244
|
|
# Enable counters for staged, unstaged, etc.
|
|
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
|
|
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76
|
|
|
|
# Show status of repositories of these types. You can add svn and/or hg if you are
|
|
# using them. If you do, your prompt may become slow even when your current directory
|
|
# isn't in an svn or hg reposotiry.
|
|
typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
|
|
|
|
# These settings are used for respositories other than Git or when gitstatusd fails and
|
|
# Powerlevel10k has to fall back to using vcs_info.
|
|
typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76
|
|
typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=11
|
|
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76
|
|
typeset -g POWERLEVEL9K_VCS_REMOTE_BRANCH_ICON=':'
|
|
typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@'
|
|
typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='↓'
|
|
typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='↑'
|
|
typeset -g POWERLEVEL9K_VCS_STASH_ICON='*'
|
|
typeset -g POWERLEVEL9K_VCS_TAG_ICON=$'%{\b#%}'
|
|
typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON=$'%{\b?%}'
|
|
typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON=$'%{\b!%}'
|
|
typeset -g POWERLEVEL9K_VCS_STAGED_ICON=$'%{\b+%}'
|
|
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=
|
|
|
|
typeset -g POWERLEVEL9K_STATUS_OK=true
|
|
|
|
# Add an empty line before each prompt.
|
|
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
|
|
# Add a space between the prompt and the cursor.
|
|
typeset -g POWERLEVEL9K_LEFT_SEGMENT_END_SEPARATOR=''
|
|
# Align the first lines of the left and right prompt rather than the last lines.
|
|
typeset -g POWERLEVEL9K_RPROMPT_ON_NEWLINE=false
|
|
# Don't show the trailing segment separator on left prompt lines without any segments.
|
|
typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
|
|
# Connect left prompt lines with these symbols.
|
|
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='┌['
|
|
typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX='├['
|
|
typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX='└['
|
|
# Connect right prompt lines with these symbols.
|
|
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX=']┐'
|
|
typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX=']┤'
|
|
typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX=']┘'
|
|
|
|
# Enable special styling for non-writable directories.
|
|
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true
|
|
# If set to true, embed a hyperlink into the directory. Useful for quickly
|
|
# opening a directory in the file manager simply by clicking the link.
|
|
# Can also be handy when the directory is shortened, as it allows you to see
|
|
# the full directory that was used in previous commands.
|
|
typeset -g POWERLEVEL9K_DIR_HYPERLINK=true
|
|
|
|
# Enable counters for staged, unstaged, etc. in git prompt.
|
|
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
|
|
|
|
# Show execution time of the last command if takes longer than this many seconds.
|
|
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=5
|
|
# Show this many fractional digits. Zero means round to seconds.
|
|
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
|
|
|
|
# Context format: user@host.
|
|
typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m'
|
|
# Don't show context unless running with privileges on via SSH.
|
|
typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_CONTENT_EXPANSION=
|
|
typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_VISUAL_IDENTIFIER_EXPANSION=
|
|
typeset -g POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
|
|
|
# Format for the current time: 09:51:02. See `man 3 strftime`.
|
|
typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}'
|
|
# If set to true, time will update when you hit enter. This way prompts for the past
|
|
# commands will contain the start times of their commands as opposed to the default
|
|
# behavior where they contain the end times of their preceding commands.
|
|
typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=true
|
|
typeset -g POWERLEVEL9K_TIME_FOREGROUND=130
|
|
}
|
|
|
|
(( ! p9k_classic_restore_aliases )) || setopt aliases
|
|
'builtin' 'unset' 'p9k_classic_restore_aliases'
|