Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am using Robby Russell's "oh-my-zsh" extension on OSX 10.5 Leopard. However I find that it's not loaded by default.. when I start a new Terminal it uses the "default" ZSH prompt, and I must manually type "zsh" and press Return to get the "enhanced" prompt. My .zshrc file lists the ZSH path as pointing to the oh-my-zsh directory:

This gets very annoying because every time I open a new tab I've got to type zsh again (as an aside is it possible to get a new tab to remember my current working directory? I mainly write Rails apps so I'll have 2-3 windows open inside the same directory and it's frustrating to have to cd back into it every time). Is there an easy way to get it automatically start oh-my-zsh when I open a terminal so I don't have to type zsh every time?

EDIT

I automatically installed oh-my-zsh following Robby's instructions on Github, so here's the .zshrc it created for me:

# Path to your oh-my-zsh configuration.
export ZSH=$HOME/.oh-my-zsh

# Set to the name theme to load.
# Look in ~/.oh-my-zsh/themes/
export ZSH_THEME="maran"

# Comment this out to disable weekly auto-update checks
# export DISABLE_AUTO_UPDATE="false"

source $ZSH/oh-my-zsh.sh

# Customize to your needs...
export     PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr  /local/bin:/usr/X11/bin:/usr/local/git/bin
export GIT_EDITOR="mate -w"

I tried changing the default shell to point to that but then I get an error saying it's been set to an illegal variable. The $HOME variable points correctly to my home directory, but it doesn't seem to be loading until I type zsh in the terminal when I have the regular zsh prompt.

EDIT

Here is the output of pstree -wp $$

-+= 00001 root /sbin/launchd
 \-+= 00066 waynemolina /sbin/launchd
   \-+= 68844 waynemolina /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_704684
     \-+= 68845 root login -pfq waynemolina /bin/zsh
       \-+= 68846 waynemolina -zsh
         \-+= 68939 waynemolina pstree -wp 68846
           \--- 68940 root ps -axwwo user
share|improve this question

4 Answers 4

up vote 2 down vote accepted
+50

Back in 10.4, Terminal has a preference for “When creating a new Terminal window” to either use /usr/bin/login or to let the user specify a command. I expect that Terminal in 10.5 has something similar.

Do you happen to have something like zsh -f as the specified command instead of using /usr/bin/login or a zsh invocation without -f? The -f option will cause zsh to ignore all the startup files except /etc/zshenv (i.e. it will ignore your ~/.zshrc).

Another way to check this setting might be with defaults read com.apple.Terminal Shell. If it shows some output you have a custom setting. If it is blank or does not exist then you are probably still using the default of /usr/bin/login.

Edited to add:
In one of your shells with the default prompt (a new Terminal window or tab), check for the following:

  • Does set -o | fgrep rcs show “on” for norcs?
  • Does [[ "$ZDOTDIR" -ef "$HOME" ]] || echo "ZDOTDIR=$ZDOTDIR" show anything?

If one or both of these conditions are true, you'll need to track down where they are being set. Note that norcs might be set with any of set +o rcs, set -o norcs, setopt norcs, unsetopt rcs, or set -f. Also the option names are not case sensitive and may have underscores inserted anythere (NO_rC___s is the same as norcs). Look in /etc/zshenv, /etc/zprofile, /etc/zshrc, /etc/zlogin; and .zshenv, .zprofile, .zshrc, and .zlogin from your ZDOTDIR directory.

It might also be useful to know the full parentage of your “default prompt” shells (pstree -wp $$ if you have pstree from (e.g.) MacPorts). Maybe the normal ‘rc’ process is being interrupted by something like zsh -f in an ‘rc’ file.

share|improve this answer
    
It was using /usr/bin/login according to the settings, but I changed it to /bin/zsh and it's still running the "default" zsh prompt and not my enhanced one. –  Wayne M Oct 28 '09 at 12:19
    
I tried both commands you posted, rcs is "off" and ZDOTDIR is empty. –  Wayne M Oct 31 '09 at 2:12
    
Do you mean that you see norcs off (which is the default and means that your ‘rc’ files should be used)? The debug echos you put in based on Ryan's answer also seem to indicate that norcs is off for your “New Tab”/“New Window” case. I just wanted to clarify since 'rcs is "off"' is actually the opposite of 'norcs is "off"'. –  Chris Johnsen Oct 31 '09 at 8:43

I don't know too much about how Mac OS X works with shells, but in general I find it useful to sprinkle some echo statements around my initialization files, to make sure that they are being sourced. So, in your .zshrc file, you could put a line that says echo "Loading .zshrc". And so on. The presence or absence of these echo statements when you start a new shell (or open a new tab) should help you diagnose the problem.

As for the directory changing problem, there are two potential solutions:
1. Use screen, and forget about tabs.
2. Write a function to echo the current directory to a file somewhere, then put that function in your precmd, and then add a line in .zshrc to read that file and cd to it. To be more specific (but untested!):

PWD_SAVE_FILE="$HOME/.pwd_save"
function savepwd {
  pwd > "$PWD_SAVE_FILE"
}

function precmd {
  savepwd
}

cd "`cat "$PWD_SAVE_FILE"`"
share|improve this answer
    
+1 for ‘echo debug’ technique; just be sure to remove them (or comment them out) when done, otherwise the echo output from non-login ‘rc’ files (.zshenv, .zshrc, and the global equivalents) can confuse tools that ssh-in and directly run commands (e.g. rsync, git) –  Chris Johnsen Oct 30 '09 at 21:42
    
I did an echo and it was outputted properly when I loaded a new command prompt. It's also run when I type the "zsh" command, so it's getting loaded but for some reason the enhanced prompt isn't appearing until I type zsh manually –  Wayne M Oct 31 '09 at 2:19
    
Well, I don't actually have a Mac, so I can't help you with Mac-specific weirdness. Only general weirdness, and possibly zsh-specific weirdness. –  Ryan Thompson Nov 3 '09 at 8:04

I had this problem. It was due to having a .zlogin in my home directory. Once I removed .zlogin oh my zsh worked

share|improve this answer

Try putting this in your ~/.zshrc file for debugging purposes:

Right after this line:

export ZSH=$HOME/.oh-my-zsh

Put:

echo $HOME
echo $ZSH
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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