From c280b2784338737aaf75f36e45a3bb84ec3a8b5b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 24 Jun 2023 00:34:42 +0200 Subject: Revert changes to previous commit --- .config/zsh/.zshrc | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) (limited to '.config/zsh') diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index aa9e659..233afaa 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -80,8 +80,8 @@ setopt interactive_comments beep extendedglob nomatch notify completeinword prom ########## Prompt(s) ########## -# Enable colors -autoload -U colors && colors +# Enable colors and change prompt: +autoload -U colors && colors # Load colors # Prompt with Vi insert-mode/normal-mode and blinking '$', note blinking '$' only works on some terminals. terminfo_down_sc=$terminfo[cud1]$terminfo[cuu1]$terminfo[sc]$terminfo[cud1] @@ -102,16 +102,16 @@ git_branch_test_color() { # Job indicator jobs_status_indicator() { - local jobs_output - declare -p jobs_output >/dev/null 2>&1 - if [[ $? -eq 0 ]]; then - unset jobs_output - fi - jobs_output=$(jobs -s) - if [[ -n "$jobs_output" ]]; then - local jobs_count=$(echo "$jobs_output" | wc -l) - echo "jobs: ${jobs_count}" - fi + local jobs_output + declare -p jobs_output >/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + unset jobs_output + fi + jobs_output=$(jobs -s) + if [[ -n "$jobs_output" ]]; then + local jobs_count=$(echo "$jobs_output" | wc -l) + echo "jobs: ${jobs_count}" + fi } remote_indicator() { @@ -128,14 +128,15 @@ zstyle ':vcs_info:*' stagedstr ' +%F{15}staged%f' zstyle ':vcs_info:*' unstagedstr ' -%F{15}unstaged%f' zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' actionformats '%F{5}%F{2}%b%F{3}|%F{1}%a%F{5}%f ' -zstyle ':vcs_info:*' formats '%F{208} '$'\uE0A0'' %f$(git_branch_test_color)%f%F{76}%c%F{3}%u%f ' +zstyle ':vcs_info:*' formats \ + '%F{208} '$'\uE0A0'' %f$(git_branch_test_color)%f%F{76}%c%F{3}%u%f ' zstyle ':vcs_info:git*+set-message:*' hooks git-untracked zstyle ':vcs_info:*' enable git +vi-git-untracked() { if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ [[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then - hook_com[unstaged]+='%F{196} !%f%F{15}untracked%f' - fi + hook_com[unstaged]+='%F{196} !%f%F{15}untracked%f' +fi } # Prompt @@ -148,9 +149,9 @@ function normal-mode() { } function my_precmd () { - vcs_info - PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} \$(remote_indicator)\$(jobs_status_indicator) - %{%{$terminfo_down_sc$(insert-mode)$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" + vcs_info + PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} \$(remote_indicator)\$(jobs_status_indicator) + %{%{$terminfo_down_sc$(insert-mode)$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" } add-zsh-hook precmd my_precmd @@ -163,19 +164,18 @@ function set-prompt() { echo -ne '\e[5 q' VI_MODE=$(insert-mode) fi - PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} \$(remote_indicator)\$(jobs_status_indicator) - %{%{$terminfo_down_sc$VI_MODE$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" + + PS1="%{┌─[%F{145}%n%f] %F{39}%0~%f%} ${vcs_info_msg_0_} \$(remote_indicator)\$(jobs_status_indicator) + %{%{$terminfo_down_sc$VI_MODE$terminfo[rc]%}%{└─%{["%{$(tput setaf 226)%}""%{$(tput blink)%}"%{$%}"%{$(tput sgr0)%}"%{%G]%}%}%}%}" } function update-mode-file() { set-prompt local current_mode=$(cat ~/.vi-mode) local new_mode="$VI_MODE" - if [[ "$new_mode" != "$current_mode" ]]; then echo "$new_mode" >| ~/.vi-mode fi - if command -v tmux &>/dev/null && [[ -n "$TMUX" ]]; then tmux refresh-client -S fi @@ -238,10 +238,8 @@ TRAPWINCH() { # Trap the WINCH signal to update the mode file on window size cha function nvim-listener() { local prev_nvim_status="inactive" local nvim_pid="" - while true; do local current_nvim_pid=$(pgrep -x "nvim") - if [[ -n "$current_nvim_pid" && "$current_nvim_pid" != "$nvim_pid" ]]; then # Neovim started prev_nvim_status="active" @@ -265,8 +263,6 @@ function nvim-listener() { tmux refresh-client -S fi fi - # Add a delay - # sleep 0.5 done } -- cgit v1.2.3