I have a theme that is written in bash (I think). However, I have decided to use zsh for my shell. More specifically, I'm using oh-my-zsh (a customised zsh I believe).

The theme I want to use is currently in a file called .bash_prompt, which was being sourced from .bash_profile back when the default shell was bash.

Is there anyway I can tell oh-my-zsh to use this prompt? I understand that zsh has a slightly different syntax/language to bash, so sourcing it directly from .zshrc throws quite a lot of errors.

  • Can you show us that "theme" from .bash_prompt? Which errors are shown specifically? – slhck Dec 31 '12 at 17:11
  • Here we are. Here are the errors: .dotfiles/bash/bash_prompt:44: parse error near ]]'` – Oliver Joseph Ash Dec 31 '12 at 17:13
  • Those double brackets are test commands. ( See tldp.org/LDP/abs/html/testconstructs.html#DBLBRACKETS ). You might want to replace that that single brackets or /bin/test (which is the same as a single bracket). – Hennes Dec 31 '12 at 17:24
  • Right, the next error I have is this: .dotfiles/bash/bash_prompt:47: = not found. Seems to be a few small differences between zsh and bash like this, would be nice if they were documented in one place somewhere? – Oliver Joseph Ash Dec 31 '12 at 18:01

No, you generally can't source non-trivial bash scripts in zsh without some modification.

The Z-Shell is most similar to the Korn Shell [ksh], while bash is a superset of the Bourne shell [sh].

There are some syntax differences between sh and ksh shells. Although bash and zsh have considerable feature crossover, implementation details do differ in some respects.

This is particularly noticeable with the if [[ "$VAR" ]]; constructs used in the linked script (they don't seem to work in zsh - if [ $VAR ]; does, though).

However, the modification needed to get the linked script sourced by zsh is pretty minimal.

  • Thanks for the clarification. So are these shells referred to as languages? – Oliver Joseph Ash Jan 13 '13 at 13:26

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.