user7496931
user7496931

Reputation: 1519

Customizing Powerleve10k prompt

I just added the Powerlevel10k theme to my zsh and i'm trying to configure certain parts.

It currently looks like this:

enter image description here

The ~/.p10k.zsh has a lot of configurations done and I've been trying to change certain things but i'm not there yet.

I don't want to print the whole path on the left prompt, just the directory. Also, not sure what those numbers indicate in the git section. And the right prompt is displaying my ruby version, although I haven't used Ruby in ages and want to change it to a different setting.

I've tried adding a PS1=... to .zshrc but it seems to be overriden by the P10K config file.

Any suggestions?

Upvotes: 29

Views: 49071

Answers (2)

Roman Perepelitsa
Roman Perepelitsa

Reputation: 2718

Display only the last directory segment

  1. Open ~/.p10k.zsh.
  2. Search for POWERLEVEL9K_SHORTEN_STRATEGY.
  3. Change the value of this parameter to truncate_to_last.

Alternatively, change the value of POWERLEVEL9K_DIR_MAX_LENGTH to 1. This will maximally shorten current directory while keeping the transformation reversible. You can restore the original directory by copy-pasting the shortened directory to the command line and pressing TAB.

Ruby version

Powerlevel10k has several prompt segments that can display Ruby version. By default only those are enabled that display Ruby version when it has been manually overridden by some tool (e.g., rbenv or asdf).

To remove Ruby version from prompt:

  1. Open ~/.p10k.zsh.
  2. Search for POWERLEVEL9K_RIGHT_PROMPT_SEGMENTS.
  3. Remove or comment out the following elements: rbenv, rvm and asdf.

Alternatively (and perhaps preferably), find out which tool is overriding Ruby version for you and remove the override if you no longer need it.

Upvotes: 71

hc_dev
hc_dev

Reputation: 9418

shorten dir segment to show only deepest directory

To show only last n significant path segments, you can set following in your config .zshrc, e.g n=1 means show only last folder in present working directory:

POWERLEVEL9K_SHORTEN_DIR_LENGTH=1

See https://stackoverflow.com/a/49027654

explain Git symbols

The question/exclamation mark in Git segment (vcs segment, next to path) means the number of files untracked (?) and unstaged (!). For detailed description see What do different symbols in Git status mean?

change version segment

You can change the version segment (on the right of prompt) to reflect another tool. For example to replace shown ruby version by python version replace the element within right promt elements in your config .zshrc:

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(rbenv)

by

POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(pyenv)

Upvotes: 13

Related Questions