Compare commits

...

4 Commits

Author SHA1 Message Date
Ahmed Hosam 0e2d1f1907
Merge d8fbc75bab into 9253fb1c50 2026-06-15 16:13:20 +08:00
Roman Perepelitsa 9253fb1c50 fix a bug that triggers when SH_GLOB is set (#2887) 2026-06-15 09:54:55 +02:00
Ahmed Hosam d8fbc75bab
Update README.md
Specify the version of NixOS, and add the update of `initExtra` in 25.05v of NixOS.
2025-05-15 16:42:43 +03:00
Ahmed Hosam 8de553fbc9
add nixos installation for home-manager and system-wide 2025-05-03 22:40:53 +03:00
3 changed files with 58 additions and 7 deletions

View File

@ -431,6 +431,7 @@ Powerlevel10k.
- [Arch Linux](#arch-linux)
- [Alpine Linux](#alpine-linux)
- [Fig](#fig)
- [NixOS](#nixos)
### Manual
@ -549,6 +550,42 @@ ln -s /usr/share/zsh/plugins/powerlevel10k ~/.local/share/zsh/plugins/
Follow the instructions on
[this page](https://fig.io/plugins/other/powerlevel10k).
### NixOS
**Home Manager**
```nix
programs.zsh = {
...
plugins = [
{
name = "zsh-powerlevel10k";
src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/";
file = "powerlevel10k.zsh-theme";
}
];
# NixOS 24.11 or earlier:
initExtra = ''
source ~/.p10k.zsh
'';
# NixOS 25.05 or later:
# initContent = let initExtra = lib.mkOrder 1000 '' [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh ''; in lib.mkMerge [initExtra];
};
```
**System wide**
```nix
programs.zsh = {
...
promptInit = ''
source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
source ~/.p10k.zsh
'';
};
```
## Configuration
- [For new users](#for-new-users)

View File

@ -138,6 +138,14 @@ function getColorCode() {
return 1
}
function _p9k_codeset_is_utf8() {
# Use `case` to survive SH_GLOB.
case "${langinfo[CODESET]}" in
utf-8|UTF-8|utf8|UTF8) return 0;;
*) return 1;;
esac
}
# _p9k_declare <type> <uppercase-name> [default]...
function _p9k_declare() {
local -i set=$+parameters[$2]
@ -1796,7 +1804,7 @@ prompt_dir() {
if (( $+_POWERLEVEL9K_SHORTEN_DELIMITER )); then
local delim=$_POWERLEVEL9K_SHORTEN_DELIMITER
else
if [[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then
if _p9k_codeset_is_utf8; then
local delim=$'\u2026'
else
local delim='..'
@ -6851,13 +6859,13 @@ function _p9k_restore_special_params() {
}
function _p9k_on_expand() {
(( _p9k__expanded && ! ${+__p9k_instant_prompt_active} )) && [[ "${langinfo[CODESET]}" == (utf|UTF)(-|)8 ]] && return
(( _p9k__expanded && ! ${+__p9k_instant_prompt_active} )) && _p9k_codeset_is_utf8 && return
eval "$__p9k_intro_no_locale"
if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]]; then
if ! _p9k_codeset_is_utf8; then
_p9k_restore_special_params
if [[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]] && _p9k_init_locale; then
if ! _p9k_codeset_is_utf8 && _p9k_init_locale; then
if [[ -n $LC_ALL ]]; then
_p9k__real_lc_all=$LC_ALL
LC_ALL=$__p9k_locale
@ -7458,7 +7466,7 @@ _p9k_init_params() {
_p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_LENGTH
_p9k_declare -i POWERLEVEL9K_VCS_SHORTEN_MIN_LENGTH
_p9k_declare -s POWERLEVEL9K_VCS_SHORTEN_STRATEGY
if [[ $langinfo[CODESET] == (utf|UTF)(-|)8 ]]; then
if _p9k_codeset_is_utf8; then
_p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '\u2026'
else
_p9k_declare -e POWERLEVEL9K_VCS_SHORTEN_DELIMITER '..'
@ -9519,7 +9527,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.20.16
typeset -g P9K_VERSION=1.20.17
if [[ ${VSCODE_SHELL_INTEGRATION-} == <1-> && ${+__p9k_force_term_shell_integration} == 0 ]]; then
typeset -gri __p9k_force_term_shell_integration=1

View File

@ -27,7 +27,13 @@
local -a match mbegin mend
local -i MBEGIN MEND OPTIND
local MATCH OPTARG IFS=$'\'' \t\n\0'\'
typeset -gr __p9k_intro_locale='[[ $langinfo[CODESET] != (utf|UTF)(-|)8 ]] && _p9k_init_locale && { [[ -n $LC_ALL ]] && local LC_ALL=$__p9k_locale || local LC_CTYPE=$__p9k_locale }'
# Use `case` to survive SH_GLOB.
typeset -gr __p9k_intro_locale='{
case "${langinfo[CODESET]}" in
utf-8|UTF-8|utf8|UTF8) false;;
*) true;;
esac
} && _p9k_init_locale && { [[ -n "$LC_ALL" ]] && local LC_ALL=$__p9k_locale || local LC_CTYPE=$__p9k_locale }'
typeset -gr __p9k_intro_no_locale="${${__p9k_intro_base/ match / match reply }/ MATCH / MATCH REPLY }"
typeset -gr __p9k_intro_no_reply="$__p9k_intro_base; $__p9k_intro_locale"
typeset -gr __p9k_intro="$__p9k_intro_no_locale; $__p9k_intro_locale"