mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
Merge branch 'ohmyzsh:master' into omz-subexecutor
This commit is contained in:
commit
22017d6e7c
20 changed files with 124 additions and 66 deletions
|
|
@ -367,7 +367,7 @@ zstyle ':omz:lib:directories' aliases no
|
|||
|
||||
Async prompt functions are an experimental feature (included on April 3, 2024) that allows Oh My Zsh to render prompt information
|
||||
asyncronously. This can improve prompt rendering performance, but it might not work well with some setups. We hope that's not an
|
||||
issue, but if you're seeing problems with this new feature, you can turn it of by setting the following in your .zshrc file,
|
||||
issue, but if you're seeing problems with this new feature, you can turn it off by setting the following in your .zshrc file,
|
||||
before Oh My Zsh is sourced:
|
||||
|
||||
```sh
|
||||
|
|
|
|||
12
lib/cli.zsh
12
lib/cli.zsh
|
|
@ -773,7 +773,17 @@ function _omz::theme::use {
|
|||
}
|
||||
|
||||
function _omz::update {
|
||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
||||
# Check if git command is available
|
||||
(( $+commands[git] )) || {
|
||||
_omz::log error "git is not installed. Aborting..."
|
||||
return 1
|
||||
}
|
||||
|
||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
||||
[[ $? -eq 0 ]] || {
|
||||
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
||||
return 1
|
||||
}
|
||||
|
||||
# Run update script
|
||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
autoload -Uz is-at-least
|
||||
|
||||
# The git prompt's git commands are read-only and should not interfere with
|
||||
# other processes. This environment variable is equivalent to running with `git
|
||||
# --no-optional-locks`, but falls back gracefully for older versions of git.
|
||||
|
|
@ -37,8 +39,10 @@ function _omz_git_prompt_info() {
|
|||
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref:gs/%/%%}${upstream:gs/%/%%}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
|
||||
}
|
||||
|
||||
# Enable async prompt by default unless the setting is at false / no
|
||||
if zstyle -T ':omz:alpha:lib:git' async-prompt; then
|
||||
# Use async version if setting is enabled, or undefined but zsh version is at least 5.0.6
|
||||
# https://github.com/ohmyzsh/ohmyzsh/issues/12331#issuecomment-2059460268
|
||||
if zstyle -t ':omz:alpha:lib:git' async-prompt \
|
||||
|| { is-at-least 5.0.6 && zstyle -T ':omz:alpha:lib:git' async-prompt }; then
|
||||
function git_prompt_info() {
|
||||
setopt localoptions noksharrays
|
||||
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then
|
||||
|
|
|
|||
|
|
@ -1,19 +1,20 @@
|
|||
## History wrapper
|
||||
function omz_history {
|
||||
local clear list
|
||||
zparseopts -E c=clear l=list
|
||||
# parse arguments and remove from $@
|
||||
local clear list stamp
|
||||
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp
|
||||
|
||||
if [[ -n "$clear" ]]; then
|
||||
# if -c provided, clobber the history file
|
||||
echo -n >| "$HISTFILE"
|
||||
fc -p "$HISTFILE"
|
||||
echo >&2 History file deleted.
|
||||
elif [[ -n "$list" ]]; then
|
||||
# if -l provided, run as if calling `fc' directly
|
||||
builtin fc "$@"
|
||||
elif [[ $# -eq 0 ]]; then
|
||||
# if no arguments provided, show full history starting from 1
|
||||
builtin fc $stamp -l 1
|
||||
else
|
||||
# unless a number is provided, show all history events (starting from 1)
|
||||
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
|
||||
# otherwise, run `fc -l` with a custom format
|
||||
builtin fc $stamp -l "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ autojump_paths=(
|
|||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ To use it, add `git-prompt` to the plugins array in your zshrc file:
|
|||
plugins=(... git-prompt)
|
||||
```
|
||||
|
||||
You may also need to [customize your theme](https://github.com/ohmyzsh/ohmyzsh/issues/9395#issuecomment-1027130429)
|
||||
to change the way the prompt is built. See the
|
||||
[OMZ wiki on customizing themes](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#overriding-and-adding-themes).
|
||||
|
||||
See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
|
||||
|
||||
## Requirements
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ plugins=(... git)
|
|||
| `gfg` | `git ls-files \| grep` |
|
||||
| `gm` | `git merge` |
|
||||
| `gma` | `git merge --abort` |
|
||||
| `gmc` | `git merge --continue` |
|
||||
| `gms` | `git merge --squash` |
|
||||
| `gmom` | `git merge origin/$(git_main_branch)` |
|
||||
| `gmum` | `git merge upstream/$(git_main_branch)` |
|
||||
|
|
@ -166,6 +167,7 @@ plugins=(... git)
|
|||
| `grhk` | `git reset --keep` |
|
||||
| `grhs` | `git reset --soft` |
|
||||
| `gpristine` | `git reset --hard && git clean --force -dfx` |
|
||||
| `gwipe` | `git reset --hard && git clean --force -df` |
|
||||
| `groh` | `git reset origin/$(git_current_branch) --hard` |
|
||||
| `grs` | `git restore` |
|
||||
| `grss` | `git restore --source` |
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ alias gignored='git ls-files -v | grep "^[[:lower:]]"'
|
|||
alias gfg='git ls-files | grep'
|
||||
alias gm='git merge'
|
||||
alias gma='git merge --abort'
|
||||
alias gmc='git merge --continue'
|
||||
alias gms="git merge --squash"
|
||||
alias gmom='git merge origin/$(git_main_branch)'
|
||||
alias gmum='git merge upstream/$(git_main_branch)'
|
||||
|
|
@ -349,6 +350,7 @@ alias grhh='git reset --hard'
|
|||
alias grhk='git reset --keep'
|
||||
alias grhs='git reset --soft'
|
||||
alias gpristine='git reset --hard && git clean --force -dfx'
|
||||
alias gwipe='git reset --hard && git clean --force -df'
|
||||
alias groh='git reset origin/$(git_current_branch) --hard'
|
||||
alias grs='git restore'
|
||||
alias grss='git restore --source'
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ plugins=(... laravel)
|
|||
|:-:|:-:|
|
||||
| `artisan` | `php artisan` |
|
||||
| `pas` | `php artisan serve` |
|
||||
| `pats` | `php artisan test` |
|
||||
|
||||
## Database
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ alias bob='php artisan bob::build'
|
|||
|
||||
# Development
|
||||
alias pas='php artisan serve'
|
||||
alias pats='php artisan test'
|
||||
|
||||
# Database
|
||||
alias pam='php artisan migrate'
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
|
|||
| `tab` | Open the current directory in a new tab |
|
||||
| `split_tab` | Split the current terminal tab horizontally |
|
||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||
| `ofd` | Open the current directory in a Finder window |
|
||||
| `ofd` | Open passed directories (or $PWD by default) in Finder |
|
||||
| `pfd` | Return the path of the frontmost Finder window |
|
||||
| `pfs` | Return the current Finder selection |
|
||||
| `cdf` | `cd` to the current Finder directory |
|
||||
|
|
|
|||
|
|
@ -3,8 +3,15 @@
|
|||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||
|
||||
# Open the current directory in a Finder window
|
||||
alias ofd='open_command $PWD'
|
||||
# Open in Finder the directories passed as arguments, or the current directory if
|
||||
# no directories are passed
|
||||
function ofd {
|
||||
if (( ! $# )); then
|
||||
open_command $PWD
|
||||
else
|
||||
open_command $@
|
||||
fi
|
||||
}
|
||||
|
||||
# Show/hide hidden files in the Finder
|
||||
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
# Automatic poetry environment activation/deactivation
|
||||
_togglePoetryShell() {
|
||||
# deactivate environment if pyproject.toml doesn't exist and not in a subdir
|
||||
if [[ ! -f "$PWD/pyproject.toml" ]] ; then
|
||||
if [[ "$poetry_active" == 1 ]]; then
|
||||
if [[ "$PWD" != "$poetry_dir"* ]]; then
|
||||
export poetry_active=0
|
||||
deactivate
|
||||
return
|
||||
fi
|
||||
fi
|
||||
# Determine if currently in a Poetry-managed directory
|
||||
local in_poetry_dir=0
|
||||
if [[ -f "$PWD/pyproject.toml" ]] && grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
|
||||
in_poetry_dir=1
|
||||
fi
|
||||
|
||||
# activate the environment if pyproject.toml exists
|
||||
if [[ "$poetry_active" != 1 ]]; then
|
||||
if [[ -f "$PWD/pyproject.toml" ]]; then
|
||||
if grep -q 'tool.poetry' "$PWD/pyproject.toml" && venv_dir=$(poetry env info --path); then
|
||||
export poetry_active=1
|
||||
export poetry_dir="$PWD"
|
||||
source "${venv_dir}/bin/activate"
|
||||
fi
|
||||
# Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
|
||||
if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] || [[ "$PWD" != "$poetry_dir"* ]]; }; then
|
||||
export poetry_active=0
|
||||
unset poetry_dir
|
||||
deactivate
|
||||
fi
|
||||
|
||||
# Activate the environment if in a Poetry directory and no environment is currently active
|
||||
if [[ $in_poetry_dir -eq 1 ]] && [[ $poetry_active -ne 1 ]]; then
|
||||
venv_dir=$(poetry env info --path 2>/dev/null)
|
||||
if [[ -n "$venv_dir" ]]; then
|
||||
export poetry_active=1
|
||||
export poetry_dir="$PWD"
|
||||
source "${venv_dir}/bin/activate"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd _togglePoetryShell
|
||||
_togglePoetryShell
|
||||
_togglePoetryShell # Initial call to check the current directory at shell startup
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ if parsed.scheme not in proxy_protocols:
|
|||
|
||||
def make_argv():
|
||||
yield "nc"
|
||||
if sys.platform == 'linux':
|
||||
if sys.platform in {'linux', 'cygwin'}:
|
||||
# caveats: the built-in netcat of most linux distributions and cygwin support proxy type
|
||||
# caveats: macOS built-in netcat command not supported proxy-type
|
||||
yield "-X" # --proxy-type
|
||||
# Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ The plugin also supports the following:
|
|||
| `ZSH_TMUX_AUTOQUIT` | Automatically closes terminal once tmux exits (default: `ZSH_TMUX_AUTOSTART`) |
|
||||
| `ZSH_TMUX_CONFIG` | Set the configuration path (default: `$HOME/.tmux.conf`, `$XDG_CONFIG_HOME/tmux/tmux.conf`) |
|
||||
| `ZSH_TMUX_DEFAULT_SESSION_NAME` | Set tmux default session name when autostart is enabled |
|
||||
| `ZSH_TMUX_AUTONAME_SESSION` | Automatically name new sessions based on the basename of `$PWD` (default: `false`) |
|
||||
| `ZSH_TMUX_DETACHED` | Set the detached mode (default: `false`) |
|
||||
| `ZSH_TMUX_FIXTERM` | Sets `$TERM` to 256-color term or not based on current terminal support |
|
||||
| `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux` if available, `screen` otherwise) |
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ fi
|
|||
: ${ZSH_TMUX_AUTOCONNECT:=true}
|
||||
# Automatically close the terminal when tmux exits
|
||||
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART}
|
||||
# Automatically name the new session based on the basename of PWD
|
||||
: ${ZSH_TMUX_AUTONAME_SESSION:=false}
|
||||
# Set term to screen or screen-256color based on current terminal support
|
||||
: ${ZSH_TMUX_DETACHED:=false}
|
||||
# Set detached mode
|
||||
|
|
@ -102,9 +104,22 @@ function _zsh_tmux_plugin_run() {
|
|||
|
||||
local _detached=""
|
||||
[[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d"
|
||||
|
||||
local session_name
|
||||
if [[ "$ZSH_TMUX_AUTONAME_SESSION" == "true" ]]; then
|
||||
# Name the session after the basename of the current directory
|
||||
session_name=${PWD##*/}
|
||||
# If the current directory is the home directory, name it 'HOME'
|
||||
[[ "$PWD" == "$HOME" ]] && session_name="HOME"
|
||||
# If the current directory is the root directory, name it 'ROOT'
|
||||
[[ "$PWD" == "/" ]] && session_name="ROOT"
|
||||
else
|
||||
session_name="$ZSH_TMUX_DEFAULT_SESSION_NAME"
|
||||
fi
|
||||
|
||||
# Try to connect to an existing session.
|
||||
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t $ZSH_TMUX_DEFAULT_SESSION_NAME
|
||||
if [[ -n "$session_name" ]]; then
|
||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name"
|
||||
else
|
||||
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached
|
||||
fi
|
||||
|
|
@ -116,8 +131,9 @@ function _zsh_tmux_plugin_run() {
|
|||
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
|
||||
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
|
||||
fi
|
||||
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then
|
||||
$tmux_cmd new-session -s $ZSH_TMUX_DEFAULT_SESSION_NAME
|
||||
|
||||
if [[ -n "$session_name" ]]; then
|
||||
$tmux_cmd new-session -s "$session_name"
|
||||
else
|
||||
$tmux_cmd new-session
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ _global_commands=(
|
|||
)
|
||||
|
||||
_yarn_find_package_json() {
|
||||
local dir=$(cd "$1" && pwd)
|
||||
local dir=$(builtin cd "$1" && pwd)
|
||||
|
||||
while true
|
||||
do
|
||||
|
|
@ -109,7 +109,7 @@ _yarn_commands_scripts() {
|
|||
|
||||
if [[ -n $opt_args[--cwd] ]]; then
|
||||
packageJson=$(_yarn_find_package_json $opt_args[--cwd])
|
||||
binaries=($(cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t)))
|
||||
binaries=($(builtin cd $opt_args[--cwd] && echo node_modules/.bin/*(x:t)))
|
||||
else
|
||||
packageJson=$(_yarn_find_package_json $pwd)
|
||||
binaries=($(echo node_modules/.bin/*(x:t)))
|
||||
|
|
@ -130,9 +130,9 @@ _yarn_scripts() {
|
|||
if [[ -n $_yarn_run_cwd ]]; then
|
||||
packageJson=$(_yarn_find_package_json $_yarn_run_cwd)
|
||||
if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then
|
||||
binaries=($(cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t)))
|
||||
binaries=($(builtin cd $_yarn_run_cwd && echo node_modules/.bin/*(x:t)))
|
||||
else
|
||||
binaries=($(cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1'))
|
||||
binaries=($(builtin cd $_yarn_run_cwd && yarn bin | perl -wln -e 'm{^[^:]+: (\S+)$} and print $1'))
|
||||
fi
|
||||
else
|
||||
packageJson=$(_yarn_find_package_json $pwd)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ prompt_context() {
|
|||
# Git: branch/detached head, dirty status
|
||||
prompt_git() {
|
||||
(( $+commands[git] )) || return
|
||||
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
|
||||
if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then
|
||||
return
|
||||
fi
|
||||
local PL_BRANCH_CHAR
|
||||
|
|
@ -106,12 +106,12 @@ prompt_git() {
|
|||
}
|
||||
local ref dirty mode repo_path
|
||||
|
||||
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
|
||||
repo_path=$(git rev-parse --git-dir 2>/dev/null)
|
||||
if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
|
||||
repo_path=$(command git rev-parse --git-dir 2>/dev/null)
|
||||
dirty=$(parse_git_dirty)
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \
|
||||
ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
|
||||
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||
ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \
|
||||
ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)"
|
||||
if [[ -n $dirty ]]; then
|
||||
prompt_segment yellow black
|
||||
else
|
||||
|
|
@ -119,8 +119,8 @@ prompt_git() {
|
|||
fi
|
||||
|
||||
local ahead behind
|
||||
ahead=$(git log --oneline @{upstream}.. 2>/dev/null)
|
||||
behind=$(git log --oneline ..@{upstream} 2>/dev/null)
|
||||
ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
|
||||
behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
|
||||
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
|
||||
PL_BRANCH_CHAR=$'\u21c5'
|
||||
elif [[ -n "$ahead" ]]; then
|
||||
|
|
@ -163,10 +163,10 @@ prompt_bzr() {
|
|||
done
|
||||
|
||||
local bzr_status status_mod status_all revision
|
||||
if bzr_status=$(bzr status 2>&1); then
|
||||
if bzr_status=$(command bzr status 2>&1); then
|
||||
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
|
||||
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
|
||||
revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
|
||||
revision=${$(command bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
|
||||
if [[ $status_mod -gt 0 ]] ; then
|
||||
prompt_segment yellow black "bzr@$revision ✚"
|
||||
else
|
||||
|
|
@ -182,13 +182,13 @@ prompt_bzr() {
|
|||
prompt_hg() {
|
||||
(( $+commands[hg] )) || return
|
||||
local rev st branch
|
||||
if $(hg id >/dev/null 2>&1); then
|
||||
if $(hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
|
||||
if $(command hg id >/dev/null 2>&1); then
|
||||
if $(command hg prompt >/dev/null 2>&1); then
|
||||
if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then
|
||||
# if files are not added
|
||||
prompt_segment red white
|
||||
st='±'
|
||||
elif [[ -n $(hg prompt "{status|modified}") ]]; then
|
||||
elif [[ -n $(command hg prompt "{status|modified}") ]]; then
|
||||
# if any modification
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
|
|
@ -196,15 +196,15 @@ prompt_hg() {
|
|||
# if working copy is clean
|
||||
prompt_segment green $CURRENT_FG
|
||||
fi
|
||||
echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
|
||||
echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
|
||||
else
|
||||
st=""
|
||||
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(hg id -b 2>/dev/null)
|
||||
if `hg st | grep -q "^\?"`; then
|
||||
rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
|
||||
branch=$(command hg id -b 2>/dev/null)
|
||||
if command hg st | command grep -q "^\?"; then
|
||||
prompt_segment red black
|
||||
st='±'
|
||||
elif `hg st | grep -q "^[MA]"`; then
|
||||
elif command hg st | command grep -q "^[MA]"; then
|
||||
prompt_segment yellow black
|
||||
st='±'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || {
|
|||
}
|
||||
|
||||
# Cancel update if:
|
||||
# - the automatic update is disabled.
|
||||
# - the current user doesn't have write permissions nor owns the $ZSH directory.
|
||||
# - the automatic update is disabled
|
||||
# - the current user doesn't have write permissions nor owns the $ZSH directory
|
||||
# - is not run from a tty
|
||||
# - git is unavailable on the system.
|
||||
# - git is unavailable on the system
|
||||
# - $ZSH is not a git repository
|
||||
if [[ "$update_mode" = disabled ]] \
|
||||
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
||||
|| [[ ! -t 1 ]] \
|
||||
|| ! command git --version 2>&1 >/dev/null; then
|
||||
|| ! command git --version 2>&1 >/dev/null \
|
||||
|| (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then
|
||||
unset update_mode
|
||||
return
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -10,9 +10,14 @@ fi
|
|||
|
||||
# Protect against unwanted sourcing
|
||||
case "$ZSH_EVAL_CONTEXT" in
|
||||
*:file) echo "error: this file should not be sourced" && return ;;
|
||||
*:file) echo "error: this file should not be sourced" && return 1 ;;
|
||||
esac
|
||||
|
||||
# Define "$ZSH" if not defined -- in theory this should be `export`ed by the calling script
|
||||
if [[ -z "$ZSH" ]]; then
|
||||
ZSH="${0:a:h:h}"
|
||||
fi
|
||||
|
||||
cd "$ZSH"
|
||||
|
||||
verbose_mode="default"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue