Search code examples
zshiterm2

Why does my zsh have these texts on startup?


I was installing RoR the other day and when I opened my iterm2, this was on startup : enter image description here

This is on my .bash_profile

# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"

export WORKON_HOME=$HOME/.virtualenv
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenv
alias python='/usr/local/bin/python3'
echo 'export PATH="/usr/local/sbin:$PATH"'
alias q='exit'

echo 'export PATH="/usr/local/sbin:$PATH"'
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export GEM_HOME=~/.ruby

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"


export PATH=/Users/highcenoid/gems/bin:/usr/local/opt/sqlite/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

On my .zshrc :

export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH="/Users/user/.oh-my-zsh"
ZSH_THEME="powerlevel9k/powerlevel9k"
DISABLE_AUTO_TITLE="true"
ENABLE_CORRECTION="true"
plugins=(git django npm node pip python yarn brew virtualenv)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status virtualenv)
source $ZSH/oh-my-zsh.sh
export MANPATH="/usr/local/man:$MANPATH"
[[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh ]] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh
[[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh ]] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh
[[ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/slss.zsh ]] && . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/slss.zsh
export DEFAULT_USER="$(whoami)"
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
export PATH="$PATH:$HOME/.rvm/bin"

This is my virtualenv

#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 
'virtualenv==16.4.3','console_scripts','virtualenv'
__requires__ = 'virtualenv==16.4.3'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.exit(
        load_entry_point('virtualenv==16.4.3', 'console_scripts', 
'virtualenv')()
    )

What else do I need to show?


Solution

  • What is happening?

    Your .zshrc looks OK, but problem is with in your .bash_profile. Shell config files are just shell scripts executed when shell starts. And in this line of .bash_profile

    source /usr/local/bin/virtualenv
    

    content of virtualenv file is included into shell script (source is like include or import in other languages). And including any other language source into shell script will always cause errors.

    Why?

    I don't know how virtualenv should be installed and initiated, but this is obviously wrong. My first guesss would be that virtualenv should be a shell script, but something overwrote it with python content. Or - virtualenvs content is OK, but it should not be initiated by sourcing it into .bash_profile, but executed there.

    OK, but how do I fix it?

    There is not much to do, if my first guess is right. Maybe reinstalling virtualenv related stuff could help.

    But in the second case - change the source line mentioned above to

    /usr/local/bin/virtualenv
    

    save the file, and that should do the trick. This tells not to include virtualenv but to execute it.

    PS. export PATH=...

    Last two lines

    export PATH="/usr/local/sbin:$PATH"
    export PATH="/usr/local/sbin:$PATH"
    

    show up, because again your .bash_profile says so. There are two lines: 9 and 12

    echo 'export PATH="/usr/local/sbin:$PATH"'
    

    echo is like print in other languages. So this tells shell to print some static strings. If you don't like that, you can remove those lines or put # in front of them, to comment them out.