Frage

I am using zsh with oh-my-zsh in iTerm (OS X). I encounter the following problem:

  1. echo $ZSH_VERSION returns 4.3.11.
  2. I run upgrade_oh_my_zsh successfully.
  3. echo $ZSH_VERSION again returns 4.3.11.
  4. I run brew install zsh / brew upgrade zsh and I get a Error: zsh-5.0.2 already installed.
  5. Yet even after I restart iTerm echo $ZSH_VERSION returns 4.3.11.

How do I make OMZ use the latest zsh version?

War es hilfreich?

Lösung 2

Solved the issue. My /etc/paths had already /usr/local/bin at the top. When I opened /usr/local/bin/ I saw that besides zsh, I also have zsh-5.2.0. I tried chsh -s /usr/local/bin/zsh-5.2.0 but that didn't help. I removed zsh and renamed zsh-5.2.0 to zsh -> also to no avail. I saw that zsh-5.2.0 was pointing to /usr/local/Cellar/zsh/5.0.2/bin/zsh-5.0.2 and previously I had seen that the original zsh was pointing to /bin/zsh. So what helped me was this:

  • opened /usr/local/Cellar/zsh/5.0.2/bin/ -> contained both zsh and zsh-5.2.0.
  • copied zsh from there to /bin/ and overwrote /bin/zsh
  • restarted iTerm

Andere Tipps

I'm glad you've found a solution. Some notes:

  1. oh-my-zsh is a zsh configuration framework. It is not "zsh", merely the configuration files for the shell. Upgrading oh-my-zsh and zsh itself are two separate, largely unrelated tasks.
  2. Overwriting /bin/zsh with a new binary is one solution. Another is to use a symlink - probably from /usr/local/Cellar/zsh/5.0.2/bin/zsh-5.2.0 to somewhere in your $PATH (like /usr/local/bin/), and setting the shell using chsh. The advantage of a symlink is that you've kept all the binaries (so you still have 4.3, 5.0, 5.2).
  3. This question may shed some light on why chsh didn't work.

I have the following in my ~/.zshrc. It will find a usable zsh in a given list of directories, sort them by version number and exec the newest one.

if [[ $- == *i* ]]; then
    arg=$(
        for dir in \
            /usr/local/bin \
            /usr/gnu/bin \
            /usr/sfw/bin \
            /bin \
            /usr/bin
        do
            arg=$dir/zsh

            # Make sure the shell is a readable, executable file.
            if [[ ! -f $arg || ! -r $arg || ! -x $arg ]]; then
                continue
            fi

            # Print sortable version number and path to shell.
            ver=$( $arg -c 'echo $ZSH_VERSION' 2>/dev/null )
            if [[ -n $ver ]]; then
                printf '%03u%03u%03u %s\n' $( echo $ver | tr '.' ' ' ) $arg
            fi
        done | sort -r | head -1 | cut -c11-
    )

    if [[ -n $arg && $arg != $SHELL ]]; then
        echo "Switching SHELL to $arg"
        export SHELL=$arg
        exec $SHELL -li
    fi
fi

If you want it to search the contents of the PATH variable, you can use

for dir in $( echo "$PATH" | tr ':' ' ' ); do
    (...)

If you have spaces in your directory names, you must use something like

printf '%s\n' "$PATH" | tr ':' '\n' | while read dir; do
    (...)

and add double quotes around $arg and $SHELL some places.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top