2

I'm a long-time bash user just getting used to running zsh, oh-my-zsh, and powerline. I like the setup very much, but have one frustration I can't figure out how to solve.

I occasionally need to copy & paste terminal sessions into emails, text documents, etc. With the default powerline setup, the special characters cause grief, so my thought is to switch my zsh theme to a plain ascii theme. Unfortunately, I can't figure out how to do that from the command line. I'm sure it's possible, but I can't quite figure out the interaction between powerline and the shell to wire it up.

My suggested workflow would be:

  • Open shell session
  • Do work as normal
  • Switch themes to an "ascii only" theme (which powerline includes apparently)
  • Do work for copy/paste
  • Switch themes back to my previous one

I'm comfortable with scripting this as a script or alias, but I can't quite figure out how to start. My google-fu is weak when searching for things like "change powerline theme dynamically", "change zsh prompt dynamically", etc.

Things I've tried:

  • Manually setting the prompt: PS1="\$ ". That sets the left side prompt just fine, but doesn't clear the right side prompt (which usually has git information in my setup)
  • Manually applying a theme: source ~/.oh-my-zsh/themes/my-plain-ascii.zsh-theme. Still doesn't clear the right side prompt

And I'm still unsure how to re-apply my powerline defaults after I'm finished, short of source ~/.zshrc, which works, but seems heavyweight.

1 Answer 1

2
+50

You should be able to source the ascii theme, then unset or clear the RPROMPT variable. So something like

source ~/.oh-my-zsh/themes/my-plain-ascii.zsh-theme
unset RPROMPT
<your work for copying and pasting>
source <powerline-install-directory>/bindings/zsh/powerline.zsh

Of course, you could always just add the unset RPROMPT line to your custom zsh-theme.

3
  • unset RPROMPT in my custom theme didn't work, but RPROMPT="" did. I'm unable to find what variable controls the line that appears above the curent command line. It currently contains the working directory and current git branch. Is there a document somewhere for the variables that represent each part of a prompt? And are these powerline, oh-my-zsh, or zsh variables?
    – Palpatim
    Commented Mar 2, 2017 at 22:15
  • The man pages for zshparam has info about PROMPT/PS1, RPROMPT/RPS1, and other shell variables (these are zsh variables - not unique to powerline or oh-my-zsh). I don't understand what you want to do with the line that appears above the current command line; are you talking about previous commands you've run? What is your my-plain-ascii.zsh-theme?
    – justins
    Commented Mar 2, 2017 at 22:28
  • Thanks for the pointer to zshparam. It looks like the "line above" to which I was referring was an artifact of a previous theme. Once I did a clean startup with a fresh shell, I'm able to switch back & forth between my custom theme and my normal powerline theme by sourceing the appropriate files as you mentioned. Thanks for the help!
    – Palpatim
    Commented Mar 3, 2017 at 15:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .