Merge branch 'ohmyzsh:master' into omz-subexecutor

This commit is contained in:
Pandu E POLUAN 2024-04-19 11:00:39 +07:00 committed by GitHub
commit 22017d6e7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 124 additions and 66 deletions

View file

@ -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 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 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: before Oh My Zsh is sourced:
```sh ```sh

View file

@ -773,7 +773,17 @@ function _omz::theme::use {
} }
function _omz::update { 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 # Run update script
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default

View file

@ -1,3 +1,5 @@
autoload -Uz is-at-least
# The git prompt's git commands are read-only and should not interfere with # 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 # other processes. This environment variable is equivalent to running with `git
# --no-optional-locks`, but falls back gracefully for older versions of 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}" 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 # Use async version if setting is enabled, or undefined but zsh version is at least 5.0.6
if zstyle -T ':omz:alpha:lib:git' async-prompt; then # 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() { function git_prompt_info() {
setopt localoptions noksharrays setopt localoptions noksharrays
if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then if [[ -n "$_OMZ_ASYNC_OUTPUT[_omz_git_prompt_info]" ]]; then

View file

@ -1,19 +1,20 @@
## History wrapper ## History wrapper
function omz_history { function omz_history {
local clear list # parse arguments and remove from $@
zparseopts -E c=clear l=list local clear list stamp
zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp t:=stamp
if [[ -n "$clear" ]]; then if [[ -n "$clear" ]]; then
# if -c provided, clobber the history file # if -c provided, clobber the history file
echo -n >| "$HISTFILE" echo -n >| "$HISTFILE"
fc -p "$HISTFILE" fc -p "$HISTFILE"
echo >&2 History file deleted. echo >&2 History file deleted.
elif [[ -n "$list" ]]; then elif [[ $# -eq 0 ]]; then
# if -l provided, run as if calling `fc' directly # if no arguments provided, show full history starting from 1
builtin fc "$@" builtin fc $stamp -l 1
else else
# unless a number is provided, show all history events (starting from 1) # otherwise, run `fc -l` with a custom format
[[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1 builtin fc $stamp -l "$@"
fi fi
} }

View file

@ -13,6 +13,7 @@ autojump_paths=(
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) /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/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 /etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
) )

View file

@ -9,6 +9,10 @@ To use it, add `git-prompt` to the plugins array in your zshrc file:
plugins=(... git-prompt) 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). See the [original repository](https://github.com/olivierverdier/zsh-git-prompt).
## Requirements ## Requirements

View file

@ -111,6 +111,7 @@ plugins=(... git)
| `gfg` | `git ls-files \| grep` | | `gfg` | `git ls-files \| grep` |
| `gm` | `git merge` | | `gm` | `git merge` |
| `gma` | `git merge --abort` | | `gma` | `git merge --abort` |
| `gmc` | `git merge --continue` |
| `gms` | `git merge --squash` | | `gms` | `git merge --squash` |
| `gmom` | `git merge origin/$(git_main_branch)` | | `gmom` | `git merge origin/$(git_main_branch)` |
| `gmum` | `git merge upstream/$(git_main_branch)` | | `gmum` | `git merge upstream/$(git_main_branch)` |
@ -166,6 +167,7 @@ plugins=(... git)
| `grhk` | `git reset --keep` | | `grhk` | `git reset --keep` |
| `grhs` | `git reset --soft` | | `grhs` | `git reset --soft` |
| `gpristine` | `git reset --hard && git clean --force -dfx` | | `gpristine` | `git reset --hard && git clean --force -dfx` |
| `gwipe` | `git reset --hard && git clean --force -df` |
| `groh` | `git reset origin/$(git_current_branch) --hard` | | `groh` | `git reset origin/$(git_current_branch) --hard` |
| `grs` | `git restore` | | `grs` | `git restore` |
| `grss` | `git restore --source` | | `grss` | `git restore --source` |

View file

@ -252,6 +252,7 @@ alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias gfg='git ls-files | grep' alias gfg='git ls-files | grep'
alias gm='git merge' alias gm='git merge'
alias gma='git merge --abort' alias gma='git merge --abort'
alias gmc='git merge --continue'
alias gms="git merge --squash" alias gms="git merge --squash"
alias gmom='git merge origin/$(git_main_branch)' alias gmom='git merge origin/$(git_main_branch)'
alias gmum='git merge upstream/$(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 grhk='git reset --keep'
alias grhs='git reset --soft' alias grhs='git reset --soft'
alias gpristine='git reset --hard && git clean --force -dfx' 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 groh='git reset origin/$(git_current_branch) --hard'
alias grs='git restore' alias grs='git restore'
alias grss='git restore --source' alias grss='git restore --source'

View file

@ -10,6 +10,7 @@ plugins=(... laravel)
|:-:|:-:| |:-:|:-:|
| `artisan` | `php artisan` | | `artisan` | `php artisan` |
| `pas` | `php artisan serve` | | `pas` | `php artisan serve` |
| `pats` | `php artisan test` |
## Database ## Database

View file

@ -4,6 +4,7 @@ alias bob='php artisan bob::build'
# Development # Development
alias pas='php artisan serve' alias pas='php artisan serve'
alias pats='php artisan test'
# Database # Database
alias pam='php artisan migrate' alias pam='php artisan migrate'

View file

@ -17,7 +17,7 @@ Original author: [Sorin Ionescu](https://github.com/sorin-ionescu)
| `tab` | Open the current directory in a new tab | | `tab` | Open the current directory in a new tab |
| `split_tab` | Split the current terminal tab horizontally | | `split_tab` | Split the current terminal tab horizontally |
| `vsplit_tab` | Split the current terminal tab vertically | | `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 | | `pfd` | Return the path of the frontmost Finder window |
| `pfs` | Return the current Finder selection | | `pfs` | Return the current Finder selection |
| `cdf` | `cd` to the current Finder directory | | `cdf` | `cd` to the current Finder directory |

View file

@ -3,8 +3,15 @@
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}" 0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
0="${${(M)0:#/*}:-$PWD/$0}" 0="${${(M)0:#/*}:-$PWD/$0}"
# Open the current directory in a Finder window # Open in Finder the directories passed as arguments, or the current directory if
alias ofd='open_command $PWD' # no directories are passed
function ofd {
if (( ! $# )); then
open_command $PWD
else
open_command $@
fi
}
# Show/hide hidden files in the Finder # Show/hide hidden files in the Finder
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder" alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"

View file

@ -1,27 +1,27 @@
# Automatic poetry environment activation/deactivation
_togglePoetryShell() { _togglePoetryShell() {
# deactivate environment if pyproject.toml doesn't exist and not in a subdir # Determine if currently in a Poetry-managed directory
if [[ ! -f "$PWD/pyproject.toml" ]] ; then local in_poetry_dir=0
if [[ "$poetry_active" == 1 ]]; then if [[ -f "$PWD/pyproject.toml" ]] && grep -q 'tool.poetry' "$PWD/pyproject.toml"; then
if [[ "$PWD" != "$poetry_dir"* ]]; then in_poetry_dir=1
export poetry_active=0
deactivate
return
fi
fi
fi fi
# activate the environment if pyproject.toml exists # Deactivate the current environment if moving out of a Poetry directory or into a different Poetry directory
if [[ "$poetry_active" != 1 ]]; then if [[ $poetry_active -eq 1 ]] && { [[ $in_poetry_dir -eq 0 ]] || [[ "$PWD" != "$poetry_dir"* ]]; }; then
if [[ -f "$PWD/pyproject.toml" ]]; then export poetry_active=0
if grep -q 'tool.poetry' "$PWD/pyproject.toml" && venv_dir=$(poetry env info --path); then unset poetry_dir
export poetry_active=1 deactivate
export poetry_dir="$PWD" fi
source "${venv_dir}/bin/activate"
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
fi fi
} }
autoload -U add-zsh-hook autoload -U add-zsh-hook
add-zsh-hook chpwd _togglePoetryShell add-zsh-hook chpwd _togglePoetryShell
_togglePoetryShell _togglePoetryShell # Initial call to check the current directory at shell startup

View file

@ -22,7 +22,8 @@ if parsed.scheme not in proxy_protocols:
def make_argv(): def make_argv():
yield "nc" 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 # caveats: macOS built-in netcat command not supported proxy-type
yield "-X" # --proxy-type yield "-X" # --proxy-type
# Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy). # Supported protocols are 4 (SOCKS v4), 5 (SOCKS v5) and connect (HTTP proxy).

View file

@ -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_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_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_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_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` | 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) | | `ZSH_TMUX_FIXTERM_WITHOUT_256COLOR` | `$TERM` to use for non 256-color terminals (default: `tmux` if available, `screen` otherwise) |

View file

@ -13,6 +13,8 @@ fi
: ${ZSH_TMUX_AUTOCONNECT:=true} : ${ZSH_TMUX_AUTOCONNECT:=true}
# Automatically close the terminal when tmux exits # Automatically close the terminal when tmux exits
: ${ZSH_TMUX_AUTOQUIT:=$ZSH_TMUX_AUTOSTART} : ${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 # Set term to screen or screen-256color based on current terminal support
: ${ZSH_TMUX_DETACHED:=false} : ${ZSH_TMUX_DETACHED:=false}
# Set detached mode # Set detached mode
@ -102,9 +104,22 @@ function _zsh_tmux_plugin_run() {
local _detached="" local _detached=""
[[ "$ZSH_TMUX_DETACHED" == "true" ]] && _detached="-d" [[ "$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. # Try to connect to an existing session.
if [[ -n "$ZSH_TMUX_DEFAULT_SESSION_NAME" ]]; then if [[ -n "$session_name" ]]; then
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t $ZSH_TMUX_DEFAULT_SESSION_NAME [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached -t "$session_name"
else else
[[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached [[ "$ZSH_TMUX_AUTOCONNECT" == "true" ]] && $tmux_cmd attach $_detached
fi fi
@ -116,8 +131,9 @@ function _zsh_tmux_plugin_run() {
elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then elif [[ -e "$ZSH_TMUX_CONFIG" ]]; then
tmux_cmd+=(-f "$ZSH_TMUX_CONFIG") tmux_cmd+=(-f "$ZSH_TMUX_CONFIG")
fi 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 else
$tmux_cmd new-session $tmux_cmd new-session
fi fi

View file

@ -86,7 +86,7 @@ _global_commands=(
) )
_yarn_find_package_json() { _yarn_find_package_json() {
local dir=$(cd "$1" && pwd) local dir=$(builtin cd "$1" && pwd)
while true while true
do do
@ -109,7 +109,7 @@ _yarn_commands_scripts() {
if [[ -n $opt_args[--cwd] ]]; then if [[ -n $opt_args[--cwd] ]]; then
packageJson=$(_yarn_find_package_json $opt_args[--cwd]) 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 else
packageJson=$(_yarn_find_package_json $pwd) packageJson=$(_yarn_find_package_json $pwd)
binaries=($(echo node_modules/.bin/*(x:t))) binaries=($(echo node_modules/.bin/*(x:t)))
@ -130,9 +130,9 @@ _yarn_scripts() {
if [[ -n $_yarn_run_cwd ]]; then if [[ -n $_yarn_run_cwd ]]; then
packageJson=$(_yarn_find_package_json $_yarn_run_cwd) packageJson=$(_yarn_find_package_json $_yarn_run_cwd)
if [[ -d "${_yarn_run_cwd}/node_modules" ]]; then 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 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 fi
else else
packageJson=$(_yarn_find_package_json $pwd) packageJson=$(_yarn_find_package_json $pwd)

View file

@ -96,7 +96,7 @@ prompt_context() {
# Git: branch/detached head, dirty status # Git: branch/detached head, dirty status
prompt_git() { prompt_git() {
(( $+commands[git] )) || return (( $+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 return
fi fi
local PL_BRANCH_CHAR local PL_BRANCH_CHAR
@ -106,12 +106,12 @@ prompt_git() {
} }
local ref dirty mode repo_path local ref dirty mode repo_path
if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then if [[ "$(command git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]]; then
repo_path=$(git rev-parse --git-dir 2>/dev/null) repo_path=$(command git rev-parse --git-dir 2>/dev/null)
dirty=$(parse_git_dirty) dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || \ ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref="◈ $(git describe --exact-match --tags HEAD 2> /dev/null)" || \ ref="◈ $(command git describe --exact-match --tags HEAD 2> /dev/null)" || \
ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" ref="➦ $(command git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then if [[ -n $dirty ]]; then
prompt_segment yellow black prompt_segment yellow black
else else
@ -119,8 +119,8 @@ prompt_git() {
fi fi
local ahead behind local ahead behind
ahead=$(git log --oneline @{upstream}.. 2>/dev/null) ahead=$(command git log --oneline @{upstream}.. 2>/dev/null)
behind=$(git log --oneline ..@{upstream} 2>/dev/null) behind=$(command git log --oneline ..@{upstream} 2>/dev/null)
if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
PL_BRANCH_CHAR=$'\u21c5' PL_BRANCH_CHAR=$'\u21c5'
elif [[ -n "$ahead" ]]; then elif [[ -n "$ahead" ]]; then
@ -163,10 +163,10 @@ prompt_bzr() {
done done
local bzr_status status_mod status_all revision 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_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
status_all=$(echo -n "$bzr_status" | head -n1 | 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 if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision ✚" prompt_segment yellow black "bzr@$revision ✚"
else else
@ -182,13 +182,13 @@ prompt_bzr() {
prompt_hg() { prompt_hg() {
(( $+commands[hg] )) || return (( $+commands[hg] )) || return
local rev st branch local rev st branch
if $(hg id >/dev/null 2>&1); then if $(command hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then if $(command hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then if [[ $(command hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added # if files are not added
prompt_segment red white prompt_segment red white
st='±' st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then elif [[ -n $(command hg prompt "{status|modified}") ]]; then
# if any modification # if any modification
prompt_segment yellow black prompt_segment yellow black
st='±' st='±'
@ -196,15 +196,15 @@ prompt_hg() {
# if working copy is clean # if working copy is clean
prompt_segment green $CURRENT_FG prompt_segment green $CURRENT_FG
fi fi
echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st echo -n ${$(command hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
else else
st="" st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') rev=$(command hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null) branch=$(command hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then if command hg st | command grep -q "^\?"; then
prompt_segment red black prompt_segment red black
st='±' st='±'
elif `hg st | grep -q "^[MA]"`; then elif command hg st | command grep -q "^[MA]"; then
prompt_segment yellow black prompt_segment yellow black
st='±' st='±'
else else

View file

@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || {
} }
# Cancel update if: # Cancel update if:
# - the automatic update is disabled. # - the automatic update is disabled
# - the current user doesn't have write permissions nor owns the $ZSH directory. # - the current user doesn't have write permissions nor owns the $ZSH directory
# - is not run from a tty # - 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 ]] \ if [[ "$update_mode" = disabled ]] \
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \ || [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|| [[ ! -t 1 ]] \ || [[ ! -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 unset update_mode
return return
fi fi

View file

@ -10,9 +10,14 @@ fi
# Protect against unwanted sourcing # Protect against unwanted sourcing
case "$ZSH_EVAL_CONTEXT" in 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 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" cd "$ZSH"
verbose_mode="default" verbose_mode="default"