Почистил и ускорил zsh
This commit is contained in:
parent
74e201e92c
commit
b3f074faff
6 changed files with 279 additions and 2396 deletions
|
@ -1,431 +0,0 @@
|
|||
# Powerlevel10k configuration file restricted to 8-color ASCII. Produced by
|
||||
# running `p10k configure` while at 1387763f2719661dc7e43e86a5bfd24cc357d6a0
|
||||
# and then editing ~/.p10k.zsh. Configuration wizard header follows.
|
||||
#
|
||||
# Generated by Powerlevel10k configuration wizard on 2019-11-12 at 08:45 CET.
|
||||
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 11792.
|
||||
# Wizard options: compatible, lean, 2 lines, disconnected, no frame, sparse, concise.
|
||||
# Type `p10k configure` to generate another config.
|
||||
|
||||
# Temporarily change options.
|
||||
'builtin' 'local' '-a' 'p10k_config_opts'
|
||||
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
|
||||
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
|
||||
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
|
||||
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
|
||||
|
||||
() {
|
||||
emulate -L zsh
|
||||
setopt no_unset extended_glob
|
||||
zmodload zsh/langinfo
|
||||
if [[ ${langinfo[CODESET]:-} != (utf|UTF)(-|)8 ]]; then
|
||||
local LC_ALL=${${(@M)$(locale -a):#*.(utf|UTF)(-|)8}[1]:-en_US.UTF-8}
|
||||
fi
|
||||
|
||||
# Unset all configuration options. This allows you to apply configiguration changes without
|
||||
# restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
|
||||
unset -m 'POWERLEVEL9K_*'
|
||||
|
||||
# The list of segments shown on the left. Fill it with the most important segments.
|
||||
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
|
||||
# =========================[ Line #1 ]=========================
|
||||
dir # current directory
|
||||
vcs # git status
|
||||
# =========================[ Line #2 ]=========================
|
||||
newline
|
||||
prompt_char # prompt symbol
|
||||
)
|
||||
|
||||
# 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 -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
|
||||
# =========================[ Line #1 ]=========================
|
||||
status # exit code of the last command
|
||||
command_execution_time # duration of the last command
|
||||
background_jobs # presence of background jobs
|
||||
context # user@hostname
|
||||
# =========================[ Line #2 ]=========================
|
||||
newline
|
||||
)
|
||||
|
||||
# Basic style options that define the overall look of your prompt. You probably don't want to
|
||||
# change them.
|
||||
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
|
||||
|
||||
# When set to true, icons appear before content on both sides of the prompt. When set
|
||||
# to false, icons go after content. If empty or not set, icons go before content in the left
|
||||
# prompt and after content in the right prompt.
|
||||
#
|
||||
# You can also override it for a specific segment:
|
||||
#
|
||||
# POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false
|
||||
#
|
||||
# Or for a specific segment in specific state:
|
||||
#
|
||||
# POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false
|
||||
typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true
|
||||
|
||||
# Add an empty line before each prompt.
|
||||
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
|
||||
|
||||
# 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=
|
||||
|
||||
# The left end of left prompt.
|
||||
typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
|
||||
# The right end of right prompt.
|
||||
typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL=
|
||||
|
||||
################################[ prompt_char: prompt symbol ]################################
|
||||
# Green prompt symbol if the last command succeeded.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=2
|
||||
# Red prompt symbol if the last command failed.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=1
|
||||
# Default prompt symbol.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='>'
|
||||
# Prompt symbol in command vi mode.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='<'
|
||||
# Prompt symbol in visual vi mode.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
|
||||
# Prompt symbol in overwrite vi mode.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='^'
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
|
||||
|
||||
##################################[ dir: current directory ]##################################
|
||||
# Default current directory color.
|
||||
typeset -g POWERLEVEL9K_DIR_FOREGROUND=4
|
||||
# If directory is too long, shorten some of its segments to the shortest possible unique
|
||||
# prefix. The shortened directory can be tab-completed to the original.
|
||||
typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique
|
||||
# Replace removed segment suffixes with this symbol.
|
||||
typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=
|
||||
# Color of the shortened directory segments.
|
||||
typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=4
|
||||
# Color of the anchor directory segments. Anchor segments are never shortened. The first
|
||||
# segment is always an anchor.
|
||||
typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=4
|
||||
# Display anchor directory segments in bold.
|
||||
typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=false
|
||||
# Don't shorten directories that contain any of these files. They are anchors.
|
||||
local anchor_files=(
|
||||
.bzr
|
||||
.citc
|
||||
.git
|
||||
.hg
|
||||
.node-version
|
||||
.python-version
|
||||
.ruby-version
|
||||
.shorten_folder_marker
|
||||
.svn
|
||||
.terraform
|
||||
CVS
|
||||
Cargo.toml
|
||||
composer.json
|
||||
go.mod
|
||||
package.json
|
||||
)
|
||||
typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
|
||||
# Don't shorten this many last directory segments. They are anchors.
|
||||
typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
|
||||
# Shorten directory if it's longer than this even if there is space for it. The value can
|
||||
# be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty,
|
||||
# directory will be shortened only when prompt doesn't fit or when other parameters demand it
|
||||
# (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below).
|
||||
typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80
|
||||
# When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this
|
||||
# many columns for typing commands.
|
||||
typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40
|
||||
# When `dir` segment is on the last prompt line, try to shorten it enough to leave at least
|
||||
# COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands.
|
||||
typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50
|
||||
|
||||
# Enable special styling for non-writable directories.
|
||||
typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=true
|
||||
# Show this icon when the current directory is not writable. POWERLEVEL9K_DIR_SHOW_WRITABLE
|
||||
# above must be set to true for this parameter to have effect.
|
||||
typeset -g POWERLEVEL9K_DIR_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='X'
|
||||
|
||||
# Custom prefix.
|
||||
# typeset -g POWERLEVEL9K_DIR_PREFIX='%fin '
|
||||
|
||||
# POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons for different directories.
|
||||
# It must be an array with 3 * N elements. Each triplet consists of:
|
||||
#
|
||||
# 1. A pattern against which the current directory is matched. Matching is done with
|
||||
# extended_glob option enabled.
|
||||
# 2. Directory class for the purpose of styling.
|
||||
# 3. Icon.
|
||||
#
|
||||
# Triplets are tried in order. The first triplet whose pattern matches $PWD wins. If there
|
||||
# are no matches, the directory will have no icon.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_DIR_CLASSES=(
|
||||
# '~/work(/*)#' WORK '(╯°□°)╯︵ ┻━┻'
|
||||
# '~(/*)#' HOME '⌂'
|
||||
# '*' DEFAULT '')
|
||||
#
|
||||
# With these settings, the current directory in the prompt may look like this:
|
||||
#
|
||||
# (╯°□°)╯︵ ┻━┻ ~/work/projects/important/urgent
|
||||
#
|
||||
# Or like this:
|
||||
#
|
||||
# ⌂ ~/best/powerlevel10k
|
||||
#
|
||||
# You can also set different colors for directories of different classes. Remember to override
|
||||
# FOREGROUND, SHORTENED_FOREGROUND and ANCHOR_FOREGROUND for every directory class that you wish
|
||||
# to have its own color.
|
||||
#
|
||||
# typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31
|
||||
# typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103
|
||||
# typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39
|
||||
#
|
||||
typeset -g POWERLEVEL9K_DIR_CLASSES=()
|
||||
|
||||
#####################################[ vcs: git status ]######################################
|
||||
# Branch icon.
|
||||
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=
|
||||
POWERLEVEL9K_VCS_BRANCH_ICON=${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}
|
||||
|
||||
# Untracked files icon. It's really a question mark, your font isn't broken.
|
||||
# Change the value of this parameter to show a different icon.
|
||||
typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
|
||||
POWERLEVEL9K_VCS_UNTRACKED_ICON=${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}
|
||||
|
||||
# Formatter for Git status.
|
||||
#
|
||||
# Example output: master <42 >42 *42 merge ~42 +42 !42 ?42.
|
||||
#
|
||||
# You can edit the function to customize how Git status looks.
|
||||
#
|
||||
# VCS_STATUS_* parameters are set by gitstatus plugin. See reference:
|
||||
# https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
|
||||
function my_git_formatter() {
|
||||
emulate -L zsh
|
||||
|
||||
if [[ -n $P9K_CONTENT ]]; then
|
||||
# If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
|
||||
# gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
|
||||
typeset -g my_git_format=$P9K_CONTENT
|
||||
return
|
||||
fi
|
||||
|
||||
if (( $1 )); then
|
||||
# Styling for up-to-date Git status.
|
||||
local meta='%f' # default foreground
|
||||
local clean='%2F' # green foreground
|
||||
local modified='%3F' # yellow foreground
|
||||
local untracked='%4F' # blue foreground
|
||||
local conflicted='%1F' # red foreground
|
||||
else
|
||||
# Styling for incomplete and stale Git status.
|
||||
local meta='%5F' # magenta foreground
|
||||
local clean='%5F' # magenta foreground
|
||||
local modified='%5F' # magenta foreground
|
||||
local untracked='%5F' # magenta foreground
|
||||
local conflicted='%5F' # magenta foreground
|
||||
fi
|
||||
|
||||
local res
|
||||
local where # branch name, tag or commit
|
||||
if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
|
||||
res+="${clean}${POWERLEVEL9K_VCS_BRANCH_ICON}"
|
||||
where=${(V)VCS_STATUS_LOCAL_BRANCH}
|
||||
elif [[ -n $VCS_STATUS_TAG ]]; then
|
||||
res+="${meta}#"
|
||||
where=${(V)VCS_STATUS_TAG}
|
||||
else
|
||||
res+="${meta}@"
|
||||
where=${VCS_STATUS_COMMIT[1,8]}
|
||||
fi
|
||||
|
||||
# If local branch name or tag is at most 32 characters long, show it in full.
|
||||
# Otherwise show the first 12 … the last 12.
|
||||
(( $#where > 32 )) && where[13,-13]="…"
|
||||
res+="${clean}${where//\%/%%}" # escape %
|
||||
|
||||
# Show tracking branch name if it differs from local branch.
|
||||
if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
|
||||
res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape %
|
||||
fi
|
||||
|
||||
# <42 if behind the remote.
|
||||
(( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}<${VCS_STATUS_COMMITS_BEHIND}"
|
||||
# >42 if ahead of the remote.
|
||||
(( VCS_STATUS_COMMITS_AHEAD )) && res+=" ${clean}⇡${VCS_STATUS_COMMITS_AHEAD}"
|
||||
# *42 if have stashes.
|
||||
(( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}"
|
||||
# 'merge' if the repo is in an unusual state.
|
||||
[[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
|
||||
# ~42 if have merge conflicts.
|
||||
(( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
|
||||
# +42 if have staged changes.
|
||||
(( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
|
||||
# !42 if have unstaged changes.
|
||||
(( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
|
||||
# ?42 if have untracked files. It's really a question mark, your font isn't broken.
|
||||
# See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
|
||||
# Remove the next line if you don't want to see untracked files at all.
|
||||
(( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
|
||||
|
||||
typeset -g my_git_format=$res
|
||||
}
|
||||
functions -M my_git_formatter 2>/dev/null
|
||||
|
||||
# Disable the default Git status formatting.
|
||||
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
|
||||
# Install our own Git status formatter.
|
||||
typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
|
||||
typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}'
|
||||
# Enable counters for staged, unstaged, etc.
|
||||
typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
|
||||
|
||||
# Icon color.
|
||||
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=2
|
||||
typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=5
|
||||
# Custom icon.
|
||||
typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION=
|
||||
# Custom prefix.
|
||||
# typeset -g POWERLEVEL9K_VCS_PREFIX='%fon '
|
||||
|
||||
# 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=2
|
||||
typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=2
|
||||
typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=3
|
||||
typeset -g POWERLEVEL9K_VCS_UNSTAGED_ICON='!'
|
||||
typeset -g POWERLEVEL9K_VCS_STAGED_ICON='+'
|
||||
typeset -g POWERLEVEL9K_VCS_STASH_ICON='*'
|
||||
typeset -g POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='<'
|
||||
typeset -g POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='>'
|
||||
typeset -g POWERLEVEL9K_VCS_TAG_ICON='#'
|
||||
typeset -g POWERLEVEL9K_VCS_COMMIT_ICON='@'
|
||||
typeset -g POWERLEVEL9K_VCS_REMOTE_BRANCH_ICON=':'
|
||||
|
||||
##########################[ status: exit code of the last command ]###########################
|
||||
# Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and
|
||||
# style them independently from the regular OK and ERROR state.
|
||||
typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true
|
||||
|
||||
# Status on success. No content, just an icon. No need to show it if prompt_char is enabled as
|
||||
# it will signify success by turning green.
|
||||
typeset -g POWERLEVEL9K_STATUS_OK=false
|
||||
typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=2
|
||||
typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION=''
|
||||
|
||||
# Status when some part of a pipe command fails but the overall exit status is zero. It may look
|
||||
# like this: 1|0.
|
||||
typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true
|
||||
typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=2
|
||||
typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION=''
|
||||
|
||||
# Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as
|
||||
# it will signify error by turning red.
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR=false
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=1
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION=''
|
||||
|
||||
# Status when the last command was terminated by a signal.
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=1
|
||||
# Use terse signal names: "INT" instead of "SIGINT(2)".
|
||||
typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION=''
|
||||
|
||||
# Status when some part of a pipe command fails and the overall exit status is also non-zero.
|
||||
# It may look like this: 1|0.
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=1
|
||||
typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION=''
|
||||
|
||||
###################[ command_execution_time: duration of the last command ]###################
|
||||
# Show duration of the last command if takes longer than this many seconds.
|
||||
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
|
||||
# Show this many fractional digits. Zero means round to seconds.
|
||||
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
|
||||
# Execution time color.
|
||||
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=3
|
||||
# Duration format: 1d 2h 3m 4s.
|
||||
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
|
||||
# Custom icon.
|
||||
typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION=
|
||||
# Custom prefix.
|
||||
# typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook '
|
||||
|
||||
#######################[ background_jobs: presence of background jobs ]#######################
|
||||
# Don't show the number of background jobs.
|
||||
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
|
||||
# Background jobs color.
|
||||
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=2
|
||||
# Icon to show when there are background jobs.
|
||||
typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='bg'
|
||||
|
||||
##################################[ context: user@hostname ]##################################
|
||||
# Default context color.
|
||||
typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=2
|
||||
# Default context format: %n is username, %m is hostname.
|
||||
typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m'
|
||||
|
||||
# Context color when running with privileges.
|
||||
typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=1
|
||||
# Context format when running with privileges: bold user@hostname.
|
||||
typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%n@%m'
|
||||
|
||||
# Don't show context unless running with privileges or in SSH.
|
||||
# Tip: Remove the next line to always show context.
|
||||
typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION=
|
||||
|
||||
# Custom icon.
|
||||
# typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐'
|
||||
# Custom prefix.
|
||||
# typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith '
|
||||
|
||||
# Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
|
||||
# when accepting a command line. Supported values:
|
||||
#
|
||||
# - off: Don't change prompt when accepting a command line.
|
||||
# - always: Trim down prompt when accepting a command line.
|
||||
# - same-dir: Trim down prompt when accepting a command line unless this is the first command
|
||||
# typed after changing current working directory.
|
||||
typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always
|
||||
|
||||
# Instant prompt mode.
|
||||
#
|
||||
# - off: Disable instant prompt. Choose this if you've tried instant prompt and found
|
||||
# it incompatible with your zsh configuration files.
|
||||
# - quiet: Enable instant prompt and don't print warnings when detecting console output
|
||||
# during zsh initialization. Choose this if you've read and understood
|
||||
# https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
|
||||
# - verbose: Enable instant prompt and print a warning when detecting console output during
|
||||
# zsh initialization. Choose this if you've never tried instant prompt, haven't
|
||||
# seen the warning, or if you are unsure what this all means.
|
||||
typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
|
||||
|
||||
# Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
|
||||
# For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
|
||||
# can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you
|
||||
# really need it.
|
||||
typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
|
||||
}
|
||||
|
||||
(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
|
||||
'builtin' 'unset' 'p10k_config_opts'
|
1712
zsh/p10k.zsh
1712
zsh/p10k.zsh
File diff suppressed because it is too large
Load diff
121
zsh/termsupport.zsh
Normal file
121
zsh/termsupport.zsh
Normal file
|
@ -0,0 +1,121 @@
|
|||
function zsh_urlencode() {
|
||||
emulate -L zsh
|
||||
local -a opts
|
||||
zparseopts -D -E -a opts r m P
|
||||
|
||||
local in_str="$@"
|
||||
local url_str=""
|
||||
local spaces_as_plus
|
||||
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
|
||||
local str="$in_str"
|
||||
|
||||
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
|
||||
local encoding=$langinfo[CODESET]
|
||||
|
||||
|
||||
# Use LC_CTYPE=C to process text byte-by-byte
|
||||
local i byte ord LC_ALL=C
|
||||
export LC_ALL
|
||||
local reserved=';/?:@&=+$,'
|
||||
local mark='_.!~*''()-'
|
||||
local dont_escape="[A-Za-z0-9"
|
||||
if [[ -z $opts[(r)-r] ]]; then
|
||||
dont_escape+=$reserved
|
||||
fi
|
||||
# $mark must be last because of the "-"
|
||||
if [[ -z $opts[(r)-m] ]]; then
|
||||
dont_escape+=$mark
|
||||
fi
|
||||
dont_escape+="]"
|
||||
|
||||
# Implemented to use a single printf call and avoid subshells in the loop,
|
||||
# for performance
|
||||
local url_str=""
|
||||
for (( i = 1; i <= ${#str}; ++i )); do
|
||||
byte="$str[i]"
|
||||
if [[ "$byte" =~ "$dont_escape" ]]; then
|
||||
url_str+="$byte"
|
||||
else
|
||||
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
|
||||
url_str+="+"
|
||||
else
|
||||
ord=$(( [##16] #byte ))
|
||||
url_str+="%$ord"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo -E "$url_str"
|
||||
}
|
||||
|
||||
# Runs before showing the prompt
|
||||
function mzc_termsupport_precmd {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||
}
|
||||
|
||||
# Runs before executing the command
|
||||
function mzc_termsupport_preexec {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
|
||||
emulate -L zsh
|
||||
|
||||
# split command into array of arguments
|
||||
local -a cmdargs
|
||||
cmdargs=("${(z)2}")
|
||||
# if running fg, extract the command from the job description
|
||||
if [[ "${cmdargs[1]}" = fg ]]; then
|
||||
# get the job id from the first argument passed to the fg command
|
||||
local job_id jobspec="${cmdargs[2]#%}"
|
||||
# logic based on jobs arguments:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
|
||||
# https://www.zsh.org/mla/users/2007/msg00704.html
|
||||
case "$jobspec" in
|
||||
<->) # %number argument:
|
||||
# use the same <number> passed as an argument
|
||||
job_id=${jobspec} ;;
|
||||
""|%|+) # empty, %% or %+ argument:
|
||||
# use the current job, which appears with a + in $jobstates:
|
||||
# suspended:+:5071=suspended (tty output)
|
||||
job_id=${(k)jobstates[(r)*:+:*]} ;;
|
||||
-) # %- argument:
|
||||
# use the previous job, which appears with a - in $jobstates:
|
||||
# suspended:-:6493=suspended (signal)
|
||||
job_id=${(k)jobstates[(r)*:-:*]} ;;
|
||||
[?]*) # %?string argument:
|
||||
# use $jobtexts to match for a job whose command *contains* <string>
|
||||
job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
|
||||
*) # %string argument:
|
||||
# use $jobtexts to match for a job whose command *starts with* <string>
|
||||
job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
|
||||
esac
|
||||
|
||||
# override preexec function arguments with job command
|
||||
if [[ -n "${jobtexts[$job_id]}" ]]; then
|
||||
1="${jobtexts[$job_id]}"
|
||||
2="${jobtexts[$job_id]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# cmd name only, or if this is sudo or ssh, the next cmd
|
||||
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
||||
local LINE="${2:gs/%/%%}"
|
||||
|
||||
title '$CMD' '%100>...>$LINE%<<'
|
||||
}
|
||||
|
||||
# Emits the control sequence to notify many terminal emulators
|
||||
# of the cwd
|
||||
#
|
||||
# Identifies the directory using a file: URI scheme, including
|
||||
# the host name to disambiguate local vs. remote paths.
|
||||
function mzc_termsupport_cwd {
|
||||
# Percent-encode the host and path names.
|
||||
local URL_HOST URL_PATH
|
||||
URL_HOST="$(zsh_urlencode -P $HOST)" || return 1
|
||||
URL_PATH="$(zsh_urlencode -P $PWD)" || return 1
|
||||
|
||||
# common control sequence (OSC 7) to set current host and path
|
||||
printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}"
|
||||
}
|
||||
|
||||
|
91
zsh/theme.zsh
Normal file
91
zsh/theme.zsh
Normal file
|
@ -0,0 +1,91 @@
|
|||
# Config file for Powerlevel10k with the style of robbyrussell theme from Oh My Zsh.
|
||||
#
|
||||
# Original: https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#robbyrussell.
|
||||
#
|
||||
# Replication of robbyrussell theme is exact. The only observable difference is in
|
||||
# performance. Powerlevel10k prompt is very fast everywhere, even in large Git repositories.
|
||||
#
|
||||
# Usage: Source this file either before or after loading Powerlevel10k.
|
||||
#
|
||||
# source ~/powerlevel10k/config/p10k-robbyrussell.zsh
|
||||
# source ~/powerlevel10k/powerlevel10k.zsh-theme
|
||||
|
||||
# Temporarily change options.
|
||||
'builtin' 'local' '-a' 'p10k_config_opts'
|
||||
[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
|
||||
[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
|
||||
[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
|
||||
'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
|
||||
|
||||
() {
|
||||
emulate -L zsh -o extended_glob
|
||||
|
||||
# Unset all configuration options.
|
||||
unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
|
||||
|
||||
# Zsh >= 5.1 is required.
|
||||
[[ $ZSH_VERSION == (5.<1->*|<6->.*) ]] || return
|
||||
|
||||
# Left prompt segments.
|
||||
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(prompt_char dir vcs)
|
||||
# Right prompt segments.
|
||||
typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
|
||||
|
||||
# Basic style options that define the overall prompt look.
|
||||
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= # no segment icons
|
||||
|
||||
# Green prompt symbol if the last command succeeded.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS}_FOREGROUND=green
|
||||
# Red prompt symbol if the last command failed.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS}_FOREGROUND=red
|
||||
# Prompt symbol: bold arrow.
|
||||
typeset -g POWERLEVEL9K_PROMPT_CHAR_CONTENT_EXPANSION='%B➜ '
|
||||
|
||||
# Cyan current directory.
|
||||
typeset -g POWERLEVEL9K_DIR_FOREGROUND=cyan
|
||||
# Show only the last segment of the current directory.
|
||||
typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_last
|
||||
# Bold directory.
|
||||
typeset -g POWERLEVEL9K_DIR_CONTENT_EXPANSION='%B$P9K_CONTENT'
|
||||
|
||||
# Disable the default Git status formatting.
|
||||
typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
|
||||
# Install our own Git status formatter.
|
||||
# typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
|
||||
# typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter()))+${my_git_format}}'
|
||||
# Grey Git status when loading.
|
||||
typeset -g POWERLEVEL9K_VCS_LOADING_FOREGROUND=246
|
||||
|
||||
# Instant prompt mode.
|
||||
#
|
||||
# - off: Disable instant prompt. Choose this if you've tried instant prompt and found
|
||||
# it incompatible with your zsh configuration files.
|
||||
# - quiet: Enable instant prompt and don't print warnings when detecting console output
|
||||
# during zsh initialization. Choose this if you've read and understood
|
||||
# https://github.com/romkatv/powerlevel10k#instant-prompt.
|
||||
# - verbose: Enable instant prompt and print a warning when detecting console output during
|
||||
# zsh initialization. Choose this if you've never tried instant prompt, haven't
|
||||
# seen the warning, or if you are unsure what this all means.
|
||||
typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
|
||||
|
||||
# Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
|
||||
# For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
|
||||
# can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you
|
||||
# really need it.
|
||||
typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
|
||||
|
||||
# If p10k is already loaded, reload configuration.
|
||||
# This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true.
|
||||
(( ! $+functions[p10k] )) || p10k reload
|
||||
}
|
||||
|
||||
# Tell `p10k configure` which file it should overwrite.
|
||||
typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a}
|
||||
|
||||
(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
|
||||
'builtin' 'unset' 'p10k_config_opts'
|
||||
|
30
zsh/title.zsh
Normal file
30
zsh/title.zsh
Normal file
|
@ -0,0 +1,30 @@
|
|||
function title {
|
||||
emulate -L zsh
|
||||
setopt prompt_subst
|
||||
|
||||
[[ "$EMACS" == *term* ]] && return
|
||||
|
||||
# if $2 is unset use $1 as default
|
||||
# if it is set and empty, leave it as is
|
||||
: ${2=$1}
|
||||
|
||||
case "$TERM" in
|
||||
xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|kitty|wezterm|st*)
|
||||
print -Pn "\e]2;${2:q}\a" # set window name
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
;;
|
||||
screen*|tmux*)
|
||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
||||
;;
|
||||
*)
|
||||
# Try to use terminfo to set the title
|
||||
# If the feature is available set title
|
||||
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
|
||||
echoti tsl
|
||||
print -Pn "$1"
|
||||
echoti fsl
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
290
zsh/zshrc
290
zsh/zshrc
|
@ -10,7 +10,9 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
|
|||
fi
|
||||
|
||||
source ~/.config/zsh/p10k/powerlevel10k.zsh-theme
|
||||
source ~/.config/zsh/p10k.zsh
|
||||
source ~/.config/zsh/conf.d/*.zsh
|
||||
source ~/.config/zsh/termsupport.zsh
|
||||
source ~/.config/zsh/title.zsh
|
||||
|
||||
antigen bundle zsh-users/zsh-syntax-highlighting
|
||||
antigen bundle zsh-users/zsh-history-substring-search
|
||||
|
@ -20,8 +22,7 @@ antigen bundle ael-code/zsh-colored-man-pages
|
|||
antigen theme romkatv/powerlevel10k
|
||||
antigen apply
|
||||
|
||||
# Exports
|
||||
|
||||
# {{{ Exports
|
||||
#export GOPROXY=https://proxy.neonxp.ru
|
||||
export GOPRIVATE=devopar.hippoparking.ru,gitlab.sovcombank.group
|
||||
export EDITOR="nvim"
|
||||
|
@ -36,9 +37,9 @@ export LS_OPTIONS='--color=auto'
|
|||
eval "$(dircolors -b)"
|
||||
|
||||
fpath+="~/.config/zsh/comp"
|
||||
# }}}
|
||||
|
||||
|
||||
# Aliases
|
||||
# {{{ Aliases
|
||||
alias ls='ls $LS_OPTIONS -F'
|
||||
alias l='ls $LS_OPTIONS -F'
|
||||
alias j="sudo journalctl"
|
||||
|
@ -57,13 +58,14 @@ alias gitu='git add . && git commit && git push'
|
|||
alias g=git
|
||||
alias nsh='wl-paste | curl -d @- https://nixshare.ru/upload 2>/dev/null | wl-copy'
|
||||
alias p=python3
|
||||
|
||||
[[ ! -f `which exa` ]] || alias ls="exa" && alias ll="exa -l"
|
||||
# }}}
|
||||
|
||||
# Functions
|
||||
# {{{ Functions
|
||||
function tk() { mkdir -p $1; cd $1; }
|
||||
# }}}
|
||||
|
||||
## Options section
|
||||
# {{{ Options section
|
||||
setopt correct # Auto correct mistakes
|
||||
setopt extendedglob # Extended globbing. Allows using regular expressions with *
|
||||
setopt nocaseglob # Case insensitive globbing
|
||||
|
@ -100,278 +102,60 @@ HISTSIZE=100000
|
|||
SAVEHIST=100000
|
||||
WORDCHARS=${WORDCHARS//\/[&.;]}
|
||||
|
||||
|
||||
autoload -U compinit colors zcalc
|
||||
compinit -d
|
||||
|
||||
# Runs before showing the prompt
|
||||
function mzc_termsupport_precmd {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
|
||||
}
|
||||
|
||||
# Runs before executing the command
|
||||
function mzc_termsupport_preexec {
|
||||
[[ "${DISABLE_AUTO_TITLE:-}" == true ]] && return
|
||||
|
||||
emulate -L zsh
|
||||
|
||||
# split command into array of arguments
|
||||
local -a cmdargs
|
||||
cmdargs=("${(z)2}")
|
||||
# if running fg, extract the command from the job description
|
||||
if [[ "${cmdargs[1]}" = fg ]]; then
|
||||
# get the job id from the first argument passed to the fg command
|
||||
local job_id jobspec="${cmdargs[2]#%}"
|
||||
# logic based on jobs arguments:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Jobs-_0026-Signals.html#Jobs
|
||||
# https://www.zsh.org/mla/users/2007/msg00704.html
|
||||
case "$jobspec" in
|
||||
<->) # %number argument:
|
||||
# use the same <number> passed as an argument
|
||||
job_id=${jobspec} ;;
|
||||
""|%|+) # empty, %% or %+ argument:
|
||||
# use the current job, which appears with a + in $jobstates:
|
||||
# suspended:+:5071=suspended (tty output)
|
||||
job_id=${(k)jobstates[(r)*:+:*]} ;;
|
||||
-) # %- argument:
|
||||
# use the previous job, which appears with a - in $jobstates:
|
||||
# suspended:-:6493=suspended (signal)
|
||||
job_id=${(k)jobstates[(r)*:-:*]} ;;
|
||||
[?]*) # %?string argument:
|
||||
# use $jobtexts to match for a job whose command *contains* <string>
|
||||
job_id=${(k)jobtexts[(r)*${(Q)jobspec}*]} ;;
|
||||
*) # %string argument:
|
||||
# use $jobtexts to match for a job whose command *starts with* <string>
|
||||
job_id=${(k)jobtexts[(r)${(Q)jobspec}*]} ;;
|
||||
esac
|
||||
|
||||
# override preexec function arguments with job command
|
||||
if [[ -n "${jobtexts[$job_id]}" ]]; then
|
||||
1="${jobtexts[$job_id]}"
|
||||
2="${jobtexts[$job_id]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# cmd name only, or if this is sudo or ssh, the next cmd
|
||||
local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%}
|
||||
local LINE="${2:gs/%/%%}"
|
||||
|
||||
title '$CMD' '%100>...>$LINE%<<'
|
||||
}
|
||||
|
||||
# Emits the control sequence to notify many terminal emulators
|
||||
# of the cwd
|
||||
#
|
||||
# Identifies the directory using a file: URI scheme, including
|
||||
# the host name to disambiguate local vs. remote paths.
|
||||
function mzc_termsupport_cwd {
|
||||
# Percent-encode the host and path names.
|
||||
local URL_HOST URL_PATH
|
||||
URL_HOST="$(zsh_urlencode -P $HOST)" || return 1
|
||||
URL_PATH="$(zsh_urlencode -P $PWD)" || return 1
|
||||
|
||||
# common control sequence (OSC 7) to set current host and path
|
||||
printf "\e]7;%s\a" "file://${URL_HOST}${URL_PATH}"
|
||||
}
|
||||
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook precmd mzc_termsupport_precmd
|
||||
add-zsh-hook preexec mzc_termsupport_preexec
|
||||
# Use a precmd hook instead of a chpwd hook to avoid contaminating output
|
||||
# i.e. when a script or function changes directory without `cd -q`, chpwd
|
||||
# will be called the output may be swallowed by the script or function.
|
||||
add-zsh-hook precmd mzc_termsupport_cwd
|
||||
|
||||
source ~/.config/zsh/conf.d/*.zsh
|
||||
|
||||
colors
|
||||
|
||||
|
||||
## Plugins section: Enable fish style features
|
||||
# Use syntax highlighting
|
||||
#source ${HOME}/.zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
# Use history substring search
|
||||
#source ${HOME}/.zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
|
||||
# bind UP and DOWN arrow keys to history substring search
|
||||
zmodload zsh/terminfo
|
||||
# }}}
|
||||
|
||||
# {{{ Binds
|
||||
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
||||
bindkey "$terminfo[kcud1]" history-substring-search-down
|
||||
bindkey "^[[A" history-substring-search-up
|
||||
bindkey "^[[B" history-substring-search-down
|
||||
|
||||
bindkey -e
|
||||
bindkey "^[[7~" beginning-of-line # Home key
|
||||
bindkey "^[[H" beginning-of-line # Home key
|
||||
bindkey "^[[7~" beginning-of-line # Home key
|
||||
bindkey "^[[H" beginning-of-line # Home key
|
||||
if [[ "${terminfo[khome]}" != "" ]]; then
|
||||
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
|
||||
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning
|
||||
fi
|
||||
bindkey "^[[8~" end-of-line # End key
|
||||
bindkey "^[[F" end-of-line # End key
|
||||
bindkey "^[[8~" end-of-line # End key
|
||||
bindkey "^[[F" end-of-line # End key
|
||||
if [[ "${terminfo[kend]}" != "" ]]; then
|
||||
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
|
||||
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
|
||||
fi
|
||||
bindkey "^[[2~" overwrite-mode # Insert key
|
||||
bindkey "^[[3~" delete-char # Delete key
|
||||
bindkey "^[[C" forward-char # Right key
|
||||
bindkey "^[[D" backward-char # Left key
|
||||
bindkey "^[[5~" history-beginning-search-backward # Page up key
|
||||
bindkey "^[[6~" history-beginning-search-forward # Page down key
|
||||
bindkey "^[[2~" overwrite-mode # Insert key
|
||||
bindkey "^[[3~" delete-char # Delete key
|
||||
bindkey "^[[C" forward-char # Right key
|
||||
bindkey "^[[D" backward-char # Left key
|
||||
bindkey "^[[5~" history-beginning-search-backward # Page up key
|
||||
bindkey "^[[6~" history-beginning-search-forward # Page down key
|
||||
|
||||
# Navigate words with ctrl+arrow keys
|
||||
bindkey "^[Oc" forward-word #
|
||||
bindkey "^[Od" backward-word #
|
||||
bindkey "^[[1;5D" backward-word #
|
||||
bindkey "^[[1;5C" forward-word #
|
||||
bindkey "^H" backward-kill-word # delete previous word with ctrl+backspace
|
||||
bindkey "^[[Z" undo # Shift+tab undo last action
|
||||
bindkey "^[Oc" forward-word
|
||||
bindkey "^[Od" backward-word
|
||||
bindkey "^[[1;5D" backward-word
|
||||
bindkey "^[[1;5C" forward-word
|
||||
bindkey "^H" backward-kill-word # delete previous word with ctrl+backspace
|
||||
bindkey "^[[Z" undo # Shift+tab undo last action
|
||||
|
||||
# ctrl + space accept suggestion
|
||||
bindkey "^ " autosuggest-accept
|
||||
|
||||
dotenv() {
|
||||
if [ $# -eq 0 ]; then
|
||||
[ -f .env.gpg ] && set -- .env.gpg "$@"
|
||||
[ -f .env ] && set -- .env "$@"
|
||||
fi
|
||||
|
||||
set -a
|
||||
while [ $# -gt 0 ]; do
|
||||
echo "dotenv: Loading $1"
|
||||
case "$1" in
|
||||
*.gpg)
|
||||
eval "$(gpg --quiet --decrypt --yes "$1")"
|
||||
;;
|
||||
*/*)
|
||||
. "$1"
|
||||
;;
|
||||
*)
|
||||
. "./$1"
|
||||
esac
|
||||
shift
|
||||
done
|
||||
set +a
|
||||
}
|
||||
|
||||
# Set terminal window and tab/icon title
|
||||
#
|
||||
# usage: title short_tab_title [long_window_title]
|
||||
#
|
||||
# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1
|
||||
# Fully supports screen and probably most modern xterm and rxvt
|
||||
# (In screen, only short_tab_title is used)
|
||||
function title {
|
||||
emulate -L zsh
|
||||
setopt prompt_subst
|
||||
|
||||
[[ "$EMACS" == *term* ]] && return
|
||||
|
||||
# if $2 is unset use $1 as default
|
||||
# if it is set and empty, leave it as is
|
||||
: ${2=$1}
|
||||
|
||||
case "$TERM" in
|
||||
xterm*|putty*|rxvt*|konsole*|ansi|mlterm*|alacritty|kitty|wezterm|st*)
|
||||
print -Pn "\e]2;${2:q}\a" # set window name
|
||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||
;;
|
||||
screen*|tmux*)
|
||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
||||
;;
|
||||
*)
|
||||
# Try to use terminfo to set the title
|
||||
# If the feature is available set title
|
||||
if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then
|
||||
echoti tsl
|
||||
print -Pn "$1"
|
||||
echoti fsl
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
# }}}
|
||||
|
||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
||||
|
||||
# URL-encode a string
|
||||
#
|
||||
# Encodes a string using RFC 2396 URL-encoding (%-escaped).
|
||||
# See: https://www.ietf.org/rfc/rfc2396.txt
|
||||
#
|
||||
# By default, reserved characters and unreserved "mark" characters are
|
||||
# not escaped by this function. This allows the common usage of passing
|
||||
# an entire URL in, and encoding just special characters in it, with
|
||||
# the expectation that reserved and mark characters are used appropriately.
|
||||
# The -r and -m options turn on escaping of the reserved and mark characters,
|
||||
# respectively, which allows arbitrary strings to be fully escaped for
|
||||
# embedding inside URLs, where reserved characters might be misinterpreted.
|
||||
#
|
||||
# Prints the encoded string on stdout.
|
||||
# Returns nonzero if encoding failed.
|
||||
#
|
||||
# Usage:
|
||||
# zsh_urlencode [-r] [-m] [-P] <string> [<string> ...]
|
||||
#
|
||||
# -r causes reserved characters (;/?:@&=+$,) to be escaped
|
||||
#
|
||||
# -m causes "mark" characters (_.!~*''()-) to be escaped
|
||||
#
|
||||
# -P causes spaces to be encoded as '%20' instead of '+'
|
||||
function zsh_urlencode() {
|
||||
emulate -L zsh
|
||||
local -a opts
|
||||
zparseopts -D -E -a opts r m P
|
||||
|
||||
local in_str="$@"
|
||||
local url_str=""
|
||||
local spaces_as_plus
|
||||
if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi
|
||||
local str="$in_str"
|
||||
|
||||
# URLs must use UTF-8 encoding; convert str to UTF-8 if required
|
||||
local encoding=$langinfo[CODESET]
|
||||
|
||||
|
||||
# Use LC_CTYPE=C to process text byte-by-byte
|
||||
local i byte ord LC_ALL=C
|
||||
export LC_ALL
|
||||
local reserved=';/?:@&=+$,'
|
||||
local mark='_.!~*''()-'
|
||||
local dont_escape="[A-Za-z0-9"
|
||||
if [[ -z $opts[(r)-r] ]]; then
|
||||
dont_escape+=$reserved
|
||||
fi
|
||||
# $mark must be last because of the "-"
|
||||
if [[ -z $opts[(r)-m] ]]; then
|
||||
dont_escape+=$mark
|
||||
fi
|
||||
dont_escape+="]"
|
||||
|
||||
# Implemented to use a single printf call and avoid subshells in the loop,
|
||||
# for performance
|
||||
local url_str=""
|
||||
for (( i = 1; i <= ${#str}; ++i )); do
|
||||
byte="$str[i]"
|
||||
if [[ "$byte" =~ "$dont_escape" ]]; then
|
||||
url_str+="$byte"
|
||||
else
|
||||
if [[ "$byte" == " " && -n $spaces_as_plus ]]; then
|
||||
url_str+="+"
|
||||
else
|
||||
ord=$(( [##16] #byte ))
|
||||
url_str+="%$ord"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo -E "$url_str"
|
||||
}
|
||||
|
||||
if [ -f env.sh ]; then
|
||||
source ./env.sh
|
||||
fi
|
||||
|
||||
[[ ! -f ~/.zshrc.local ]] || source ~/.zshrc.local
|
||||
[[ ! -f ~/.config/zsh/p10k.zsh ]] || source ~/.config/zsh/p10k.zsh
|
||||
|
||||
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
|
||||
# {{{ Overwriting
|
||||
source ~/.config/zsh/theme.zsh
|
||||
[[ ! -f env.sh ]] || source ./env.sh
|
||||
[[ ! -f ~/.zshrc.local.zsh ]] || source ~/.zshrc.local.zsh
|
||||
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
||||
# }}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue