I have a MacBook with Iterm2 with Zshell (zsh) and one of the add-ons I have is the command line fuzzy finder (fzf), but despite being added to my .zshrc it doesn't work. If I manually load it with source ~/.fzf.zsh it works, and if I then reload my .zshrc source ~/.zshrc it doesn't work again.
What could be the reason?
Here's most of my .zshrc file (see the line: # add fuzzy find):
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# add fuzzy find
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# add syntax highlighting
export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/usr/local/share/zsh-syntax-highlighting/highlighters
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Path to your oh-my-zsh installation.
export ZSH="/Users/xxxx/.oh-my-zsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git)
source $ZSH/oh-my-zsh.sh
DEFAULT_USER=`whoami`
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
alias pip=/usr/local/bin/pip3
Something you do in .zshrc following source ~/.fzf.zsh breaks it. Make sure ~/.fzf.zsh occurs after that, most easily accomplished by moving it to the end of the file.
Related
I have tried using this code in both .bashrc and .bash_profile:
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export TMPDIR=/tmp
export SUBJECTS_DIR=/mindhive/nklab3/projects/ellison_on_nklab3/zfMRI
but when I write echo $SUBJECTS_DIR in the terminal, it returns a completely different filepath.
I have done source .bashrc, source .bash_profile, and restarted my ssh login, but none of these have changed anything, echo just continues giving the wrong directory. I have also tried writing the SUBJECTS_DIR filepath in quotes, writing it with :$SUBJECTS_DIR at the end, and a bunch of other configurations that I've found from looking around on the internet for ages to find what the problem might be, but no way of writing it has changed anything so far either. What do I do?
/etc/bashrc is supposed to be source'd by /etc/profile or autoloaded by bash depending on how Bash was built by the distro. I think what you want to do is this; placed in ~/.bash_profile:
if [[ -f ~/.bashrc ]]; then
. ~/.bashrc
fi
export TMPDIR=/tmp
export SUBJECTS_DIR=/mindhive/nklab3/projects/ellison_on_nklab3/zfMRI
Read Bash Startup Files.
I get this when I tre to run the terminal on my mac:
zsh compinit: insecure directories, run compaudit for list.
Ignore insecure directories and continue [y] or abort compinit [n]? y
Suggested answers like this are of no use to me as they all involve running commands which I'm not currently able to do. How do I resolve this?
Ths is my .zshrc:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH="$HOME/.jenv/bin:$PATH:/Users/paulcarron/Apache/apache-maven-3.8.1/bin"
eval "$(jenv init -)"
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
source ~/.bash_profile
.bashrc:
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
eval "$(jenv init -)"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if [ -r ~/.zshrc ]; then
source ~/.zshrc
fi
You have a created an infinite loop in your dotfiles. Your .zshrc sources your .bashrc, which sources your .zshrc, ad infinitum.
Additionally, when you source "$NVM_DIR/bash_completion" from zsh, it for some strange reason calls compinit. (This is something that nvm should not do.)
So, there you have it: Together, you’ve created yourself infinite compinits.
Moral of the story: It’s already a bad idea to source .bashrc from .zshrc, or vice versa, but doing it in both directions is even worse.
Solution: Don’t do that and remove the offending lines from your dotfiles.
The only way my .bashrc and .bashprofile are recognized by OSX is if I specify in my terminal's preferences for the file to be targeted upon boot. Is there a reason why they're not working like they should be?
Here's the inside of my .bashrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
Load RVM into a shell session *as a function*
#Add RVM to PATH for scripting. Make sure this is the last PATH
variable change.
export PATH="$PATH:$HOME/.rvm/bin"
smiley () { echo -e ":\\$(($??50:51))"; }
export PS1="\h\$(smiley) \e[30;1m\w\e[0m\n\$ "
Inside of .bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" #
Load RVM into a shell session *as a function*
# Add RVM to PATH for scripting. Make sure this is the last PATH n .
variable change.
export PATH="$PATH:$HOME/.rvm/bin"
alias b='cd ..'
Any help would be appreciated! Thanks!
In OSX, all sessions are login sessions and will not source $HOME/.bashrc, they will source $HOME/.profile or $HOME/.bash_profile. So put the following in your .bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
When I open up a new shell I get:
Last login: Sun Mar 23 10:14:46 on ttys000
-bash: : command not found
I'm not totally sure how to figure out what's going on there, as its not totally clear which command its talking about.
Is it likely something in the .bashrc file?
HISTSIZE=10000
HISTFILESIZE=20000
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PS1="\[\e[01;32m\]\h \[\e[01;34m\]\W \$(parse_git_branch)\[\e[01;34m\]$\[\e[00m\] "
export PYTHONSTARTUP=/Users/JimShook/.pythonstartup
export WORKON_HOME=$HOME/.virtualenv
source /usr/local/bin/virtualenvwrapper.sh
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
PATH=$PATH:/usr/local/rvm/bin # Add RVM to PATH for scripting
### Added by the Heroku Toolbelt
Or maybe the bash_profile?
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
[[ -s "/usr/local/rvm/scripts/rvm" ]] && source "/usr/local/rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Any thoughts are helpful.
Things to check - as suggested above:
anything changed recently? if so, start there... (added new line/command/sourced file?)
look for 'control codes' in the your file(s)
Try:
cat -v ~/.bashrc ## look for '^M' or other special chars - remove if present
bash -n ~/.bashrc ## try the 'sourced files' separately
If using VI, some thing to try after opening the file:
:syntax off ## turn off colors - may be easier to see 'hidden' codes
:set list ## control codes may be visible
Every time I log into my VPS I must run source ~/.bashrc before I can run any rvm, ruby, or gem commands.
Why is this? Can't make it load by default?
ssh deployer#xxx
ruby -v
-bash: ruby: command not found
source ~/.bashrc
ruby -v
ruby 1.9.3p429 (2013-05-15 revision 40747) [i686-linux]
I installed rvm under deployer.
I have ~/.bash_pofile which is empty. I also have ~/.profile which has the following in it:
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
My ~/.bashrc has this at the top:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
From the bash man page:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable.
So in your case, the (empty) ~/.bash_profile is being executed, and your ~/.profile (and thus your ~/.bashrc) are ignored. To solve this, you'll either need to delete your ~/.bash_profile, or else move the contents of ~/.profile into ~/.bash_profile.
When you log in, if Bash can find a file named .bash_profile in your home directory it will execute it and do not even search for a .profile file. Thus you have two choices, either remove the empty .bash_profile file or copy the contents of .profile to .bash_profile.
Moving the information from .bashrc to the other files, as suggested by others is one way to do it.
Otherwise, this snippet of code will do the same thing, without needing to move the contents, or remove the file. Depending on the ways you have things set up, you may not want to delete a file, if it has relevant information in it for other tasks, other than interactive login.
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
Though using the files as they are intended to be used by reading the documentation can definitely alleviate some frustration.