Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing Powerleve10k prompt

Tags:

zsh

oh-my-zsh

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?

like image 712
user7496931 Avatar asked Apr 12 '20 18:04

user7496931


People also ask

What is transient prompt?

Transient prompt, when enabled, replaces the prompt with a simpler one to allow more screen real estate. You can use go text/template templates extended with sprig to enrich the text. All template functionality is available, even reusing cross segment template properties from the previous primary prompt run.

What is zsh instant prompt?

Powerlevel10k has a new feature called Instant Prompt. Once enabled, Powerlevel10k prompt will appear instantly after you start zsh, allowing you to get hacking right away. No configuration is required. You'll get instant prompt with the style of your choice even if your zsh configs pull in half the universe.


2 Answers

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.

like image 102
Roman Perepelitsa Avatar answered Oct 17 '22 19:10

Roman Perepelitsa


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)
like image 7
hc_dev Avatar answered Oct 17 '22 19:10

hc_dev