Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (41 commits)
  Introducing the ANSI logo graphic
  feat(yarn): add setting to disable adding global dir to `$PATH` (ohmyzsh#10642)
  fix(cli): allow `omz` commands to be used in a script (ohmyzsh#10645)
  feat(multipass): add plugin for multipass (ohmyzsh#10140)
  refactor(zsh_reload)!: remove deprecated plugin
  chore: update copyright year
  refactor(django): remove deprecated `django` plugin
  style(init): use consistent code style in init script (ohmyzsh#10601)
  refactor(installer): use POSIX-standard's `id -u -n` to define `$USER`
  chore(1password): fix comments to follow code (ohmyzsh#10634)
  fix(gitfast): update to git-completion 1.3.6 (ohmyzsh#10633)
  fix(changelog): don't show changelog with only ignored type commits
  style(rkj-repos): change `white` to `default` to support light color schemes (ohmyzsh#6195)
  fix(tmux): use `$ZSH_TMUX_CONFIG` setting in tmuxconf alias
  fix(ys): fix `$VIRTUAL_ENV` check if `nounset` is enabled (ohmyzsh#9915)
  fix(installer): avoid `git clone -c` to support git v1.7.1 (ohmyzsh#10621)
  fix(npx)!: detect new `npx` versions and fail gracefully (ohmyzsh#10452)
  style(updater): silence `git pull` output and show errors in English
  feat(postgres): support Homebrew for Apple Silicon (ohmyzsh#10618)
  fix(cli): make sure to run `zsh` command if an alias exists (ohmyzsh#9737)
  ...
  • Loading branch information
lesterchan committed Feb 5, 2022
2 parents 51217b7 + 2d3bae9 commit ca5e350
Show file tree
Hide file tree
Showing 43 changed files with 1,069 additions and 1,232 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2009-2021 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)
Copyright (c) 2009-2022 Robby Russell and contributors (https://github.com/ohmyzsh/ohmyzsh/contributors)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p align="center"><img src="https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png" alt="Oh My Zsh"></p>
<p align="center"><img src="https://ohmyzsh.s3.amazonaws.com/omz-ansi-github.png" alt="Oh My Zsh"></p>

Oh My Zsh is an open source, community-driven framework for managing your [zsh](https://www.zsh.org/) configuration.

Expand Down
77 changes: 37 additions & 40 deletions lib/cli.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function _omz {
elif (( CURRENT == 3 )); then
case "$words[2]" in
changelog) local -a refs
refs=("${(@f)$(cd "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
refs=("${(@f)$(builtin cd -q "$ZSH"; command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}")
_describe 'command' refs ;;
plugin) subcmds=(
'disable:Disable plugin(s)'
Expand Down Expand Up @@ -105,7 +105,10 @@ function _omz {
return 0
}

compdef _omz omz
# If run from a script, do not set the completion function
if (( ${+functions[compdef]} )); then
compdef _omz omz
fi

## Utility functions

Expand Down Expand Up @@ -176,13 +179,13 @@ function _omz::changelog {
local version=${1:-HEAD} format=${3:-"--text"}

if (
cd "$ZSH"
builtin cd -q "$ZSH"
! command git show-ref --verify refs/heads/$version && \
! command git show-ref --verify refs/tags/$version && \
! command git rev-parse --verify "${version}^{commit}"
) &>/dev/null; then
cat >&2 <<EOF
Usage: omz changelog [version]
Usage: ${(j: :)${(s.::.)0#_}} [version]
NOTE: <version> must be a valid branch, tag or commit.
EOF
Expand All @@ -193,9 +196,9 @@ EOF
}

function _omz::plugin {
(( $# > 0 && $+functions[_omz::plugin::$1] )) || {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: omz plugin <command> [options]
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
Expand All @@ -212,12 +215,12 @@ EOF
local command="$1"
shift

_omz::plugin::$command "$@"
$0::$command "$@"
}

function _omz::plugin::disable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin disable <plugin> [...]"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi

Expand Down Expand Up @@ -289,7 +292,7 @@ multi == 1 && length(\$0) > 0 {
}

# Exit if the new .zshrc file has syntax errors
if ! zsh -n "$zdot/.zshrc"; then
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
Expand All @@ -299,15 +302,13 @@ multi == 1 && length(\$0) > 0 {
# Restart the zsh session if there were no errors
_omz::log info "plugins disabled: ${(j:, :)dis_plugins}."

# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}

function _omz::plugin::enable {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin enable <plugin> [...]"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi

Expand Down Expand Up @@ -365,7 +366,7 @@ multi == 1 && /^[^#]*\)/ {
}

# Exit if the new .zshrc file has syntax errors
if ! zsh -n "$zdot/.zshrc"; then
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
Expand All @@ -375,15 +376,13 @@ multi == 1 && /^[^#]*\)/ {
# Restart the zsh session if there were no errors
_omz::log info "plugins enabled: ${(j:, :)add_plugins}."

# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}

function _omz::plugin::info {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin info <plugin>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin>"
return 1
fi

Expand Down Expand Up @@ -430,7 +429,7 @@ function _omz::plugin::list {

function _omz::plugin::load {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz plugin load <plugin> [...]"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <plugin> [...]"
return 1
fi

Expand Down Expand Up @@ -477,9 +476,9 @@ function _omz::plugin::load {
}

function _omz::pr {
(( $# > 0 && $+functions[_omz::pr::$1] )) || {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: omz pr <command> [options]
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
Expand All @@ -493,7 +492,7 @@ EOF
local command="$1"
shift

_omz::pr::$command "$@"
$0::$command "$@"
}

function _omz::pr::clean {
Expand Down Expand Up @@ -534,7 +533,7 @@ function _omz::pr::test {

# Check the input
if ! [[ -n "$1" && "$1" =~ ^[[:digit:]]+$ ]]; then
echo >&2 "Usage: omz pr test <PR_NUMBER_or_URL>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <PR_NUMBER_or_URL>"
return 1
fi

Expand Down Expand Up @@ -619,9 +618,9 @@ function _omz::reload {
}

function _omz::theme {
(( $# > 0 && $+functions[_omz::theme::$1] )) || {
(( $# > 0 && $+functions[$0::$1] )) || {
cat >&2 <<EOF
Usage: omz theme <command> [options]
Usage: ${(j: :)${(s.::.)0#_}} <command> [options]
Available commands:
Expand All @@ -636,7 +635,7 @@ EOF
local command="$1"
shift

_omz::theme::$command "$@"
$0::$command "$@"
}

function _omz::theme::list {
Expand Down Expand Up @@ -671,7 +670,7 @@ function _omz::theme::list {

function _omz::theme::set {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme set <theme>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
fi

Expand Down Expand Up @@ -721,7 +720,7 @@ EOF
}

# Exit if the new .zshrc file has syntax errors
if ! zsh -n "$zdot/.zshrc"; then
if ! command zsh -n "$zdot/.zshrc"; then
_omz::log error "broken syntax in '"${zdot/#$HOME/\~}/.zshrc"'. Rolling back changes..."
command mv -f "$zdot/.zshrc" "$zdot/.zshrc.new"
command mv -f "$zdot/.zshrc.bck" "$zdot/.zshrc"
Expand All @@ -731,15 +730,13 @@ EOF
# Restart the zsh session if there were no errors
_omz::log info "'$1' theme set correctly."

# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
[[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh"
# Only reload zsh if run in an interactive session
[[ ! -o interactive ]] || _omz::reload
}

function _omz::theme::use {
if [[ -z "$1" ]]; then
echo >&2 "Usage: omz theme use <theme>"
echo >&2 "Usage: ${(j: :)${(s.::.)0#_}} <theme>"
return 1
fi

Expand All @@ -761,13 +758,13 @@ function _omz::theme::use {
}

function _omz::update {
local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)

# Run update script
if [[ "$1" != --unattended ]]; then
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" --interactive || return $?
else
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" || return $?
ZSH="$ZSH" command zsh -f "$ZSH/tools/upgrade.sh" || return $?
fi

# Update last updated file
Expand All @@ -777,7 +774,7 @@ function _omz::update {
command rm -rf "$ZSH/log/update.lock"

# Restart the zsh session if there were changes
if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
if [[ "$1" != --unattended && "$(builtin cd -q "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
# Old zsh versions don't have ZSH_ARGZERO
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
# Check whether to run a login shell
Expand All @@ -787,7 +784,7 @@ function _omz::update {

function _omz::version {
(
cd "$ZSH"
builtin cd -q "$ZSH"

# Get the version name:
# 1) try tag-like version
Expand Down

0 comments on commit ca5e350

Please sign in to comment.