powerlevel9k icon indicating copy to clipboard operation
powerlevel9k copied to clipboard

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

Open TamasBarta opened this issue 5 years ago • 10 comments

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!

TamasBarta avatar Aug 29 '19 11:08 TamasBarta

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?

romkatv avatar Aug 29 '19 11:08 romkatv

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.

TamasBarta avatar Aug 29 '19 12:08 TamasBarta

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

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

$ █

romkatv avatar Aug 29 '19 12:08 romkatv

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.

TamasBarta avatar Aug 29 '19 12:08 TamasBarta

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.

romkatv avatar Aug 29 '19 13:08 romkatv

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

TamasBarta avatar Aug 30 '19 11:08 TamasBarta

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.

romkatv avatar Aug 30 '19 11:08 romkatv

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

FernandoGarcia avatar Sep 04 '19 20:09 FernandoGarcia

@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.

romkatv avatar Sep 05 '19 11:09 romkatv

Thanks for your answer.

FernandoGarcia avatar Sep 05 '19 15:09 FernandoGarcia