Powerlevel9k: How to copy/paste/share terminal text output cleanly?

Created on 4 May 2017  Â·  9Comments  Â·  Source: Powerlevel9k/powerlevel9k

To show someone a series of terminal commands and their output, it is nice to copy/paste the entire terminal text, prompt and all. oh-my-zsh's default theme was pretty clean for this. powerlevel9k however introduces some noise. Pasting it into a regular web text area, there are special symbols that render as boxes. powerlevel9k's right-aligned content, like the current time, often goes way off the right edge of the screen. What is the recommendation for copy/pasting powerlevel9k terminal output cleanly?

Example direct paste:

 ~/S…/P…/powerlevel9k  master  git branch -r                                                                                                                                              ✓  08:55:40
  origin/HEAD -> origin/master
  origin/debug-svn-icon-color
  origin/master
  origin/merging-awesome-font-fix
  origin/nerdfont-complete
  origin/next
  origin/zsh-async-integration
 ~/S…/P…/powerlevel9k  master  git checkout merging-awesome-font-fix                                                                                                                      ✓  08:55:43
Branch merging-awesome-font-fix set up to track remote branch merging-awesome-font-fix from origin.
Switched to a new branch 'merging-awesome-font-fix'
 ~/S…/P…/powerlevel9k  merging-awesome-font-fix  git remote -v                                                                                                                            ✓  08:55:49
origin  [email protected]:bhilburn/powerlevel9k.git (fetch)
origin  [email protected]:bhilburn/powerlevel9k.git (push)
question

Most helpful comment

Okay, I think @docwhat provided the best option we are going to get in #525, which has now been merged into next. You can now call prompt_powerlevel9k_teardown to go back to a very minimal prompt, which is much more copy/paste-able.

Update your branch to the HEAD of next and enjoy =)

All 9 comments

@john-kurkowski - You're right in that this can be problematic. It is especially problematic if your terminal emulator (or often your multiplexor) grabs the entire screen. Unfortunately, I don't know of a good way to resolve this.

Unfortunately, adding a command that disables parts or all of the prompt to make it easily selectable also won't help, because the terminal emulator wouldn't do this for text that has been already printed - you would have to do it preemptively.

Does anyone else have thoughts on this? I agree it's obnoxious, but I'm honestly not sure it's fixable.

@john-kurkowski I don't think there is a good way to get a clean copy of the terminal output, because the prompt was already printed. These boxes are characters that can not be rendered correctly in the application you paste the content to. Comparing a prompt theme that has no special characters with p9k is a bit unfair, IMHO.

Usually that noise comes from copying the prompt as well. Only way to get that working is to redo your commands and disable p9k prior to that - or redirect the command output to a file. Both ways are no good, because you have to redo your commands which is annoying..

Yeah, I'm just not sure what could be done here.

Adding a command that toggles the prompt on/off is probably our best option, to be honest. It would require you to do it pre-emptively, but that's better than nothing, I suppose. That shouldn't be too hard to implement, as it's simply making a function available to toggle a flag that, if enabled, bypasses the prompt rendering.

Well, I copied a lot of text with an enabled powerlevel9k.
Here is an example of my favourite 'pastebin' called filebin:

The important stuff is still readable.

Another option is a screenshot or to mark only the important text without the prompt.

I don't think this is really a problem

I updated the original comment with an example paste. The prompt is noisy and the timestamps are way off the screen.

@shibumi Your example isn't bad! As you can see from my OP, my prompt does not paste as cleanly. Is your pastebin doing anything special that pasting into e.g. GitHub doesn't?

Can you link to your favorite pastebin? (There are a few hits on Google for "filebin")

Another option is a screenshot or to mark only the important text without the prompt.

A screenshot is a fallback, sure. Though not great for copying a long subset of the paste, like a hash or URL. Not great for screen readers. Often it's not up to the paster to determine what part of it is the "important text."

Okay, I think @docwhat provided the best option we are going to get in #525, which has now been merged into next. You can now call prompt_powerlevel9k_teardown to go back to a very minimal prompt, which is much more copy/paste-able.

Update your branch to the HEAD of next and enjoy =)

I'll give it a try! Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gipert picture gipert  Â·  5Comments

TheBabu picture TheBabu  Â·  5Comments

shibumi picture shibumi  Â·  5Comments

controversial picture controversial  Â·  4Comments

davidmpaz picture davidmpaz  Â·  3Comments