From 5f99eb5afd3c19683f178ddb57bb9345391d3548 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 30 Sep 2021 10:18:53 +0200 Subject: fix(cli): get branch and tags from OMZ folder in `omz changelog` completion --- lib/cli.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/cli.zsh') diff --git a/lib/cli.zsh b/lib/cli.zsh index 2189e24ca..f40a4226e 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -35,7 +35,7 @@ function _omz { elif (( CURRENT == 3 )); then case "$words[2]" in changelog) local -a refs - refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") + refs=("${(@f)$(command git -C "$ZSH" for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") _describe 'command' refs ;; plugin) subcmds=( 'disable:Disable plugin(s)' -- cgit v1.2.3-70-g09d2 From 3c209b00d69499db93fb6aac5c79a6179ff6b855 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 30 Sep 2021 15:41:25 +0200 Subject: feat(cli): show current theme in `omz theme list` Fixes #9540 --- lib/cli.zsh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lib/cli.zsh') diff --git a/lib/cli.zsh b/lib/cli.zsh index f40a4226e..cadc82e27 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -630,17 +630,23 @@ function _omz::theme::list { return fi + # Print theme in use + if [[ -n "$ZSH_THEME" ]]; then + print -Pn "%U%BCurrent theme%b%u: " + [[ $ZSH_THEME = random ]] && echo "$RANDOM_THEME (via random)" || echo "$ZSH_THEME" + echo + fi + + # Print custom themes if there are any if (( ${#custom_themes} )); then print -P "%U%BCustom themes%b%u:" print -l ${(q-)custom_themes} | column -x + echo fi - if (( ${#builtin_themes} )); then - (( ${#custom_themes} )) && echo # add a line of separation - - print -P "%U%BBuilt-in themes%b%u:" - print -l ${(q-)builtin_themes} | column -x - fi + # Print built-in themes + print -P "%U%BBuilt-in themes%b%u:" + print -l ${(q-)builtin_themes} | column -x } function _omz::theme::set { @@ -727,6 +733,10 @@ function _omz::theme::use { _omz::log error "%B$1%b theme not found" return 1 fi + + # Update theme settings + ZSH_THEME="$1" + [[ $1 = random ]] || unset RANDOM_THEME } function _omz::update { -- cgit v1.2.3-70-g09d2 From be4a952972de03d501fbff79435ae41594f06bac Mon Sep 17 00:00:00 2001 From: Monson Shao Date: Fri, 3 Jul 2020 12:16:58 +0800 Subject: feat(cli)!: add `omz reload` command and deprecate `zsh_reload` plugin (#9078) BREAKING CHANGE: the `zsh_reload` plugin is deprecated. Instead of using its `src` function, use `omz reload` or `exec zsh` to reload zsh after making changes to your `.zshrc` file. Closes #9078 --- lib/cli.zsh | 12 ++++++++++++ plugins/zsh_reload/README.md | 22 +--------------------- plugins/zsh_reload/zsh_reload.plugin.zsh | 25 +++++-------------------- 3 files changed, 18 insertions(+), 41 deletions(-) (limited to 'lib/cli.zsh') diff --git a/lib/cli.zsh b/lib/cli.zsh index cadc82e27..773891fce 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -26,6 +26,7 @@ function _omz { 'help:Usage information' 'plugin:Manage plugins' 'pr:Manage Oh My Zsh Pull Requests' + 'reload:Reload the current zsh session' 'theme:Manage themes' 'update:Update Oh My Zsh' ) @@ -159,6 +160,7 @@ Available commands: changelog Print the changelog plugin Manage plugins pr Manage Oh My Zsh Pull Requests + reload Reload the current zsh session theme Manage themes update Update Oh My Zsh @@ -598,6 +600,16 @@ function _omz::pr::test { ) } +function _omz::reload { + # Delete current completion cache + command rm -f $_comp_dumpfile $ZSH_COMPDUMP + + # 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" +} + function _omz::theme { (( $# > 0 && $+functions[_omz::theme::$1] )) || { cat >&2 < Date: Tue, 5 Oct 2021 11:58:39 +0200 Subject: fix(cli): fix zsh array syntax for szh 5.0.2 --- lib/cli.zsh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/cli.zsh') diff --git a/lib/cli.zsh b/lib/cli.zsh index 773891fce..4b14360c1 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -91,7 +91,8 @@ function _omz { # NOTE: $(( CURRENT - 1 )) is the last plugin argument completely passed, i.e. that which # has a space after them. This is to avoid removing plugins partially passed, which makes # the completion not add a space after the completed plugin. - local -a args=(${words[4,$(( CURRENT - 1))]}) + local -a args + args=(${words[4,$(( CURRENT - 1))]}) valid_plugins=(${valid_plugins:|args}) _describe 'plugin' valid_plugins ;; @@ -214,7 +215,7 @@ function _omz::plugin::disable { fi # Check that plugin is in $plugins - local -a dis_plugins=() + local -a dis_plugins for plugin in "$@"; do if [[ ${plugins[(Ie)$plugin]} -eq 0 ]]; then _omz::log warn "plugin '$plugin' is not enabled." @@ -303,7 +304,7 @@ function _omz::plugin::enable { fi # Check that plugin is not in $plugins - local -a add_plugins=() + local -a add_plugins for plugin in "$@"; do if [[ ${plugins[(Ie)$plugin]} -ne 0 ]]; then _omz::log warn "plugin '$plugin' is already enabled." @@ -424,10 +425,8 @@ function _omz::plugin::load { return 1 fi - local plugins=("$@") local plugin base has_completion=0 - - for plugin in $plugins; do + for plugin in "$@"; do if [[ -d "$ZSH_CUSTOM/plugins/$plugin" ]]; then base="$ZSH_CUSTOM/plugins/$plugin" elif [[ -d "$ZSH/plugins/$plugin" ]]; then -- cgit v1.2.3-70-g09d2