aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-06-24 00:57:02 +0200
committersrdusr <trevorgray@srdusr.com>2023-06-24 00:57:02 +0200
commite4781c00c103fe24e1170f659f96231f5356b0de (patch)
treeacb5af19d1037950dd54d03d1d0af6f5fddb888f
parent409fcdc49aa49bedce3a4908424f6773f11efd15 (diff)
downloaddotfiles-e4781c00c103fe24e1170f659f96231f5356b0de.tar.gz
dotfiles-e4781c00c103fe24e1170f659f96231f5356b0de.zip
Keep changes
-rw-r--r--.config/zsh/.zshrc45
1 files changed, 21 insertions, 24 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc
index 233afaa..f5c7da1 100644
--- a/.config/zsh/.zshrc
+++ b/.config/zsh/.zshrc
@@ -80,12 +80,11 @@ setopt interactive_comments beep extendedglob nomatch notify completeinword prom
########## Prompt(s) ##########
-# Enable colors and change prompt:
-autoload -U colors && colors # Load colors
+# Enable colors
+autoload -U colors && 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]
-
git_branch_test_color() {
local ref=$(git symbolic-ref --short HEAD 2> /dev/null)
if [ -n "${ref}" ]; then
@@ -102,16 +101,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,15 +127,14 @@ 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
@@ -149,9 +147,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
@@ -164,9 +162,8 @@ 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() {
@@ -228,8 +225,8 @@ function zle-keymap-select() {
preexec () { print -rn -- $terminfo[el]; echo -ne '\e[5 q' ; }
-zle -N zle-keymap-select
zle -N zle-line-init
+zle -N zle-keymap-select
TRAPWINCH() { # Trap the WINCH signal to update the mode file on window size changes
update-mode-file