0

I have configuration files that I use to make my PS1 fancy. The design depends on the presence of a particular font. If the font isn't present, the PS1 looks ugly.

I share access to a webmaster ssh account with other webmasters. I do the majority of the work on the site, so I'd like to have my preferred environment. On the other hand, I do not want to burden the other webmasters with an unpleasant prompt or a font requirement when they're logged in.

I'd like to be able to set some variable when I launch my terminal emulator, so when I setup PS1 in my .zshrc, I can check for the presence of that variable. If it's there, I can be confident that the necessary font is installed and show the fancy PS1 that I prefer to see. If not, I can show a more simple one for my co-webmasters.

The best solution I have so far is a little function that can tell me what terminal emulator I'm using:

function term_emu() {
    echo `basename "/"$(ps -f -p $(cat /proc/$(echo $$)/stat | cut -d \  -f 4) | tail -1 | sed 's/^.* //')`
}

However, it's possible that other webmasters will use mintty but not have the font installed, so this solution is not great.

Any other ideas?

  • If you want to get the process name of your parent, ps -o comm= -p "$PPID" should be enough. – Stéphane Chazelas Dec 22 '15 at 22:23
  • "ps: unknown option -- o" – JoshuaD Dec 22 '15 at 22:30
  • I also think the function is a bit more clever than getting the name of the parent, because the immediate parent might be some other shell, and not the terminal emulator, right? (I didn't write the function and I don't understand it.) – JoshuaD Dec 22 '15 at 22:31
  • What system is that? -o is a standard (POSIX) ps option. – Stéphane Chazelas Dec 22 '15 at 22:32
  • cygwin, ps version 1.7.34 . – JoshuaD Dec 22 '15 at 22:34

Your Answer

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

Browse other questions tagged or ask your own question.