I was installing RoR the other day and when I opened my iterm2, this was on startup :
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?
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.
Related
I set up an NPM_TOKEN in my .zshrc file. When I run yarn start in a terminal my Gatsby app runs fine, but when I create an NPM run configuration in WebStorm for start, it can't find the token:
error An unexpected error occurred: "Failed to replace env in config: ${NPM_TOKEN}".
I actually get the same error when attempting to commit from Webstorm. Works fine in terminal (even the WS terminal)
I have Fig installed, and ohmyzsh, and here is my .zshrc file.
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source
"$HOME/.fig/shell/zshrc.pre.zsh"
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git)
source $ZSH/oh-my-zsh.sh
source ~/.zprofile # loads some custom aliases using "source
.aliases/some_alias_file.zsh" etc
export NPM_TOKEN="my token"
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"
export NVM_DIR="$HOME/.nvm"
Is there a way to fix this?
UPDATE: Adding my NPM_TOKEN to .bashrc fixed this. So I guess Webstorm is running bash, or reading that file, instead of zsh and reading its config files? We're slightly over my head at this point. But I would imagine there's a way to configure this?
Running python3 xx.py in my specific folder
shows Import Error
But, I go to my home directory ,and add the new files with same code
and then it can work well. Why?
I checked both sys.path in these two, the path is same
find pycache, init.py
ls -l
remove it
rm -rf "pycache" "init.py" it works!
Finally,it is solved
What's the write command line for watching and compiling .less files. I want to watch a folder of lss files for any changes and to compile it to css.
I tried using terminal to cd right into the folder where my .less files are and to just run this command less.watch() but when I made changes nothing got outputted to css file.
What am I missing.
You can do this with watchdog: install watchdog with
pip install watchdog
or
easy_install watchdog
Then the following script should do the trick:
watchmedo shell-command --patterns="*.less" --command=\
'LESS=`echo "${watch_src_path}" | sed s/.less$/.css/`; \
echo compile: "${watch_src_path}";\
lessc "${watch_src_path}" "${LESS}"; \
if [ "$?" -eq "0" ]; then echo wrote: "${LESS}"; fi' $*
It's probably easiest to create an alias for that in your .bash_profile (or whatever the equivalent on your system is.
I used Bash Shell for a long time and recently switched to ZSH because of the greatness of the project O-My-Zsh.
I have no problems how to use the zsh but setuping the local environment. I am currently using the dotfiles structure from Peepcode screencast, illustrate file-tree below:
Map .bash_profile to .zshrc file, map .zshrc file to the ~/bin/dotfile/zshrc file, zshrc file just load 3 files which is environment, alias, config. ( Those 3 files are the logic separation of the .zshrc file )
That is my setup. It is currently working the way it should. I could use alias which I set in alias file, etc.
Here is my question, the project O-My-Zsh needs the config file like loading the .oh-my-zsh folder and .oh-my-zsh.sh files. It is working if I put .oh-my-zsh config setting in the ~/.zshrc file. Since I mapped .zshrc to another place, how could I still refer to source the O-My-Zsh themes, plugins, settings? How should I source the ~/.oh-my-zsh folder in the clean way?
I think I understand your question, and my current setup may be similar:
In an effort to make setup and sync between various machines, I have moved all of my dotfiles to Dropbox (in a folder called .zsh). A symlink connects Dropbox/.zsh/.zshrc to ~/.zshrc, and Dropbox/.zsh/.zshrc sources all of my various config files, like so:
# Set so that all other sourced files can be found.
export ZDOTDIR="$HOME/Dropbox/.zsh"
source $ZDOTDIR/checks.zsh
# source $ZDOTDIR/colors.zsh
source $ZDOTDIR/exports.zsh
source $ZDOTDIR/oh-my-zsh_opts.zsh
source $ZDOTDIR/setopt.zsh
source $ZDOTDIR/pyopts.zsh
source $ZDOTDIR/prompt.zsh
source $ZDOTDIR/completion.zsh
source $ZDOTDIR/aliases.zsh
source $ZDOTDIR/bindkeys.zsh
source $ZDOTDIR/functions.zsh
# source $ZDOTDIR/zsh_hooks.zsh
Similarly, $ZDOTDIR/oh-my-zsh_opts.zsh defines all of my Oh-my-zsh options:
# Path to your oh-my-zsh configuration.
ZSH=$ZDOTDIR/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="af-magic"
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(battery colored-man colorize cp extract frontend git pip python pyenv\
virtualenv)
if [[ $IS_MAC -eq 1 ]]; then
plugins=($plugins brew brew-cask osx textmate)
fi
if [[ $IS_LINUX -eq 1 ]]; then
plugins=($plugins)
fi
if [[ $HAS_APT -eq 1 ]]; then
plugins=($plugins debian)
fi
if [[ $HAS_YUM -eq 1 ]]; then
plugins=($plugins yum)
fi
source $ZSH/oh-my-zsh.sh
I'm having some trouble in exporting the PATH I've modified inside the Makefile into the current Terminal.
I'm trying to add to the PATH, the bin folder inside wherever the Makefile directory is.
Here's the relevant strip of the makefile:
PATH := $(shell pwd)/bin:$(PATH)
install:
mkdir -p ./bin
export PATH
echo $(PATH)
The echo prints it correctly but if I redo the echo in the terminal, the PATH remains the same.
Thanks in advance for the help.
If you're using GNU make, you need to explicitly export the PATH variable to the environment for subprocesses:
export PATH := $(shell pwd)/bin:$(PATH)
install:
mkdir -p ./bin
export PATH
echo $(PATH)
What you are trying to do is not possible. Make is running in another process than the shell in your terminal. Changes to the environment in the make process does not transfer to the shell.
Perhaps you are confusing the effect of the export statement. export does not export the values of the variables from the make process to the shell. Instead, export marks variables so they will be transfered any child processes of make. As far as I know there is no way to change the environment of the parent process (the shell where you started make is the parent process of the make process).
Perhaps this answers will make the concept of exporting variables to child processes a bit clearer.
Perhaps you can rely on the user to do it for you. Note the quoting
install_hint:
#echo "Execute this command at your shell prompt:"
#echo "export PATH=$(shell pwd)/bin:\$$PATH"