From 9836aebe672159622193f14a89eedc38ccd29a5d Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Tue, 14 Dec 2021 11:58:58 +0100 Subject: fix(agnoster): quote % in prompt functions --- themes/agnoster.zsh-theme | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'themes') diff --git a/themes/agnoster.zsh-theme b/themes/agnoster.zsh-theme index fe7ddbac6..5f4efe813 100644 --- a/themes/agnoster.zsh-theme +++ b/themes/agnoster.zsh-theme @@ -135,7 +135,7 @@ prompt_git() { zstyle ':vcs_info:*' formats ' %u%c' zstyle ':vcs_info:*' actionformats ' %u%c' vcs_info - echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" + echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" fi } @@ -153,7 +153,7 @@ prompt_bzr() { if bzr_status=$(bzr status 2>&1); then status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m) status_all=$(echo -n "$bzr_status" | head -n1 | wc -m) - revision=$(bzr log -r-1 --log-format line | cut -d: -f1) + revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%} if [[ $status_mod -gt 0 ]] ; then prompt_segment yellow black "bzr@$revision ✚" else @@ -183,7 +183,7 @@ prompt_hg() { # if working copy is clean prompt_segment green $CURRENT_FG fi - echo -n $(hg prompt "☿ {rev}@{branch}") $st + echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st else st="" rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') @@ -197,7 +197,7 @@ prompt_hg() { else prompt_segment green $CURRENT_FG fi - echo -n "☿ $rev@$branch" $st + echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st fi fi } @@ -209,9 +209,8 @@ prompt_dir() { # Virtualenv: current working virtualenv prompt_virtualenv() { - local virtualenv_path="$VIRTUAL_ENV" - if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then - prompt_segment blue black "(`basename $virtualenv_path`)" + if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then + prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})" fi } @@ -237,8 +236,8 @@ prompt_status() { prompt_aws() { [[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return case "$AWS_PROFILE" in - *-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;; - *) prompt_segment green black "AWS: $AWS_PROFILE" ;; + *-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;; + *) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;; esac } -- cgit v1.2.3-70-g09d2 From 4e777ef9d62f70ec971a3eaca71a23b9f4c93a54 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Dec 2021 00:33:20 +0100 Subject: fix(trapd00r): fix potential command injection in `zsh_path` --- themes/trapd00r.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) (limited to 'themes') diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme index 4e3238393..849daf30b 100644 --- a/themes/trapd00r.zsh-theme +++ b/themes/trapd00r.zsh-theme @@ -38,6 +38,8 @@ local c13=$'\e[38;5;196m\e[1m' zsh_path() { + setopt localoptions nopromptsubst + local colors colors=$(echoti colors) -- cgit v1.2.3-70-g09d2 From 43be5ea32150912ae2e85e2cc278c092022ea53f Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Dec 2021 00:38:58 +0100 Subject: fix(bureau): quote % in git prompt function and remove global variables --- themes/bureau.zsh-theme | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'themes') diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 3b3bdc80f..7a253a688 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -17,13 +17,14 @@ ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" bureau_git_branch () { + local ref ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ ref=$(command git rev-parse --short HEAD 2> /dev/null) || return echo "${ref#refs/heads/}" } bureau_git_status() { - _STATUS="" + local _STATUS _INDEX # check status of files _INDEX=$(command git status --porcelain 2> /dev/null) @@ -63,18 +64,22 @@ bureau_git_status() { echo $_STATUS } -bureau_git_prompt () { - local _branch=$(bureau_git_branch) - local _status=$(bureau_git_status) - local _result="" - if [[ "${_branch}x" != "x" ]]; then - _result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch" - if [[ "${_status}x" != "x" ]]; then - _result="$_result $_status" - fi - _result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX" +bureau_git_prompt() { + local branch=$(bureau_git_branch) + local status=$(bureau_git_status) + local info + + if [[ -z "${branch}" ]]; then + return + fi + + info="${branch:gs/%/%%}" + + if [[ -n "${status}" ]]; then + info+=" $status" fi - echo $_result + + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}" } -- cgit v1.2.3-70-g09d2 From a9d57eb2eec4d6234c4714a430ddfb4c57443570 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 27 Dec 2021 15:01:25 +0100 Subject: fix: quote % in `box_name` prompt functions --- themes/candy-kingdom.zsh-theme | 4 +++- themes/fino-time.zsh-theme | 5 +++-- themes/fino.zsh-theme | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'themes') diff --git a/themes/candy-kingdom.zsh-theme b/themes/candy-kingdom.zsh-theme index ad03cc320..31e63df15 100644 --- a/themes/candy-kingdom.zsh-theme +++ b/themes/candy-kingdom.zsh-theme @@ -11,7 +11,9 @@ patches: Date: Mon, 3 Jan 2022 17:05:48 +0100 Subject: fix(bureau): fix `status` variable name causing error (#10561) Also cleaned up the code a bit Fixes #10561 --- themes/bureau.zsh-theme | 53 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'themes') diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 7a253a688..50058e213 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -24,59 +24,58 @@ bureau_git_branch () { } bureau_git_status() { - local _STATUS _INDEX + local result gitstatus # check status of files - _INDEX=$(command git status --porcelain 2> /dev/null) - if [[ -n "$_INDEX" ]]; then - if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED" + gitstatus=$(command git status --porcelain -b 2> /dev/null) + if [[ -n "$gitstatus" ]]; then + if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then + result+="$ZSH_THEME_GIT_PROMPT_STAGED" fi - if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" + if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then + result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED" fi - if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" + if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then + result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED" fi - if $(echo "$_INDEX" | command grep -q '^UU '); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" + if $(echo "$gitstatus" | command grep -q '^UU '); then + result+="$ZSH_THEME_GIT_PROMPT_UNMERGED" fi else - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN" + result+="$ZSH_THEME_GIT_PROMPT_CLEAN" fi # check status of local repository - _INDEX=$(command git status --porcelain -b 2> /dev/null) - if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD" + if $(echo "$gitstatus" | command grep -q '^## .*ahead'); then + result+="$ZSH_THEME_GIT_PROMPT_AHEAD" fi - if $(echo "$_INDEX" | command grep -q '^## .*behind'); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND" + if $(echo "$gitstatus" | command grep -q '^## .*behind'); then + result+="$ZSH_THEME_GIT_PROMPT_BEHIND" fi - if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED" + if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then + result+="$ZSH_THEME_GIT_PROMPT_DIVERGED" fi if $(command git rev-parse --verify refs/stash &> /dev/null); then - _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED" + result+="$ZSH_THEME_GIT_PROMPT_STASHED" fi - echo $_STATUS + echo $result } bureau_git_prompt() { - local branch=$(bureau_git_branch) - local status=$(bureau_git_status) + local gitbranch=$(bureau_git_branch) + local gitstatus=$(bureau_git_status) local info - if [[ -z "${branch}" ]]; then + if [[ -z "$gitbranch" ]]; then return fi - info="${branch:gs/%/%%}" + info="${gitbranch:gs/%/%%}" - if [[ -n "${status}" ]]; then - info+=" $status" + if [[ -n "$gitstatus" ]]; then + info+=" $gitstatus" fi echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}" -- cgit v1.2.3-70-g09d2 From d3bb52d7d825f2a6ce2e1c76ca472b05c6f27b40 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Wed, 5 Jan 2022 09:10:32 +0100 Subject: style: declare globals properly By default, `typeset` defines variables locally unless in the main scope. This is specially bad when using `omz plugin load`, which happens inside a function, so the declared variables don't continue being defined when the function finishes and the main scope reappears. --- plugins/colored-man-pages/colored-man-pages.plugin.zsh | 2 +- plugins/deno/deno.plugin.zsh | 2 +- plugins/fnm/fnm.plugin.zsh | 2 +- plugins/gh/gh.plugin.zsh | 2 +- plugins/helm/helm.plugin.zsh | 2 +- plugins/rbw/rbw.plugin.zsh | 2 +- plugins/rust/rust.plugin.zsh | 4 ++-- plugins/rvm/rvm.plugin.zsh | 2 +- plugins/volta/volta.plugin.zsh | 2 +- themes/dieter.zsh-theme | 2 +- themes/jonathan.zsh-theme | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) (limited to 'themes') diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index 087ddce97..981992d88 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -22,7 +22,7 @@ less_termcap[ue]="${reset_color}" 0="${${(M)0:#/*}:-$PWD/$0}" # Absolute path to this file's directory. -typeset __colored_man_pages_dir="${0:A:h}" +typeset -g __colored_man_pages_dir="${0:A:h}" function colored() { local -a environment diff --git a/plugins/deno/deno.plugin.zsh b/plugins/deno/deno.plugin.zsh index 77c2125d2..6c12bae13 100644 --- a/plugins/deno/deno.plugin.zsh +++ b/plugins/deno/deno.plugin.zsh @@ -32,7 +32,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `deno`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_deno" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _deno _comps[deno]=_deno fi diff --git a/plugins/fnm/fnm.plugin.zsh b/plugins/fnm/fnm.plugin.zsh index e22588792..044e16a04 100644 --- a/plugins/fnm/fnm.plugin.zsh +++ b/plugins/fnm/fnm.plugin.zsh @@ -18,7 +18,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `fnm`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _fnm _comps[fnm]=_fnm fi diff --git a/plugins/gh/gh.plugin.zsh b/plugins/gh/gh.plugin.zsh index 17995e1cf..9263220ca 100644 --- a/plugins/gh/gh.plugin.zsh +++ b/plugins/gh/gh.plugin.zsh @@ -19,7 +19,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `gh`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_gh" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _gh _comps[gh]=_gh fi diff --git a/plugins/helm/helm.plugin.zsh b/plugins/helm/helm.plugin.zsh index 472c1c9dd..c6b91693a 100644 --- a/plugins/helm/helm.plugin.zsh +++ b/plugins/helm/helm.plugin.zsh @@ -14,7 +14,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `helm`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_helm" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _helm _comps[helm]=_helm fi diff --git a/plugins/rbw/rbw.plugin.zsh b/plugins/rbw/rbw.plugin.zsh index 3825be7a6..56683ad06 100644 --- a/plugins/rbw/rbw.plugin.zsh +++ b/plugins/rbw/rbw.plugin.zsh @@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `rbw`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_rbw" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _rbw _comps[rbw]=_rbw fi diff --git a/plugins/rust/rust.plugin.zsh b/plugins/rust/rust.plugin.zsh index 014c73b3b..465b701b0 100644 --- a/plugins/rust/rust.plugin.zsh +++ b/plugins/rust/rust.plugin.zsh @@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # bind it to `cargo`. Otherwise, compinit will have already done that if [[ ! -f "$ZSH_CACHE_DIR/completions/_cargo" ]]; then autoload -Uz _cargo - declare -A _comps + typeset -g -A _comps _comps[cargo]=_cargo fi @@ -19,7 +19,7 @@ fi # bind it to `rustup`. Otherwise, compinit will have already done that if [[ ! -f "$ZSH_CACHE_DIR/completions/_rustup" ]]; then autoload -Uz _rustup - declare -A _comps + typeset -g -A _comps _comps[rustup]=_rustup fi diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 4ba885563..864389ba8 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -1,7 +1,7 @@ # Completion fpath+=("${rvm_path}/scripts/zsh/Completion") -declare -A _comps +typeset -g -A _comps autoload -Uz _rvm _comps[rvm]=_rvm diff --git a/plugins/volta/volta.plugin.zsh b/plugins/volta/volta.plugin.zsh index 756dc84b3..79319394c 100644 --- a/plugins/volta/volta.plugin.zsh +++ b/plugins/volta/volta.plugin.zsh @@ -11,7 +11,7 @@ command mkdir -p "$ZSH_CACHE_DIR/completions" # If the completion file doesn't exist yet, we need to autoload it and # bind it to `deno`. Otherwise, compinit will have already done that. if [[ ! -f "$ZSH_CACHE_DIR/completions/_volta" ]]; then - declare -A _comps + typeset -g -A _comps autoload -Uz _volta _comps[volta]=_volta fi diff --git a/themes/dieter.zsh-theme b/themes/dieter.zsh-theme index 58d9f88a9..83f2dcc7c 100644 --- a/themes/dieter.zsh-theme +++ b/themes/dieter.zsh-theme @@ -6,7 +6,7 @@ # The exit code visual cues will only display once. # (i.e. they will be reset, even if you hit enter a few times on empty command prompts) -typeset -A host_repr +typeset -g -A host_repr # translate hostnames into shortened, colorcoded strings host_repr=('dieter-ws-a7n8x-arch' "%{$fg_bold[green]%}ws" 'dieter-p4sci-arch' "%{$fg_bold[blue]%}p4") diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index 11d799a84..e8c490884 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -66,7 +66,7 @@ if [[ "${langinfo[CODESET]}" = UTF-8 ]]; then PR_LRCORNER="┘" PR_URCORNER="┐" else - typeset -A altchar + typeset -g -A altchar set -A altchar ${(s..)terminfo[acsc]} # Some stuff to help us draw nice lines PR_SET_CHARSET="%{$terminfo[enacs]%}" -- cgit v1.2.3-70-g09d2 From 971683762e3aba543b0dc787e8a5ee1c16b5ace7 Mon Sep 17 00:00:00 2001 From: WeZZard <960509+WeZZard@users.noreply.github.com> Date: Tue, 11 Jan 2022 01:38:35 +0800 Subject: fix(avit): disable `log.showSignatures` in `_git_time_since_commit` (#10072) --- themes/avit.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'themes') diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index 1e20d8f9f..d117c4e94 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -31,7 +31,7 @@ function _git_time_since_commit() { local last_commit now seconds_since_last_commit local minutes hours days years commit_age # Only proceed if there is actually a commit. - if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then + if last_commit=$(command git -c log.showSignatures=false log --format='%at' -1 2>/dev/null); then now=$(date +%s) seconds_since_last_commit=$((now-last_commit)) -- cgit v1.2.3-70-g09d2 From 9c84c344d762b200de7acc794b9a0e7832144e7a Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 10 Jan 2022 19:39:05 +0100 Subject: fix: disable `log.showSignature` in `git log` calls --- plugins/git/git.plugin.zsh | 4 +--- themes/Soliah.zsh-theme | 4 +--- themes/avit.zsh-theme | 2 +- themes/dogenpunk.zsh-theme | 4 +--- themes/smt.zsh-theme | 2 +- themes/wedisagree.zsh-theme | 4 +--- tools/changelog.sh | 2 +- 7 files changed, 7 insertions(+), 15 deletions(-) (limited to 'themes') diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 648fa0a33..8f7e623ec 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -24,9 +24,7 @@ compdef _git _git_log_prettily=git-log # Warn if the current branch is a WIP function work_in_progress() { - if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then - echo "WIP!!" - fi + command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!" } # Check if main exists and use instead of master diff --git a/themes/Soliah.zsh-theme b/themes/Soliah.zsh-theme index 070c54981..c3dd6af89 100644 --- a/themes/Soliah.zsh-theme +++ b/themes/Soliah.zsh-theme @@ -45,9 +45,7 @@ function rvm_gemset() { function git_time_since_commit() { if git rev-parse --git-dir > /dev/null 2>&1; then # Only proceed if there is actually a commit. - if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then - # Get the last commit. - last_commit=`git log --pretty=format:'%at' -1 2> /dev/null` + if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then now=`date +%s` seconds_since_last_commit=$((now-last_commit)) diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme index d117c4e94..f90ba331b 100644 --- a/themes/avit.zsh-theme +++ b/themes/avit.zsh-theme @@ -31,7 +31,7 @@ function _git_time_since_commit() { local last_commit now seconds_since_last_commit local minutes hours days years commit_age # Only proceed if there is actually a commit. - if last_commit=$(command git -c log.showSignatures=false log --format='%at' -1 2>/dev/null); then + if last_commit=$(command git -c log.showSignature=false log --format='%at' -1 2>/dev/null); then now=$(date +%s) seconds_since_last_commit=$((now-last_commit)) diff --git a/themes/dogenpunk.zsh-theme b/themes/dogenpunk.zsh-theme index 6a9921288..923ca74bc 100644 --- a/themes/dogenpunk.zsh-theme +++ b/themes/dogenpunk.zsh-theme @@ -37,9 +37,7 @@ ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}" function git_time_since_commit() { if git rev-parse --git-dir > /dev/null 2>&1; then # Only proceed if there is actually a commit. - if git log -n 1 > /dev/null 2>&1; then - # Get the last commit. - last_commit=`git log --pretty=format:'%at' -1 2> /dev/null` + if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then now=`date +%s` seconds_since_last_commit=$((now-last_commit)) diff --git a/themes/smt.zsh-theme b/themes/smt.zsh-theme index 7f54472c6..52e6d9a21 100644 --- a/themes/smt.zsh-theme +++ b/themes/smt.zsh-theme @@ -40,7 +40,7 @@ function git_time_since_commit() { local last_commit seconds_since_last_commit # Only proceed if there is actually a commit - if ! last_commit=$(command git log --pretty=format:'%at' -1 2>/dev/null); then + if ! last_commit=$(command git -c log.showSignature=false log --pretty=format:'%at' -1 2>/dev/null); then echo "[$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL~%{$reset_color%}]" return fi diff --git a/themes/wedisagree.zsh-theme b/themes/wedisagree.zsh-theme index 07006ecd9..e9e9d6ef8 100644 --- a/themes/wedisagree.zsh-theme +++ b/themes/wedisagree.zsh-theme @@ -69,9 +69,7 @@ function rvm_gemset() { function git_time_since_commit() { if git rev-parse --git-dir > /dev/null 2>&1; then # Only proceed if there is actually a commit. - if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then - # Get the last commit. - last_commit=`git log --pretty=format:'%at' -1 2> /dev/null` + if last_commit=`git -c log.showSignature=false log --pretty=format:'%at' -1 2> /dev/null`; then now=`date +%s` seconds_since_last_commit=$((now-last_commit)) diff --git a/tools/changelog.sh b/tools/changelog.sh index 664f34608..86774a7ea 100755 --- a/tools/changelog.sh +++ b/tools/changelog.sh @@ -414,7 +414,7 @@ function main { # --first-parent: commits from merged branches are omitted local SEP="0mZmAgIcSeP" local -a raw_commits - raw_commits=(${(0)"$(command git log -z \ + raw_commits=(${(0)"$(command git -c log.showSignature=false log -z \ --format="%h${SEP}%D${SEP}%s${SEP}%b" --abbrev=7 \ --no-merges --first-parent $range)"}) -- cgit v1.2.3-70-g09d2 From 4e0f19cf923163104d86308d2366d37da35c0622 Mon Sep 17 00:00:00 2001 From: "GitHubLeakedPAN, GitHubLeakedMyautsai" Date: Sun, 23 Jan 2022 04:56:36 +0800 Subject: feat(ys): show `svn` repository information (#10582) --- themes/ys.zsh-theme | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'themes') diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index 45bbae2d1..5ef500e14 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -19,6 +19,13 @@ ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX" ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY" ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN" +# SVN info +local svn_info='$(svn_prompt_info)' +ZSH_THEME_SVN_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}svn${YS_VCS_PROMPT_PREFIX2}" +ZSH_THEME_SVN_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX" +ZSH_THEME_SVN_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY" +ZSH_THEME_SVN_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN" + # HG info local hg_info='$(ys_hg_prompt_info)' ys_hg_prompt_info() { @@ -66,6 +73,7 @@ PROMPT=" %{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\ ${hg_info}\ ${git_info}\ +${svn_info}\ ${venv_info}\ \ [%*] $exit_code -- cgit v1.2.3-70-g09d2 From d4f5fa37e8be25e1b4f281fcf5b90cf700dc3c95 Mon Sep 17 00:00:00 2001 From: Mathias Neerup Date: Thu, 31 Mar 2016 14:51:47 +0200 Subject: feat(simple): add color to git status indicator (#4962) Closes #4962 --- themes/simple.zsh-theme | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'themes') diff --git a/themes/simple.zsh-theme b/themes/simple.zsh-theme index 8d0070ba7..bcdecc1a5 100644 --- a/themes/simple.zsh-theme +++ b/themes/simple.zsh-theme @@ -1,6 +1,6 @@ -PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~%{$fg_bold[blue]%}$(git_prompt_info)%{$reset_color%} ' +PROMPT='%(!.%{$fg[red]%}.%{$fg[green]%})%~$(git_prompt_info)%{$reset_color%} ' -ZSH_THEME_GIT_PROMPT_PREFIX="(" -ZSH_THEME_GIT_PROMPT_SUFFIX=")" -ZSH_THEME_GIT_PROMPT_DIRTY=" ✗" -ZSH_THEME_GIT_PROMPT_CLEAN=" ✔" +ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg_bold[blue]%}(" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg_bold[blue]%})" +ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗" +ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔" -- cgit v1.2.3-70-g09d2 From 303ae79712d8d1df05b3ec6f63eb129c9a2ed031 Mon Sep 17 00:00:00 2001 From: Kuri Schlarb <246386+ntninja@users.noreply.github.com> Date: Thu, 27 Jan 2022 20:48:42 +0000 Subject: fix(ys): fix `$VIRTUAL_ENV` check if `nounset` is enabled (#9915) --- themes/ys.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'themes') diff --git a/themes/ys.zsh-theme b/themes/ys.zsh-theme index 5ef500e14..4c3c56ffc 100644 --- a/themes/ys.zsh-theme +++ b/themes/ys.zsh-theme @@ -49,7 +49,7 @@ local venv_info='$(virtenv_prompt)' YS_THEME_VIRTUALENV_PROMPT_PREFIX=" %{$fg[green]%}" YS_THEME_VIRTUALENV_PROMPT_SUFFIX=" %{$reset_color%}%" virtenv_prompt() { - [[ -n ${VIRTUAL_ENV} ]] || return + [[ -n "${VIRTUAL_ENV:-}" ]] || return echo "${YS_THEME_VIRTUALENV_PROMPT_PREFIX}${VIRTUAL_ENV:t}${YS_THEME_VIRTUALENV_PROMPT_SUFFIX}" } -- cgit v1.2.3-70-g09d2 From b5edb51ee4bb0b3e9f5cbb0c46348bcbdd941f04 Mon Sep 17 00:00:00 2001 From: Lukas Date: Thu, 27 Jan 2022 22:00:50 +0100 Subject: style(rkj-repos): change `white` to `default` to support light color schemes (#6195) Co-authored-by: Matthias Doering --- themes/rkj-repos.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'themes') diff --git a/themes/rkj-repos.zsh-theme b/themes/rkj-repos.zsh-theme index 65a075456..3cb452335 100644 --- a/themes/rkj-repos.zsh-theme +++ b/themes/rkj-repos.zsh-theme @@ -30,6 +30,6 @@ function mygit() { function retcode() {} # alternate prompt with git & hg -PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[white]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}] +PROMPT=$'%{$fg_bold[blue]%}┌─[%{$fg_bold[green]%}%n%b%{$fg[black]%}@%{$fg[cyan]%}%m%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%{$fg_bold[default]%}%~%{$fg_bold[blue]%}]%{$reset_color%} - %{$fg_bold[blue]%}[%b%{$fg[yellow]%}'%D{"%Y-%m-%d %I:%M:%S"}%b$'%{$fg_bold[blue]%}] %{$fg_bold[blue]%}└─[%{$fg_bold[magenta]%}%?$(retcode)%{$fg_bold[blue]%}] <$(mygit)$(hg_prompt_info)>%{$reset_color%} ' PS2=$' \e[0;34m%}%B>%{\e[0m%}%b ' -- cgit v1.2.3-70-g09d2 From 9e9831fcf22cf77a797eb277f7155c442ff77f16 Mon Sep 17 00:00:00 2001 From: Harris Miller Date: Fri, 4 Feb 2022 13:08:03 -0700 Subject: fix(bureau): fix never `CLEAN` git status (#10656) Closes #10656 --- themes/bureau.zsh-theme | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'themes') diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 50058e213..3ca231f6f 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -25,20 +25,21 @@ bureau_git_branch () { bureau_git_status() { local result gitstatus + gitstatus="$(command git status --porcelain -b 2>/dev/null)" # check status of files - gitstatus=$(command git status --porcelain -b 2> /dev/null) - if [[ -n "$gitstatus" ]]; then - if $(echo "$gitstatus" | command grep -q '^[AMRD]. '); then + local gitfiles="$(tail -n +2 <<< "$gitstatus")" + if [[ -n "$gitfiles" ]]; then + if $(echo "$gitfiles" | command grep -q '^[AMRD]. '); then result+="$ZSH_THEME_GIT_PROMPT_STAGED" fi - if $(echo "$gitstatus" | command grep -q '^.[MTD] '); then + if $(echo "$gitfiles" | command grep -q '^.[MTD] '); then result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED" fi - if $(echo "$gitstatus" | command grep -q -E '^\?\? '); then + if $(echo "$gitfiles" | command grep -q -E '^\?\? '); then result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED" fi - if $(echo "$gitstatus" | command grep -q '^UU '); then + if $(echo "$gitfiles" | command grep -q '^UU '); then result+="$ZSH_THEME_GIT_PROMPT_UNMERGED" fi else @@ -46,13 +47,14 @@ bureau_git_status() { fi # check status of local repository - if $(echo "$gitstatus" | command grep -q '^## .*ahead'); then + local gitbranch="$(head -n 1 <<< "$gitstatus")" + if $(echo "$gitbranch" | command grep -q '^## .*ahead'); then result+="$ZSH_THEME_GIT_PROMPT_AHEAD" fi - if $(echo "$gitstatus" | command grep -q '^## .*behind'); then + if $(echo "$gitbranch" | command grep -q '^## .*behind'); then result+="$ZSH_THEME_GIT_PROMPT_BEHIND" fi - if $(echo "$gitstatus" | command grep -q '^## .*diverged'); then + if $(echo "$gitbranch" | command grep -q '^## .*diverged'); then result+="$ZSH_THEME_GIT_PROMPT_DIVERGED" fi -- cgit v1.2.3-70-g09d2 From 74a3db75e46067ebc627a22b12aac523a9606b92 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 7 Feb 2022 17:44:05 +0100 Subject: perf(bureau): remove multiple grep calls in git status check --- themes/bureau.zsh-theme | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'themes') diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 3ca231f6f..a5a8a2b20 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -16,7 +16,7 @@ ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}" ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}" -bureau_git_branch () { +bureau_git_info () { local ref ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ ref=$(command git rev-parse --short HEAD 2> /dev/null) || return @@ -30,16 +30,16 @@ bureau_git_status() { # check status of files local gitfiles="$(tail -n +2 <<< "$gitstatus")" if [[ -n "$gitfiles" ]]; then - if $(echo "$gitfiles" | command grep -q '^[AMRD]. '); then + if [[ "$gitfiles" =~ $'(^|\n)[AMRD]. ' ]]; then result+="$ZSH_THEME_GIT_PROMPT_STAGED" fi - if $(echo "$gitfiles" | command grep -q '^.[MTD] '); then + if [[ "$gitfiles" =~ $'(^|\n).[MTD] ' ]]; then result+="$ZSH_THEME_GIT_PROMPT_UNSTAGED" fi - if $(echo "$gitfiles" | command grep -q -E '^\?\? '); then + if [[ "$gitfiles" =~ $'(^|\n)\\?\\? ' ]]; then result+="$ZSH_THEME_GIT_PROMPT_UNTRACKED" fi - if $(echo "$gitfiles" | command grep -q '^UU '); then + if [[ "$gitfiles" =~ $'(^|\n)UU ' ]]; then result+="$ZSH_THEME_GIT_PROMPT_UNMERGED" fi else @@ -48,17 +48,18 @@ bureau_git_status() { # check status of local repository local gitbranch="$(head -n 1 <<< "$gitstatus")" - if $(echo "$gitbranch" | command grep -q '^## .*ahead'); then + if [[ "$gitbranch" =~ '^## .*ahead' ]]; then result+="$ZSH_THEME_GIT_PROMPT_AHEAD" fi - if $(echo "$gitbranch" | command grep -q '^## .*behind'); then + if [[ "$gitbranch" =~ '^## .*behind' ]]; then result+="$ZSH_THEME_GIT_PROMPT_BEHIND" fi - if $(echo "$gitbranch" | command grep -q '^## .*diverged'); then + if [[ "$gitbranch" =~ '^## .*diverged' ]]; then result+="$ZSH_THEME_GIT_PROMPT_DIVERGED" fi - if $(command git rev-parse --verify refs/stash &> /dev/null); then + # check if there are stashed changes + if command git rev-parse --verify refs/stash &> /dev/null; then result+="$ZSH_THEME_GIT_PROMPT_STASHED" fi @@ -66,21 +67,22 @@ bureau_git_status() { } bureau_git_prompt() { - local gitbranch=$(bureau_git_branch) - local gitstatus=$(bureau_git_status) - local info - - if [[ -z "$gitbranch" ]]; then + # check git information + local gitinfo=$(bureau_git_info) + if [[ -z "$gitinfo" ]]; then return fi - info="${gitbranch:gs/%/%%}" + # quote % in git information + local output="${gitinfo:gs/%/%%}" + # check git status + local gitstatus=$(bureau_git_status) if [[ -n "$gitstatus" ]]; then - info+=" $gitstatus" + output+=" $gitstatus" fi - echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${info}${ZSH_THEME_GIT_PROMPT_SUFFIX}" + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${output}${ZSH_THEME_GIT_PROMPT_SUFFIX}" } -- cgit v1.2.3-70-g09d2 From 1e26ad1187cdee286d0332dbdffb6828a71140c2 Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Mon, 7 Feb 2022 17:52:57 +0100 Subject: fix(bureau): fix top line space computation Takes into account $ZLE_RPROMPT_INDENT and doesn't add the extra space at the end so it doesn't bleed into the next line. --- themes/bureau.zsh-theme | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'themes') diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index a5a8a2b20..698aa2ff8 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -103,19 +103,14 @@ get_space () { local STR=$1$2 local zero='%([BSUbfksu]|([FB]|){*})' local LENGTH=${#${(S%%)STR//$~zero/}} - local SPACES="" - (( LENGTH = ${COLUMNS} - $LENGTH - 1)) + local SPACES=$(( COLUMNS - LENGTH - ${ZLE_RPROMPT_INDENT:-1} )) - for i in {0..$LENGTH} - do - SPACES="$SPACES " - done - - echo $SPACES + (( SPACES > 0 )) || return + printf ' %.0s' {1..$SPACES} } _1LEFT="$_USERNAME $_PATH" -_1RIGHT="[%*] " +_1RIGHT="[%*]" bureau_precmd () { _1SPACES=`get_space $_1LEFT $_1RIGHT` -- cgit v1.2.3-70-g09d2 From 7b708519b9395914fb47b6c31132fb67fb8b721b Mon Sep 17 00:00:00 2001 From: Marc Cornellà Date: Thu, 10 Feb 2022 18:25:09 +0100 Subject: fix(emotty): show error on missing plugin dependencies (#9811) --- themes/emotty.zsh-theme | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'themes') diff --git a/themes/emotty.zsh-theme b/themes/emotty.zsh-theme index 044b317e8..ba0840950 100644 --- a/themes/emotty.zsh-theme +++ b/themes/emotty.zsh-theme @@ -46,6 +46,16 @@ # is shown (see vcs_action_glyph variable, default: chevron). # ------------------------------------------------------------------------------ +(( ${+functions[emotty]} )) || { + echo "error: the emotty theme requires the emotty plugin" >&2 + return 1 +} + +(( ${+emoji} )) || { + echo "error: the emotty theme requires the emoji plugin" >&2 + return 1 +} + user_prompt="$(emotty)" root_prompt="$emoji[skull]" warn_prompt="$emoji[collision_symbol]" -- cgit v1.2.3-70-g09d2