### Homebrew Installation Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Install Powerlevel10k using Homebrew and source the theme file in your .zshrc. ```zsh brew install powerlevel10k écho "source $(brew --prefix)/share/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc ``` -------------------------------- ### Example Output for `p10k explain` Source: https://github.com/romkatv/powerlevel10k/blob/master/internal/notes.md This is an example of the expected output format for the `p10k explain` command, which details segment states and their corresponding icons. ```text segment icons meaning --- --- --- --- --- --- --- --- -- status ✔ ✘ exit code of the last command ``` -------------------------------- ### Alpine Linux Installation Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Install Zsh and the powerlevel10k theme package, then create a symbolic link for the plugin. ```zsh apk add zsh zsh-theme-powerlevel10k mkdir -p ~/.local/share/zsh/plugins ln -s /usr/share/zsh/plugins/powerlevel10k ~/.local/share/zsh/plugins/ ``` -------------------------------- ### Install gitstatus via Homebrew Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Install gitstatus using Homebrew and source the prompt script from the Homebrew installation directory. ```zsh brew install romkatv/gitstatus/gitstatus echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.zsh" >>! ~/.zshrc ``` -------------------------------- ### Manual Zsh Installation Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Clone the repository and source the theme file in your .zshrc for manual installation. ```zsh git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc ``` -------------------------------- ### Fixed Instant Prompt Configuration Example Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md This corrected example shows how to move initialization code that requires console input or produces unwanted output above the instant prompt preamble or suppress its output to ensure proper Zsh startup. ```zsh keychain id_rsa --agents ssh # moved before instant prompt # OK to perform console I/O before this point. if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi # From this point on, until zsh is fully initialized, console input won't work and # console output may appear uncolored. chatty-script >/dev/null # spam output suppressed # ... ``` -------------------------------- ### Broken Instant Prompt Configuration Example Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md This example demonstrates a common mistake where initialization code that requires console input or produces excessive output is placed after the instant prompt preamble, potentially breaking the startup process. ```zsh if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi keychain id_rsa --agents ssh # asks for password chatty-script # spams to stdout even when everything is fine # ... ``` -------------------------------- ### Manual Installation of Powerlevel10k Source: https://context7.com/romkatv/powerlevel10k/llms.txt Clone the repository and add the theme to your ~/.zshrc for manual installation. Remember to restart your shell or source the file to apply changes and then run the configuration wizard. ```zsh # Clone the repo git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k # Add to ~/.zshrc echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >> ~/.zshrc # Apply changes exec zsh # Launch the interactive configuration wizard p10k configure ``` -------------------------------- ### Clone Powerlevel10k and Install Gitstatus Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md These commands are run on a machine with internet access to clone the Powerlevel10k repository and install its gitstatus component, preparing for an offline installation. ```sh target_uname="replace this with the output of the previous command" git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k GITSTATUS_CACHE_DIR="$HOME"/powerlevel10k/gitstatus/usrbin ~/powerlevel10k/gitstatus/install -f -s "${target_uname% *}" -m "${target_uname#* }" ``` -------------------------------- ### Install gitstatus via Git Clone Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Clone the gitstatus repository and source the prompt script in your .zshrc. This is the standard installation method. ```zsh git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc ``` -------------------------------- ### Install Powerlevel10k in Docker Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Run this command to try Powerlevel10k in a temporary Docker container. This allows you to experiment with the theme without making changes to your system. Ensure you have Docker installed. ```zsh docker run -e TERM -e COLORTERM -e LC_ALL=C.UTF-8 -it --rm alpine sh -uec ' apk add git zsh nano vim git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k echo "source ~/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc cd ~/powerlevel10k exec zsh' ``` -------------------------------- ### Install GitStatus via Homebrew (Zsh/Bash) Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Install gitstatus using Homebrew and source the prompt script in your .bashrc. Adjust paths if using this method. ```zsh brew install romkatv/gitstatus/gitstatus echo "source $(brew --prefix)/opt/gitstatus/gitstatus.prompt.sh" >> ~/.bashrc ``` -------------------------------- ### Wizard Frame Styles Example Source: https://github.com/romkatv/powerlevel10k/blob/master/internal/notes.md Examples of different frame styles that can be used in the configuration wizard. These styles define the visual appearance of borders and connections. ```text ╭─ ╰─ ┌─ └─ ┏━ ┗━ ╔═ ╚═ ▛▀ ▙▄ ``` -------------------------------- ### Arch Linux Installation Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Install the powerlevel10k Zsh theme package using yay and source the theme file in your .zshrc. ```zsh yay -S --noconfirm zsh-theme-powerlevel10k-git écho 'source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc ``` -------------------------------- ### Get System Architecture Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md This command is used on a machine without internet access to determine the system's architecture, which is needed for the offline installation process. ```sh uname -sm | tr '[A-Z]' '[a-z]' ``` -------------------------------- ### Oh My Zsh Installation of Powerlevel10k Source: https://context7.com/romkatv/powerlevel10k/llms.txt Install Powerlevel10k into the Oh My Zsh custom themes directory and set ZSH_THEME in your ~/.zshrc. Restart your shell and run the configuration wizard. ```zsh # Clone into Oh My Zsh custom themes directory git clone --depth=1 https://github.com/romkatv/powerlevel10k.git \ "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" # In ~/.zshrc, set: ZSH_THEME="powerlevel10k/powerlevel10k" # Restart and run wizard exec zsh p10k configure ``` -------------------------------- ### Update Powerlevel10k (Manual Install) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command if you installed Powerlevel10k manually. Ensure Zsh is restarted after updating. ```bash git -C ~/powerlevel10k pull ``` -------------------------------- ### Manual Zsh Installation (Gitee Mirror) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use the Gitee mirror for faster downloads in China, then source the theme file in your .zshrc. ```zsh git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc ``` -------------------------------- ### Manually Install Powerlevel10k Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this method if your plugin manager has issues. It involves cloning the repository and sourcing the theme file in your ~/.zshrc. ```shell git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k ``` ```shell echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc ``` -------------------------------- ### Install gitstatus via Gitee Mirror Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Use this method for faster downloads in mainland China by cloning from the Gitee mirror and sourcing the prompt script. ```zsh git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.zsh' >>! ~/.zshrc ``` -------------------------------- ### Install GitStatus via Git Clone (Gitee Mirror) Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Clone the gitstatus repository from the Gitee mirror and source the prompt script in your .bashrc for users in China. ```bash git clone --depth=1 https://gitee.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc ``` -------------------------------- ### Uninstall Powerlevel10k (Manual) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k if installed manually. ```sh rm -rf ~/powerlevel10k ``` -------------------------------- ### Define and Style Custom Prompt Segments Source: https://context7.com/romkatv/powerlevel10k/llms.txt Create custom prompt segments by defining functions named `prompt_` and registering them. This example shows how to define a clock segment and a generic 'example' segment, including styling and conditional display. ```zsh # ~/.p10k.zsh # Define a custom segment called "my_clock" function prompt_my_clock() { local time_str=$(date +"%H:%M") p9k_prompt_segment "$0" "cyan" "white" "clock" 0 '' "$time_str" } # Alternatively, use the content/icon expansion pattern: # Register it in prompt elements typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=( ... my_clock ) # Simpler example using the "example" pattern shown in config: function prompt_example() { p9k_prompt_segment "$0_PLAIN" "blue" "white" "" 0 '' "hello" } # Style the custom segment typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208 typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐' # Show this segment only when typing specific commands typeset -g POWERLEVEL9K_EXAMPLE_SHOW_ON_COMMAND='myapp|mytool' ``` -------------------------------- ### Oh My Zsh Installation Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Clone the Powerlevel10k theme into the Oh My Zsh custom themes directory and update ZSH_THEME in .zshrc. ```zsh git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" ``` -------------------------------- ### Oh My Zsh Installation (Gitee Mirror) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use the Gitee mirror for faster downloads in China, then clone into the Oh My Zsh custom themes directory and update ZSH_THEME. ```zsh git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" ``` -------------------------------- ### Uninstall Powerlevel10k (Zi) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zi. ```sh zi delete romkatv/powerlevel10k ``` -------------------------------- ### Uninstall Powerlevel10k (Homebrew) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Homebrew. ```sh brew uninstall powerlevel10k ``` -------------------------------- ### Configure Instant Prompt for Zsh Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Enable Instant Prompt to reduce Zsh startup lag. This feature prints the prompt instantly upon Zsh startup, allowing you to start typing while plugins are still loading. It can be configured via `p10k configure` or manually. -------------------------------- ### Install GitStatus via Git Clone (Bash) Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Clone the gitstatus repository and source the prompt script in your .bashrc for basic Git status integration. ```bash git clone --depth=1 https://github.com/romkatv/gitstatus.git ~/gitstatus echo 'source ~/gitstatus/gitstatus.prompt.sh' >> ~/.bashrc ``` -------------------------------- ### Uninstall Powerlevel10k (Zinit) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zinit. ```sh zinit delete romkatv/powerlevel10k ``` -------------------------------- ### Configure SHOW_ON_COMMAND Parameter for Powerlevel10k Segments Source: https://context7.com/romkatv/powerlevel10k/llms.txt This pattern allows specific prompt segments to appear only when certain commands are being typed, helping to keep the prompt clean. Examples include kubecontext, terraform workspace, AWS profile, and gcloud. ```zsh # ~/.p10k.zsh # Show kubecontext only for k8s-related commands typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|k9s|helmfile|flux' # Show terraform workspace only for terraform commands typeset -g POWERLEVEL9K_TERRAFORM_SHOW_ON_COMMAND='terraform|tofu' # Show AWS profile only for AWS/IaC commands typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|cdk' # Show gcloud only for gcloud commands typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs|gsutil' # Toggle kubecontext on/off dynamically with a shell function: function kube-toggle() { if (( ${+POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND} )); then unset POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND else POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|k9s' fi p10k reload if zle; then zle push-input zle accept-line fi } zle -N kube-toggle bindkey '^]' kube-toggle # Ctrl+] to toggle ``` -------------------------------- ### Uninstall Powerlevel10k (Zap) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zap. ```sh zsh -ic 'zap clean' ``` -------------------------------- ### Uninstall Powerlevel10k (Zim) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zim. ```sh zimfw uninstall ``` -------------------------------- ### Uninstall Powerlevel10k (Antidote) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Antidote. ```sh antidote purge romkatv/powerlevel10k ``` -------------------------------- ### Update Powerlevel10k (Zi) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zi installations. Ensure Zsh is restarted after updating. ```bash zi update ``` -------------------------------- ### Uninstall Powerlevel10k (Oh My Zsh) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Oh My Zsh. ```sh rm -rf -- "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" ``` -------------------------------- ### Update Powerlevel10k (Prezto) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Prezto installations. Ensure Zsh is restarted after updating. ```bash zprezto-update ``` -------------------------------- ### Build MesloLGS NF Font with Docker Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Recreate the recommended MesloLGS NF font using git and docker. Ensure you have both tools installed before running. ```zsh git clone --depth=1 https://github.com/romkatv/nerd-fonts.git cd nerd-fonts ./build 'Meslo/S/*' ``` -------------------------------- ### Configure Show On Command for Kubecontext Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Control when prompt segments appear based on the command being typed. This example shows the 'kubecontext' segment only when typing commands related to kubectl or helm. Customize by editing `~/.p10k.zsh` and modifying `SHOW_ON_COMMAND` parameters. ```zsh typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens' ``` -------------------------------- ### Start and Stop gitstatus Daemon Source: https://context7.com/romkatv/powerlevel10k/llms.txt Manage the background gitstatus daemon process. `gitstatus_start` initiates a named instance with specified options for reporting staged, untracked, conflicted, and unstaged changes. `gitstatus_stop` is used to terminate a running instance. ```zsh # Source the plugin first source ~/gitstatus/gitstatus.plugin.zsh # Start a named instance called "MY" # -s -1 report all staged changes (not just "at least 1") # -u -1 report all untracked files # -c -1 report all conflicted changes # -d -1 report all unstaged changes gitstatus_stop 'MY' && gitstatus_start -s -1 -u -1 -c -1 -d -1 'MY' # Check the daemon PID echo $GITSTATUS_DAEMON_PID_MY ``` -------------------------------- ### Update Powerlevel10k (Zap) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zap installations. Ensure Zsh is restarted after updating. ```bash zap update ``` -------------------------------- ### Update Powerlevel10k (Zinit) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zinit installations. Ensure Zsh is restarted after updating. ```bash zinit update ``` -------------------------------- ### Update Powerlevel10k (Zim) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zim installations. Ensure Zsh is restarted after updating. ```bash zimfw update ``` -------------------------------- ### Update Powerlevel10k (Antidote) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Antidote installations. Ensure Zsh is restarted after updating. ```bash antidote update ``` -------------------------------- ### Add Powerlevel10k to Zshrc for Offline Install Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md This command appends the Powerlevel10k theme source to the ~/.zshrc file, enabling its use on a machine without internet access after files have been copied. ```sh echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc ``` -------------------------------- ### Update Powerlevel10k (Oh My Zsh) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Oh My Zsh installations. Ensure Zsh is restarted after updating. ```bash git -C "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k" pull ``` -------------------------------- ### Run Powerlevel10k Configuration Wizard Source: https://context7.com/romkatv/powerlevel10k/llms.txt Launch the interactive configuration wizard to customize your prompt. This wizard generates a ~/.p10k.zsh file and adds the necessary source line to ~/.zshrc. Re-run it after changing fonts or terminal settings. ```zsh # Run the wizard interactively p10k configure # The wizard writes ~/.p10k.zsh and adds a source line to ~/.zshrc. # To re-run after changing fonts or terminal: p10k configure # Apply manual edits to ~/.p10k.zsh without restarting Zsh: source ~/.p10k.zsh # Reload the theme programmatically (e.g., after changing POWERLEVEL9K_* vars in the shell): p10k reload # Show help for defining custom segments: p10k help segment # Print all available color codes (foreground): getColorCode foreground # Print all available color codes (background): getColorCode background ``` -------------------------------- ### Initialize Direnv with Instant Prompt Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md To initialize direnv correctly when using instant prompt, add these lines before and after the instant prompt preamble in your `.zshrc`. ```zsh (( ${+commands[direnv]} )) && emulate zsh -c "$(direnv export zsh)" if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" fi (( ${+commands[direnv]} )) && emulate zsh -c "$(direnv hook zsh)" ``` -------------------------------- ### Basic Prompt Configuration Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Configure your Zsh prompt by sourcing gitstatus and setting PROMPT and RPROMPT. Insert ${GITSTATUS_PROMPT} where you want git status to appear. ```zsh source ~/gitstatus/gitstatus.prompt.zsh PROMPT='%~%# ' # left prompt: directory followed by %/# (normal/root) RPROMPT='$GITSTATUS_PROMPT' # right prompt: git status ``` -------------------------------- ### Uninstall Powerlevel10k (Zplugin) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zplugin. ```sh zplugin delete romkatv/powerlevel10k ``` -------------------------------- ### Uninstall Powerlevel10k (Zgen) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zgen. ```sh zgen reset ``` -------------------------------- ### Uninstall Powerlevel10k (Zplug) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Zplug. ```sh zplug clean ``` -------------------------------- ### Uninstall Powerlevel10k (Antigen) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Command to uninstall Powerlevel10k when installed via Antigen. ```sh antigen purge romkatv/powerlevel10k ``` -------------------------------- ### Clone and Build Gitstatus (Gitee Mirror) Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Clone the gitstatus repository from the Gitee mirror for faster downloads in China, and then build it using the provided script. This is for personal use. ```zsh git clone --depth=1 https://gitee.com/romkatv/gitstatus.git cd gitstatus ./build -w -s -d docker ``` -------------------------------- ### Baseline ListDir Implementation Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/docs/listdir.md A straightforward C++ implementation for listing directory contents and sorting them lexicographically. Returns an empty list on error. ```cpp vector ListDir(const char* dirname) { vector entries; if (DIR* dir = opendir(dirname)) { while (struct dirent* ent = (errno = 0, readdir(dir))) { if (!Dots(ent->d_name)) entries.push_back(ent->d_name); } if (errno) entries.clear(); sort(entries.begin(), entries.end()); closedir(dir); } return entries; } ``` -------------------------------- ### Minimal Prompt with Gitstatus Integration Source: https://context7.com/romkatv/powerlevel10k/llms.txt This snippet shows how to source the gitstatus prompt configuration and sets up the PROMPT variable for a minimal prompt. ```zsh source ~/gitstatus/gitstatus.prompt.zsh # sources gitstatus.plugin.zsh + sets up PROMPT # PROMPT becomes: user@host ~/path branch ⇣42⇡42 *2 ~1 +3 !1 ?2 # ↑ ↑ ↑ ↑ ↑ # stash conf staged unstaged untracked ``` -------------------------------- ### Update Powerlevel10k (Homebrew) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Homebrew installations. Ensure Zsh is restarted after updating. ```bash brew update && brew upgrade ``` -------------------------------- ### Optimize Auto-Wizard Check Performance Source: https://github.com/romkatv/powerlevel10k/blob/master/internal/notes.md These commands demonstrate performance benchmarks for optimizing the auto-wizard check. The results show the time taken for different parameter checks, highlighting the efficiency gains from checking fewer parameters. ```zsh time ( repeat 1000 [[ -z "${parameters[(I)POWERLEVEL9K_*~(POWERLEVEL9K_MODE|POWERLEVEL9K_CONFIG_FILE)]}" ]] ) user=0.21s system=0.05s cpu=99% total=0.264 time ( repeat 1000 [[ -z "${parameters[(I)POWERLEVEL9K_*]}" ]] ) user=0.17s system=0.00s cpu=99% total=0.175 ``` -------------------------------- ### Configure Zsh for Powerlevel9k Prompt Spacing Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Add these parameters to your ~/.zshrc to ensure prompt spacing matches Powerlevel9k. ZLE_RPROMPT_INDENT=0 aligns the right prompt to the screen edge. POWERLEVEL9K_LEGACY_ICON_SPACING=true restores Powerlevel9k's icon spacing behavior. ```shell ZLE_RPROMPT_INDENT=0 ``` ```shell POWERLEVEL9K_LEGACY_ICON_SPACING=true ``` -------------------------------- ### Update Powerlevel10k (Zplugin) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zplugin installations. Ensure Zsh is restarted after updating. ```bash zplugin update ``` -------------------------------- ### Check for Powerlevel10k References Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command during uninstallation to verify that all references to 'p10k' and 'powerlevel10k' have been removed from your shell configuration files. ```sh grep -E 'p10k|powerlevel10k' ~/.zshrc ~/.zpreztorc ~/.zimrc 2>/dev/null ``` -------------------------------- ### Clone and Build Gitstatus (GitHub) Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/README.md Clone the gitstatus repository from GitHub and build it using the provided script. This is for personal use and ensures the binary is placed in the correct location. ```zsh git clone --depth=1 https://github.com/romkatv/gitstatus.git cd gitstatus ./build -w -s -d docker ``` -------------------------------- ### Update Powerlevel10k (Zgen) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zgen installations. Ensure Zsh is restarted after updating. ```bash zgen update ``` -------------------------------- ### Update Powerlevel10k (Zplug) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Zplug installations. Ensure Zsh is restarted after updating. ```bash zplug update ``` -------------------------------- ### Optimized ListDir implementation Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/docs/listdir.md This is the main ListDir function incorporating optimizations. It uses openat, direct getdents64 calls, custom sorting with aligned 64-bit reads and byte swapping, and finally byte swaps the entries back. ```c++ void ListDir(int parent_fd, Arena& arena, vector& entries) { entries.clear(); int dir_fd = openat(parent_fd, dirname, O_NOATIME | O_RDONLY | O_DIRECTORY | O_CLOEXEC); if (dir_fd < 0) return; arena.Clear(); while (true) { char* buf = arena.Alloc(); int n = syscall(SYS_getdents64, dir_fd, buf, Arena::kBlockSize - 256); if (n <= 0) { if (n) entries.clear(); break; } for (int pos = 0; pos < n;) { auto* ent = reinterpret_cast(buf + pos); if (!Dots(ent->d_name)) { ByteSwap64(ent->d_name); entries.push_back(ent->d_name); } pos += ent->d_reclen; } } sort(entries.begin(), entries.end(), [](const char* a, const char* b) { uint64_t x = Read64(a); uint64_t y = Read64(b); return x < y || (x == y && a != b && memcmp(a + 5, b + 5, 256) < 0); }); for (char* p : entries) ByteSwap64(p); close(dir_fd); } ``` -------------------------------- ### Export GPG_TTY for Instant Prompt Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md This is the recommended way to export GPG_TTY, which works with or without instant prompt and is more efficient than alternatives. ```zsh export GPG_TTY=$TTY ``` -------------------------------- ### Update Powerlevel10k (Antigen) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Antigen installations. Ensure Zsh is restarted after updating. ```bash antigen update ``` -------------------------------- ### Configure Global Appearance Parameters for Powerlevel10k Source: https://context7.com/romkatv/powerlevel10k/llms.txt These parameters control the overall look of the powerlevel10k prompt, including icon/font mode, background, spacing, and separators. ```zsh # ~/.p10k.zsh # Icon/font mode: nerdfont-complete | nerdfont-v3 | awesome-fontconfig | ascii typeset -g POWERLEVEL9K_MODE=nerdfont-complete # Transparent background (lean style) vs colored background (classic/rainbow) # typeset -g POWERLEVEL9K_BACKGROUND= # transparent # typeset -g POWERLEVEL9K_BACKGROUND=236 # dark grey background for all segments # No surrounding whitespace around segments typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # Space between consecutive segments typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # Powerline-style segment separators (for classic/rainbow style): # typeset -g POWERLEVEL9K_LEFT_SEGMENT_SEPARATOR='\uE0B0' # # typeset -g POWERLEVEL9K_RIGHT_SEGMENT_SEPARATOR='\uE0B2' # # Icon placement: before content on left, after content on right typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true # Empty line before each prompt typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true # Horizontal ruler between prompts instead of blank line: typeset -g POWERLEVEL9K_SHOW_RULER=false typeset -g POWERLEVEL9K_RULER_CHAR='─' typeset -g POWERLEVEL9K_RULER_FOREGROUND=240 # Filler between left and right prompt (alternative to ruler): typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='·' typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=240 ``` -------------------------------- ### List Directory using openat() in C++ Source: https://github.com/romkatv/powerlevel10k/blob/master/gitstatus/docs/listdir.md This C++ function efficiently lists directory entries by utilizing openat() with a parent directory file descriptor. It avoids the performance overhead of opendir() and optimizes memory usage. ```cpp void ListDir(int parent_fd, const char* dirname, string& arena, vector& entries) { // + entries.clear(); int dir_fd = openat(parent_fd, dirname, O_NOATIME | O_RDONLY | O_DIRECTORY | O_CLOEXEC); // + if (dir_fd < 0) return; // + if (DIR* dir = fdopendir(dir_fd)) { arena.clear(); while (struct dirent* ent = (errno = 0, readdir(dir))) { if (!Dots(ent->d_name)) { entries.push_back(reinterpret_cast(arena.size())); arena.append(ent->d_name, strlen(ent->d_name) + 1); } } if (errno) entries.clear(); for (char*& p : entries) p = &arena[reinterpret_cast(p)]; sort(entries.begin(), entries.end(), [](const char* a, const char* b) { return strcmp(a, b) < 0; }); closedir(dir); } else { // + close(dir_fd); // + } // + ``` -------------------------------- ### Update Powerlevel10k (Alpine Linux) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Alpine Linux installations. Ensure Zsh is restarted after updating. ```bash apk update && apk upgrade ``` -------------------------------- ### Update Powerlevel10k (Arch Linux) Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command for Arch Linux installations. Ensure Zsh is restarted after updating. ```bash yay -S --noconfirm zsh-theme-powerlevel10k-git ``` -------------------------------- ### Configure Python Environment Segments (pyenv, virtualenv, anaconda) Source: https://context7.com/romkatv/powerlevel10k/llms.txt Configure settings for pyenv, virtualenv, and anaconda segments independently. Options include foreground colors, sources to check, display logic, and conditions for showing or hiding versions. ```zsh # ~/.p10k.zsh ## pyenv typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37 typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global) typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false # Format: show env name and python version if they differ typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}' ## virtualenv typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37 typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false # Don't show virtualenv if pyenv already shows the same version typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false ## anaconda typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37 # Show just the env name (strip surrounding parentheses from CONDA_PROMPT_MODIFIER) typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }% \):-${CONDA_PREFIX:t}}' ``` -------------------------------- ### Check Powerlevel10k Version Source: https://github.com/romkatv/powerlevel10k/blob/master/README.md Use this command to verify if Powerlevel10k has been loaded. If it succeeds, remove the old theme setting from .zshrc. ```zsh typeset -p P9K_VERSION ```