Powerlevel9k / powerlevel9k

Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
https://github.com/romkatv/powerlevel10k
MIT License
13.46k stars 949 forks source link

Question: can I only display first line of prompt when it changes? #1357

Open TamasBarta opened 4 years ago

TamasBarta commented 4 years ago

I want to achieve a cleaner terminal output, and I thought I want to try printing the first line of the prompt only when it changes, so I still have the info I need, but it isn't printed redundantly over and over with every command.

Is it currently achievable? Thanks!

romkatv commented 4 years ago

Suppose your prompt looks like this:

~/powerlevel9k master >

You type ls and hit ENTER. The output of ls appears on the screen. How should the next prompt look like? Empty line? Just >? Something else?

TamasBarta commented 4 years ago

I have multiple lines in my prompt. One line for the segments, and one for just a $ that is an actual prompt.

It looks rather like this:

 ~/Development/project > my-branch >
 $ 

I only want the first line to appear only on change. The $ should be persistent, so I know when a command finished executing.

romkatv commented 4 years ago

So, after ls prints its output you want only $ as prompt?

~/Development/project > my-branch >
$ ls
foo bar baz

$ █
TamasBarta commented 4 years ago

Exactly, only without the empty line as well if possible. Deep in folders my terminal is crowded by the colourful backgrounds of segments, it may fix that. Sorry if I wasn't clear enough.

romkatv commented 4 years ago

It's fairly easy to implement what you are asking for. It's also fairly easy to always display the current prompt in full but trim it down (perhaps to plain $ or anything else really) once you finish typing the command and hit ENTER. This will make your past prompts concise while the current prompt will stay verbose. I'm not a powerlevel9k developer though, so I cannot make it happen.

There might be an acceptable alternative. Prompts with bright alternating background colors are heavy-weight attention-grabbing beasts. If you have a few of them on your screen, it's difficult to see anything else. Such prompts used to be good for posting pictures on /r/unixporn (not anymore; even there it's considered tacky nowadays) but not for getting things done.

Luckily, powerlevel9k is flexible enough to support a different, lightweight, style reminiscent of Pure or Spaceship themes. You can see an example at https://github.com/Powerlevel9k/powerlevel9k/wiki/Show-Off-Your-Config#pure-power. This screenshot is a bit dated; the current incarnation of Pure Power is even more lightweight. Perhaps if you switch to this or similar style you won't be bothered by multiple copies of the same prompt anymore.

TamasBarta commented 4 years ago

Thanks for the tips, @romkatv! I'll try these, but I also hope the original idea gets some development effort.

romkatv commented 4 years ago

I also hope the original idea gets some development effort.

The last commit to powerlevel9k/master was made 5 months ago. Set your expectations accordingly.

FernandoGarcia commented 4 years ago

Hi! @romkatv I'm interested in this feature too. Can you add it to your 10k theme? Best regards.

romkatv commented 4 years ago

@romkatv I'm interested in this feature too. Can you add it to your 10k theme?

I don't particularly like the idea of showing prompt only when it changes but I can see the value in using different formats for the current and the past prompts. The latter is something I could add. The configuration might look like this:

# Current left prompt.
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir vcs prompt_char)

# Past left prompt.
POWERLEVEL9K_PAST_LEFT_PROMPT_ELEMENTS=(prompt_char)

Keep in mind that you can alleviate the problem of heavy-weight past prompts by running p10k configure and choosing lean style with few icons. This is my personal favorite.

FernandoGarcia commented 4 years ago

Thanks for your answer.