From 54e3e8ef54765bb5d4548864ff2d6cff75a33976 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 29 Sep 2021 17:19:25 +0200 Subject: fix(lib): fix automatic title abort inside Emacs (#10124) Closes #10124 Co-authored-by: Paul Schorfheide Co-authored-by: Alastair Rankine --- lib/termsupport.zsh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 33451ef1f..ef0d78895 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -10,7 +10,8 @@ function title { emulate -L zsh setopt prompt_subst - [[ "$INSIDE_EMACS" == *term* ]] && return + # Don't set the title if inside emacs, unless using vterm + [[ -n "$INSIDE_EMACS" && "$INSIDE_EMACS" != vterm ]] && return # if $2 is unset use $1 as default # if it is set and empty, leave it as is @@ -29,12 +30,9 @@ function title { print -Pn "\e]2;${2:q}\a" # set window name print -Pn "\e]1;${1:q}\a" # set tab name else - # Try to use terminfo to set the title - # If the feature is available set title - if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then - echoti tsl - print -Pn "$1" - echoti fsl + # Try to use terminfo to set the title if the feature is available + if (( ${+terminfo[fsl]} && ${+terminfo[tsl]} )); then + print -Pn "${terminfo[tsl]}$1${terminfo[fsl]}" fi fi ;; @@ -105,10 +103,12 @@ function omz_termsupport_preexec { title '$CMD' '%100>...>$LINE%<<' } -autoload -U add-zsh-hook -add-zsh-hook precmd omz_termsupport_precmd -add-zsh-hook preexec omz_termsupport_preexec +autoload -Uz add-zsh-hook +if [[ -z "$INSIDE_EMACS" || "$INSIDE_EMACS" = vterm ]]; then + add-zsh-hook precmd omz_termsupport_precmd + add-zsh-hook preexec omz_termsupport_preexec +fi # Keep Apple Terminal.app's current working directory updated # Based on this answer: https://superuser.com/a/315029 -- cgit v1.2.3-70-g09d2 From c7a55086e16c8f1895498a859a1ef2806fa1f612 Mon Sep 17 00:00:00 2001 From: Celestino Gomes Date: Wed, 29 Sep 2021 13:07:25 -0300 Subject: feat(lib): don't correct `su` command arguments (#10214) --- lib/correction.zsh | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/correction.zsh b/lib/correction.zsh index c635236b5..4259d3418 100644 --- a/lib/correction.zsh +++ b/lib/correction.zsh @@ -9,6 +9,7 @@ if [[ "$ENABLE_CORRECTION" == "true" ]]; then alias mv='nocorrect mv' alias mysql='nocorrect mysql' alias sudo='nocorrect sudo' + alias su='nocorrect su' setopt correct_all fi -- cgit v1.2.3-70-g09d2 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') 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') 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') 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') 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 From 07cdd7a53931a17a2c24f834c5e1ea0f62609c42 Mon Sep 17 00:00:00 2001 From: Pooya Vahidi <56851682+pooyavahidi@users.noreply.github.com> Date: Sat, 9 Oct 2021 21:02:49 +1100 Subject: fix(lib): fix status exit code check in `git_prompt_status` (#10275) --- lib/git.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index c9363274c..9a615e77b 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -206,7 +206,8 @@ function git_prompt_status() { STASHED UNMERGED AHEAD BEHIND DIVERGED ) - local status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)" + local status_text + status_text="$(__git_prompt_git status --porcelain -b 2> /dev/null)" # Don't continue on a catastrophic failure if [[ $? -eq 128 ]]; then -- cgit v1.2.3-70-g09d2 From f82aa819310752ad754c4ebfd1ae499285ee556e Mon Sep 17 00:00:00 2001 From: michael-yuji Date: Mon, 11 Oct 2021 01:15:24 +0800 Subject: fix(lib): fix `diff --color` argument check for BSD systems (#10269) --- lib/theme-and-appearance.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 0b71de372..00947f72d 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -40,7 +40,7 @@ if [[ "$DISABLE_LS_COLORS" != "true" ]]; then fi # enable diff color if possible. -if command diff --color . . &>/dev/null; then +if command diff --color /dev/null /dev/null &>/dev/null; then alias diff='diff --color' fi -- cgit v1.2.3-70-g09d2