mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-08-07 06:08:39 +02:00
parent
677a4592b1
commit
0adec2f896
11 changed files with 41 additions and 27 deletions
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -41,3 +41,5 @@ jobs:
|
||||||
./themes/*.zsh-theme; do
|
./themes/*.zsh-theme; do
|
||||||
zsh -n "$file" || return 1
|
zsh -n "$file" || return 1
|
||||||
done
|
done
|
||||||
|
- name: Check nounset startup
|
||||||
|
run: zsh -df lib/tests/nounset.test.zsh
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ bindkey -M menuselect '^o' accept-and-infer-next-history
|
||||||
zstyle ':completion:*:*:*:*:*' menu select
|
zstyle ':completion:*:*:*:*:*' menu select
|
||||||
|
|
||||||
# case insensitive (all), partial-word and substring completion
|
# case insensitive (all), partial-word and substring completion
|
||||||
if [[ "$CASE_SENSITIVE" = true ]]; then
|
if [[ ${CASE_SENSITIVE-} = true ]]; then
|
||||||
zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
|
zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
|
||||||
else
|
else
|
||||||
if [[ "$HYPHEN_INSENSITIVE" = true ]]; then
|
if [[ ${HYPHEN_INSENSITIVE-} = true ]]; then
|
||||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*'
|
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]-_}={[:upper:][:lower:]_-}' 'r:|=*' 'l:|=* r:|=*'
|
||||||
else
|
else
|
||||||
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*'
|
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
if [[ "$ENABLE_CORRECTION" == "true" ]]; then
|
if [[ ${ENABLE_CORRECTION-} == "true" ]]; then
|
||||||
alias cp='nocorrect cp'
|
alias cp='nocorrect cp'
|
||||||
alias man='nocorrect man'
|
alias man='nocorrect man'
|
||||||
alias mkdir='nocorrect mkdir'
|
alias mkdir='nocorrect mkdir'
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ function default() {
|
||||||
# 0 if the env variable exists, 3 if it was set
|
# 0 if the env variable exists, 3 if it was set
|
||||||
#
|
#
|
||||||
function env_default() {
|
function env_default() {
|
||||||
[[ ${parameters[$1]} = *-export* ]] && return 0
|
[[ ${parameters[$1]-} = *-export* ]] && return 0
|
||||||
export "$1=$2" && return 3
|
export "$1=$2" && return 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ case ${HIST_STAMPS-} in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
## History file configuration
|
## History file configuration
|
||||||
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
|
[ -z ${HISTFILE-} ] && HISTFILE="$HOME/.zsh_history"
|
||||||
[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
|
[ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
|
||||||
[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
|
[ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
autoload -Uz is-at-least
|
autoload -Uz is-at-least
|
||||||
|
|
||||||
# *-magic is known buggy in some versions; disable if so
|
# *-magic is known buggy in some versions; disable if so
|
||||||
if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then
|
if [[ ${DISABLE_MAGIC_FUNCTIONS-} != true ]]; then
|
||||||
for d in $fpath; do
|
for d in $fpath; do
|
||||||
if [[ -e "$d/url-quote-magic" ]]; then
|
if [[ -e "$d/url-quote-magic" ]]; then
|
||||||
if is-at-least 5.1; then
|
if is-at-least 5.1; then
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ function title {
|
||||||
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
print -Pn "\ek${1:q}\e\\" # set screen hardstatus
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
|
if [[ ${TERM_PROGRAM-} == "iTerm.app" ]]; then
|
||||||
print -Pn "\e]2;${2:q}\a" # set window name
|
print -Pn "\e]2;${2:q}\a" # set window name
|
||||||
print -Pn "\e]1;${1:q}\a" # set tab name
|
print -Pn "\e]1;${1:q}\a" # set tab name
|
||||||
else
|
else
|
||||||
|
|
@ -41,7 +41,7 @@ function title {
|
||||||
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
|
||||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
|
||||||
# Avoid duplication of directory in terminals with independent dir display
|
# Avoid duplication of directory in terminals with independent dir display
|
||||||
if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then
|
if [[ ${TERM_PROGRAM-} == Apple_Terminal ]]; then
|
||||||
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
|
ZSH_THEME_TERM_TITLE_IDLE="%n@%m"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ function omz_termsupport_preexec {
|
||||||
|
|
||||||
autoload -Uz add-zsh-hook
|
autoload -Uz add-zsh-hook
|
||||||
|
|
||||||
if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then
|
if [[ -z ${INSIDE_EMACS-} || ${INSIDE_EMACS-} = vterm ]]; then
|
||||||
add-zsh-hook precmd omz_termsupport_precmd
|
add-zsh-hook precmd omz_termsupport_precmd
|
||||||
add-zsh-hook preexec omz_termsupport_preexec
|
add-zsh-hook preexec omz_termsupport_preexec
|
||||||
fi
|
fi
|
||||||
|
|
@ -122,7 +122,7 @@ fi
|
||||||
# As of May 2021 mlterm, PuTTY, rxvt, screen, termux & xterm simply ignore the unknown OSC.
|
# As of May 2021 mlterm, PuTTY, rxvt, screen, termux & xterm simply ignore the unknown OSC.
|
||||||
|
|
||||||
# Don't define the function if we're inside Emacs or in an SSH session (#11696)
|
# Don't define the function if we're inside Emacs or in an SSH session (#11696)
|
||||||
if [[ -n "$INSIDE_EMACS" || -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
|
if [[ -n ${INSIDE_EMACS-} || -n ${SSH_CLIENT-} || -n ${SSH_TTY-} ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ case "$TERM" in
|
||||||
contour*|foot*) ;;
|
contour*|foot*) ;;
|
||||||
*)
|
*)
|
||||||
# Terminal.app and iTerm2 process OSC 7 correctly
|
# Terminal.app and iTerm2 process OSC 7 correctly
|
||||||
case "$TERM_PROGRAM" in
|
case "${TERM_PROGRAM-}" in
|
||||||
Apple_Terminal|iTerm.app) ;;
|
Apple_Terminal|iTerm.app) ;;
|
||||||
*) return ;;
|
*) return ;;
|
||||||
esac ;;
|
esac ;;
|
||||||
|
|
|
||||||
12
lib/tests/nounset.test.zsh
Normal file
12
lib/tests/nounset.test.zsh
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env zsh -df
|
||||||
|
|
||||||
|
set -u
|
||||||
|
|
||||||
|
export ZSH="${0:A:h:h:h}"
|
||||||
|
export HOME="$(mktemp -d)"
|
||||||
|
export ZDOTDIR="$HOME"
|
||||||
|
plugins=()
|
||||||
|
|
||||||
|
trap 'rm -rf "$HOME"' EXIT
|
||||||
|
|
||||||
|
source "$ZSH/oh-my-zsh.sh"
|
||||||
|
|
@ -21,13 +21,13 @@ if command diff --color /dev/null{,} &>/dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Don't set ls coloring if disabled
|
# Don't set ls coloring if disabled
|
||||||
[[ "$DISABLE_LS_COLORS" != true ]] || return 0
|
[[ ${DISABLE_LS_COLORS-} != true ]] || return 0
|
||||||
|
|
||||||
# Default coloring for BSD-based ls
|
# Default coloring for BSD-based ls
|
||||||
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
export LSCOLORS="Gxfxcxdxbxegedabagacad"
|
||||||
|
|
||||||
# Default coloring for GNU-based ls
|
# Default coloring for GNU-based ls
|
||||||
if [[ -z "$LS_COLORS" ]]; then
|
if [[ -z ${LS_COLORS-} ]]; then
|
||||||
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
# Define LS_COLORS via dircolors if available. Otherwise, set a default
|
||||||
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
# equivalent to LSCOLORS (generated via https://geoff.greer.fm/lscolors)
|
||||||
if (( $+commands[dircolors] )); then
|
if (( $+commands[dircolors] )); then
|
||||||
|
|
|
||||||
24
oh-my-zsh.sh
24
oh-my-zsh.sh
|
|
@ -48,15 +48,15 @@ omz_f() {
|
||||||
unset -f omz_f
|
unset -f omz_f
|
||||||
|
|
||||||
# If ZSH is not defined, use the current script's directory.
|
# If ZSH is not defined, use the current script's directory.
|
||||||
[[ -n "$ZSH" ]] || export ZSH="${${(%):-%x}:a:h}"
|
[[ -n ${ZSH-} ]] || export ZSH="${${(%):-%x}:a:h}"
|
||||||
|
|
||||||
# Set ZSH_CUSTOM to the path where your custom config files
|
# Set ZSH_CUSTOM to the path where your custom config files
|
||||||
# and plugins exists, or else we will use the default custom/
|
# and plugins exists, or else we will use the default custom/
|
||||||
[[ -n "$ZSH_CUSTOM" ]] || ZSH_CUSTOM="$ZSH/custom"
|
[[ -n ${ZSH_CUSTOM-} ]] || ZSH_CUSTOM="$ZSH/custom"
|
||||||
|
|
||||||
# Set ZSH_CACHE_DIR to the path where cache files should be created
|
# Set ZSH_CACHE_DIR to the path where cache files should be created
|
||||||
# or else we will use the default cache/
|
# or else we will use the default cache/
|
||||||
[[ -n "$ZSH_CACHE_DIR" ]] || ZSH_CACHE_DIR="$ZSH/cache"
|
[[ -n ${ZSH_CACHE_DIR-} ]] || ZSH_CACHE_DIR="$ZSH/cache"
|
||||||
|
|
||||||
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
|
# Make sure $ZSH_CACHE_DIR is writable, otherwise use a directory in $HOME
|
||||||
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
|
if [[ ! -w "$ZSH_CACHE_DIR" ]]; then
|
||||||
|
|
@ -98,15 +98,15 @@ for plugin ($plugins); do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Figure out the SHORT hostname
|
# Figure out the SHORT hostname
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
if [[ ${OSTYPE-} = darwin* ]]; then
|
||||||
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
||||||
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST-}"
|
||||||
else
|
else
|
||||||
SHORT_HOST="${HOST/.*/}"
|
SHORT_HOST="${HOST-}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Save the location of the current completion dump file.
|
# Save the location of the current completion dump file.
|
||||||
if [[ -z "$ZSH_COMPDUMP" ]]; then
|
if [[ -z ${ZSH_COMPDUMP-} ]]; then
|
||||||
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -121,7 +121,7 @@ if ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null \
|
||||||
zcompdump_refresh=1
|
zcompdump_refresh=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$ZSH_DISABLE_COMPFIX" != true ]]; then
|
if [[ ${ZSH_DISABLE_COMPFIX-} != true ]]; then
|
||||||
source "$ZSH/lib/compfix.zsh"
|
source "$ZSH/lib/compfix.zsh"
|
||||||
# Load only from secure directories
|
# Load only from secure directories
|
||||||
compinit -i -d "$ZSH_COMPDUMP"
|
compinit -i -d "$ZSH_COMPDUMP"
|
||||||
|
|
@ -133,7 +133,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Append zcompdump metadata if missing
|
# Append zcompdump metadata if missing
|
||||||
if (( $zcompdump_refresh )) \
|
if (( ${zcompdump_refresh:-0} )) \
|
||||||
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; then
|
|| ! command grep -q -Fx "$zcompdump_revision" "$ZSH_COMPDUMP" 2>/dev/null; then
|
||||||
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
|
# Use `tee` in case the $ZSH_COMPDUMP filename is invalid, to silence the error
|
||||||
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
|
# See https://github.com/ohmyzsh/ohmyzsh/commit/dd1a7269#commitcomment-39003489
|
||||||
|
|
@ -200,7 +200,7 @@ done
|
||||||
unset lib_file
|
unset lib_file
|
||||||
|
|
||||||
# Load all of the plugins that were defined in ~/.zshrc
|
# Load all of the plugins that were defined in ~/.zshrc
|
||||||
for plugin ($plugins); do
|
for plugin (${plugins-}); do
|
||||||
_omz_source "plugins/$plugin/$plugin.plugin.zsh"
|
_omz_source "plugins/$plugin/$plugin.plugin.zsh"
|
||||||
done
|
done
|
||||||
unset plugin
|
unset plugin
|
||||||
|
|
@ -218,7 +218,7 @@ is_theme() {
|
||||||
builtin test -f $base_dir/$name.zsh-theme
|
builtin test -f $base_dir/$name.zsh-theme
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ -n "$ZSH_THEME" ]]; then
|
if [[ -n ${ZSH_THEME-} ]]; then
|
||||||
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
|
if is_theme "$ZSH_CUSTOM" "$ZSH_THEME"; then
|
||||||
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
|
||||||
elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
|
elif is_theme "$ZSH_CUSTOM/themes" "$ZSH_THEME"; then
|
||||||
|
|
@ -231,4 +231,4 @@ if [[ -n "$ZSH_THEME" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# set completion colors to be the same as `ls`, after theme has been loaded
|
# set completion colors to be the same as `ls`, after theme has been loaded
|
||||||
[[ -z "$LS_COLORS" ]] || zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
[[ -z ${LS_COLORS-} ]] || zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ zstyle -s ':omz:update' mode update_mode || {
|
||||||
update_mode=prompt
|
update_mode=prompt
|
||||||
|
|
||||||
# If the mode zstyle setting is not set, support old-style settings
|
# If the mode zstyle setting is not set, support old-style settings
|
||||||
[[ "$DISABLE_UPDATE_PROMPT" != true ]] || update_mode=auto
|
[[ ${DISABLE_UPDATE_PROMPT-} != true ]] || update_mode=auto
|
||||||
[[ "$DISABLE_AUTO_UPDATE" != true ]] || update_mode=disabled
|
[[ ${DISABLE_AUTO_UPDATE-} != true ]] || update_mode=disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cancel update if:
|
# Cancel update if:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue