Skip to content

Commit

Permalink
new segment: per_directory_history (#2384)
Browse files Browse the repository at this point in the history
  • Loading branch information
romkatv committed Jul 25, 2023
1 parent 1d96f5e commit 7e9a79f
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 1 deletion.
14 changes: 14 additions & 0 deletions config/p10k-classic.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
todo # todo items (https://github.com/todotxt/todo.txt-cli)
timewarrior # timewarrior tracking status (https://timewarrior.net/)
taskwarrior # taskwarrior task count (https://taskwarrior.org/)
per_directory_history # Oh My Zsh per-directory-history local/global indicator
# cpu_arch # CPU architecture
# time # current time
# =========================[ Line #2 ]=========================
Expand Down Expand Up @@ -887,6 +888,19 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'

######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]#######
# Color when using local/global history.
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130

# Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION=''
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION=''

# Custom icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐'

################################[ cpu_arch: CPU architecture ]################################
# CPU architecture color.
typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172
Expand Down
14 changes: 14 additions & 0 deletions config/p10k-lean-8colors.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
todo # todo items (https://github.com/todotxt/todo.txt-cli)
timewarrior # timewarrior tracking status (https://timewarrior.net/)
taskwarrior # taskwarrior task count (https://taskwarrior.org/)
per_directory_history # Oh My Zsh per-directory-history local/global indicator
# cpu_arch # CPU architecture
# time # current time
# =========================[ Line #2 ]=========================
Expand Down Expand Up @@ -865,6 +866,19 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'

######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]#######
# Color when using local/global history.
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=5
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=3

# Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION=''
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION=''

# Custom icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐'

################################[ cpu_arch: CPU architecture ]################################
# CPU architecture color.
typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=3
Expand Down
14 changes: 14 additions & 0 deletions config/p10k-lean.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
todo # todo items (https://github.com/todotxt/todo.txt-cli)
timewarrior # timewarrior tracking status (https://timewarrior.net/)
taskwarrior # taskwarrior task count (https://taskwarrior.org/)
per_directory_history # Oh My Zsh per-directory-history local/global indicator
# cpu_arch # CPU architecture
# time # current time
# =========================[ Line #2 ]=========================
Expand Down Expand Up @@ -861,6 +862,19 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'

######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]#######
# Color when using local/global history.
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=135
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=130

# Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION=''
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION=''

# Custom icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐'

################################[ cpu_arch: CPU architecture ]################################
# CPU architecture color.
typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=172
Expand Down
16 changes: 16 additions & 0 deletions config/p10k-rainbow.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
todo # todo items (https://github.com/todotxt/todo.txt-cli)
timewarrior # timewarrior tracking status (https://timewarrior.net/)
taskwarrior # taskwarrior task count (https://taskwarrior.org/)
per_directory_history # Oh My Zsh per-directory-history local/global indicator
# cpu_arch # CPU architecture
# time # current time
# =========================[ Line #2 ]=========================
Expand Down Expand Up @@ -924,6 +925,21 @@
# Custom icon.
# typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'

######[ per_directory_history: Oh My Zsh per-directory-history local/global indicator ]#######
# Color when using local/global history.
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_FOREGROUND=0
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_BACKGROUND=5
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_FOREGROUND=0
typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_BACKGROUND=3

# Tip: Uncomment the next two lines to hide "local"/"global" text and leave just the icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_CONTENT_EXPANSION=''
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_CONTENT_EXPANSION=''

# Custom icon.
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_LOCAL_VISUAL_IDENTIFIER_EXPANSION='⭐'
# typeset -g POWERLEVEL9K_PER_DIRECTORY_HISTORY_GLOBAL_VISUAL_IDENTIFIER_EXPANSION='⭐'

################################[ cpu_arch: CPU architecture ]################################
# CPU architecture color.
typeset -g POWERLEVEL9K_CPU_ARCH_FOREGROUND=0
Expand Down
7 changes: 7 additions & 0 deletions internal/icons.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function _p9k_init_icons() {
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' #
ARCH_ICON 'arch'
HISTORY_ICON 'hist'
)
;;
'awesome-fontconfig')
Expand Down Expand Up @@ -290,6 +291,7 @@ function _p9k_init_icons() {
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' #
ARCH_ICON 'arch'
HISTORY_ICON 'hist'
)
;;
'awesome-mapped-fontconfig')
Expand Down Expand Up @@ -430,6 +432,7 @@ function _p9k_init_icons() {
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' #
ARCH_ICON 'arch'
HISTORY_ICON 'hist'
)
;;
'nerdfont-v3')
Expand Down Expand Up @@ -568,6 +571,7 @@ function _p9k_init_icons() {
SCALA_ICON '\uE737' #
TOOLBOX_ICON '\uE20F'$s #
ARCH_ICON '\uE266' #
HISTORY_ICON '\uF1DA'$s #
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
Expand Down Expand Up @@ -706,6 +710,7 @@ function _p9k_init_icons() {
SCALA_ICON '\uE737' #
TOOLBOX_ICON '\uE20F'$s #
ARCH_ICON '\uE266' #
HISTORY_ICON '\uF1DA'$s #
)
;;
ascii)
Expand Down Expand Up @@ -841,6 +846,7 @@ function _p9k_init_icons() {
SCALA_ICON 'scala'
TOOLBOX_ICON 'toolbox'
ARCH_ICON 'arch'
HISTORY_ICON 'hist'
)
;;
*)
Expand Down Expand Up @@ -978,6 +984,7 @@ function _p9k_init_icons() {
SCALA_ICON 'scala'
TOOLBOX_ICON '\u2B22' #
ARCH_ICON 'arch'
HISTORY_ICON 'hist'
)
;;
esac
Expand Down
27 changes: 26 additions & 1 deletion internal/p10k.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5731,6 +5731,31 @@ _p9k_prompt_cpu_arch_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[machine]$commands[arch]'
}

################################################################
# Oh My Zsh per-directory-history local/global indicator
prompt_per_directory_history() {
if [[ $_per_directory_history_is_global == true ]]; then
_p9k_prompt_segment ${0}_GLOBAL 3 $_p9k_color1 HISTORY_ICON 0 '' global
else
_p9k_prompt_segment ${0}_LOCAL 5 $_p9k_color1 HISTORY_ICON 0 '' local
fi
}

instant_prompt_per_directory_history() {
case $HISTORY_START_WITH_GLOBAL in
true)
_p9k_prompt_segment prompt_per_directory_history_GLOBAL 3 $_p9k_color1 HISTORY_ICON 0 '' global
;;
?*)
_p9k_prompt_segment prompt_per_directory_history_LOCAL 5 $_p9k_color1 HISTORY_ICON 0 '' local
;;
esac
}

_p9k_prompt_per_directory_history_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$PER_DIRECTORY_HISTORY_TOGGLE'
}

# Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with
# YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427.
_p9k_preexec1() {
Expand Down Expand Up @@ -9375,7 +9400,7 @@ if [[ $__p9k_dump_file != $__p9k_instant_prompt_dump_file && -n $__p9k_instant_p
zf_rm -f -- $__p9k_instant_prompt_dump_file{,.zwc} 2>/dev/null
fi

typeset -g P9K_VERSION=1.19.4
typeset -g P9K_VERSION=1.19.5
unset VSCODE_SHELL_INTEGRATION

_p9k_init_ssh
Expand Down

0 comments on commit 7e9a79f

Please sign in to comment.