From 0f6836701d82a2ee024153c7f781bb72c2e9a8ac Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 31 Dec 2020 23:20:24 +0100 Subject: fix(CLI): properly get zsh command in `omz update` (#9558) Zsh versions older than 5.3 don't have ZSH_ARGZERO, so use an alternative method to get the zsh command. Fixes #9558 --- lib/cli.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/cli.zsh b/lib/cli.zsh index 92d447a8e..6fcffdf87 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -391,7 +391,9 @@ function _omz::update { # Restart the zsh session if [[ $ret -eq 0 && "$1" != --unattended ]]; then + # Old zsh versions don't have ZSH_ARGZERO + local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}" # Check whether to run a login shell - [[ "$ZSH_ARGZERO" = -* ]] && exec -l "${ZSH_ARGZERO#-}" || exec "$ZSH_ARGZERO" + [[ "$zsh" = -* || -o login ]] && exec -l "${zsh#-}" || exec "$zsh" fi } -- cgit v1.2.3-70-g09d2 From 88ffc2f6666fe1196ae57cc75b559b08e08cb616 Mon Sep 17 00:00:00 2001 From: Seamile Date: Sat, 2 Jan 2021 18:57:06 +0800 Subject: fix(lib): mark changes as MODIFIED on 'MM' in `git_prompt_status` (#9552) In the output of `git status -sb`, 'MM' indicates there are both added and modified changes. This change marks that case as MODIFIED instead of ADDED. --- lib/git.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/git.zsh b/lib/git.zsh index 157c85062..34ffc7ab7 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -170,7 +170,7 @@ function git_prompt_status() { '\?\? ' 'UNTRACKED' 'A ' 'ADDED' 'M ' 'ADDED' - 'MM ' 'ADDED' + 'MM ' 'MODIFIED' ' M ' 'MODIFIED' 'AM ' 'MODIFIED' ' T ' 'MODIFIED' -- cgit v1.2.3-70-g09d2 From 9e5f280f87f2c127896c20edcdd8cd023b5b1893 Mon Sep 17 00:00:00 2001 From: Fernando Crespo Date: Sun, 3 Jan 2021 09:55:57 -0300 Subject: feat(CLI): add `plugin info` subcommand (#9452) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fernando Crespo Co-authored-by: Marc Cornellà --- lib/cli.zsh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/cli.zsh b/lib/cli.zsh index 6fcffdf87..86a0ed3c4 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -37,7 +37,7 @@ function _omz { changelog) local -a refs refs=("${(@f)$(command git for-each-ref --format="%(refname:short):%(subject)" refs/heads refs/tags)}") _describe 'command' refs ;; - plugin) subcmds=('list:List plugins') + plugin) subcmds=('info:Get plugin information' 'list:List plugins') _describe 'command' subcmds ;; pr) subcmds=('test:Test a Pull Request' 'clean:Delete all Pull Request branches') _describe 'command' subcmds ;; @@ -46,6 +46,8 @@ function _omz { esac elif (( CURRENT == 4 )); then case "$words[2]::$words[3]" in + plugin::info) compadd "$ZSH"/plugins/*/README.md(.N:h:t) \ + "$ZSH_CUSTOM"/plugins/*/README.md(.N:h:t) ;; theme::use) compadd "$ZSH"/themes/*.zsh-theme(.N:t:r) \ "$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::) ;; esac @@ -143,6 +145,7 @@ Usage: omz plugin [options] Available commands: + info Get information of a plugin list List all available Oh My Zsh plugins EOF @@ -155,6 +158,29 @@ EOF _omz::plugin::$command "$@" } +function _omz::plugin::info { + if [[ -z "$1" ]]; then + echo >&2 "Usage: omz plugin info " + return 1 + fi + + local readme + for readme in "$ZSH_CUSTOM/plugins/$1/README.md" "$ZSH/plugins/$1/README.md"; do + if [[ -f "$readme" ]]; then + (( ${+commands[less]} )) && less "$readme" || cat "$readme" + return 0 + fi + done + + if [[ -d "$ZSH_CUSTOM/plugins/$1" || -d "$ZSH/plugins/$1" ]]; then + _omz::log error "the '$1' plugin doesn't have a README file" + else + _omz::log error "'$1' plugin not found" + fi + + return 1 +} + function _omz::plugin::list { local -a custom_plugins builtin_plugins custom_plugins=("$ZSH_CUSTOM"/plugins/*(-/N:t)) -- cgit v1.2.3-70-g09d2 From 6b57839292025d17d97410d1627228f3ec730a62 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 5 Jan 2021 19:09:57 +0100 Subject: fix(CLI): show symlinked themes in `omz theme list` --- lib/cli.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/cli.zsh b/lib/cli.zsh index 86a0ed3c4..3346d3973 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -359,8 +359,8 @@ EOF function _omz::theme::list { local -a custom_themes builtin_themes - custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) - builtin_themes=("$ZSH"/themes/*.zsh-theme(.N:t:r)) + custom_themes=("$ZSH_CUSTOM"/**/*.zsh-theme(-.N:r:gs:"$ZSH_CUSTOM"/themes/:::gs:"$ZSH_CUSTOM"/:::)) + builtin_themes=("$ZSH"/themes/*.zsh-theme(-.N:t:r)) # If the command is being piped, print all found line by line if [[ ! -t 1 ]]; then -- cgit v1.2.3-70-g09d2 From c9bf8b4a84d4ae392cf1bdd6a4a7c7c4f7710b92 Mon Sep 17 00:00:00 2001 From: Kyle Gerard Felker Date: Thu, 7 Jan 2021 13:55:18 -0600 Subject: fix(lib): update Emacs terminal detection in `title` function (#9577) Environment variable EMACS was replaced by INSIDE_EMACS --- lib/termsupport.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 778f12bca..33451ef1f 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -10,7 +10,7 @@ function title { emulate -L zsh setopt prompt_subst - [[ "$EMACS" == *term* ]] && return + [[ "$INSIDE_EMACS" == *term* ]] && return # if $2 is unset use $1 as default # if it is set and empty, leave it as is -- cgit v1.2.3-70-g09d2 From 8b37f817c29715873b91c8a8e7f883eccc240895 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Sat, 16 Jan 2021 18:59:24 +0100 Subject: fix(lib): use -N syntax in `head` and `tail` to support Solaris (#6391) Closes #6391 Co-authored-by: Sergey Mashkov --- lib/functions.zsh | 2 +- lib/git.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/functions.zsh b/lib/functions.zsh index 7beb62ad9..c4340f16c 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -1,7 +1,7 @@ function zsh_stats() { fc -l 1 \ | awk '{ CMD[$2]++; count++; } END { for (a in CMD) print CMD[a] " " CMD[a]*100/count "% " a }' \ - | grep -v "./" | sort -nr | head -n20 | column -c3 -s " " -t | nl + | grep -v "./" | sort -nr | head -20 | column -c3 -s " " -t | nl } function uninstall_oh_my_zsh() { diff --git a/lib/git.zsh b/lib/git.zsh index 34ffc7ab7..c9363274c 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -51,7 +51,7 @@ function parse_git_dirty() { FLAGS+="--ignore-submodules=${GIT_STATUS_IGNORE_SUBMODULES:-dirty}" ;; esac - STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -n1) + STATUS=$(__git_prompt_git status ${FLAGS} 2> /dev/null | tail -1) fi if [[ -n $STATUS ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" -- cgit v1.2.3-70-g09d2