I use powerlevel9k-theme to get a fancy zsh-prompt. But the fonts and glyphs I use to get my desired prompt, are not compatibel with the the terminal emulator I use to ssh into my workstation (JuiceSSH on Android).

I tried to let my .zshrc "detect" which emulator is in use. On my workstation I use gnome-terminal. So I wrote a simple function to check for the existence of a gnome-specific variable $VTE_VERSION:

## functions.zsh: Choose theme based on emulator
function choosetheme() {
 if [ -n "${VTE_VERSION+1}" ]
     zgen load bhilburn/powerlevel9k powerlevel9k ## fancy theme
     zgen oh-my-zsh themes/avit ## basic theme for Android use

And then in my .zshrc:

source functions.zsh

But the result is that powerlevel9k prompt is shown regardless which emulator.

Any ideas how to accomplish this task of having different prompts/themes on different emulators? Or maybe I have overlooked something?

  • Does 'choosetheme` work if you run it interactivly? – icarus Aug 4 '17 at 22:18
  • What's the +1 after ${VTE_VERSION for? – thrig Aug 4 '17 at 23:11
  • @icarus Same result when run interactively. The powerlevel9k prompt is always shown. @thrig I'm actually not quite sure what +1 does. – Tobe Aug 5 '17 at 6:53
  • When I test the function by means of this: if [ -n "${VTE_VERSION+1}" ]; then echo Fancy theme; else echo Basic theme; fi, it correctly prints the echo based on which emulator I use. I think I have to have a closer look at powerlevel9k in combination with zgen framework. I suspect it's not an ordinary theme which can be changed interactively. – Tobe Aug 5 '17 at 6:58

The command

ps -p$PPID | awk '{print $4}'

will return two lines, with the second line being exactly whichever terminal emulator you are using. Hope I helped =)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.