[zshrc] Make sure homebrew doesn't take over PATH
This commit is contained in:
parent
03707ebb91
commit
05b66e5c47
1 changed files with 50 additions and 45 deletions
95
zshrc
95
zshrc
|
|
@ -1,4 +1,4 @@
|
|||
# 0. Sniff out the platform
|
||||
### Sniff out the platform
|
||||
# =========================
|
||||
uname=`uname -s`
|
||||
function linux() { [[ "$uname" = "Linux" ]] }
|
||||
|
|
@ -11,9 +11,35 @@ function command_exists() { which "$1" >/dev/null 2>/dev/null }
|
|||
# (tests if stdout is a tty)
|
||||
function is_interactive() { [ -t 1 ] }
|
||||
|
||||
# 1. Environment Vars
|
||||
### Various environments
|
||||
# =======================
|
||||
# Do this before setting up PATH so ~/bin and similar still have the highest precedence.
|
||||
|
||||
if mac && [[ -x $HOME/homebrew/bin/brew ]]; then
|
||||
eval "$($HOME/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
if command_exists rbenv; then
|
||||
eval "$(rbenv init -)"
|
||||
fi
|
||||
if command_exists pyenv; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
if command_exists direnv; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
|
||||
### SSH keys
|
||||
# ============
|
||||
|
||||
if mac; then
|
||||
ssh-add --apple-load-keychain
|
||||
fi
|
||||
|
||||
### Environment Vars
|
||||
# ===================
|
||||
custom_paths=(/sbin /usr/sbin /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin /usr/local/bin /usr/local/sbin /opt/homebrew/bin /opt/homebrew/sbin $HOME/go/bin $HOME/bin)
|
||||
|
||||
custom_paths=(/sbin /usr/sbin /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin /usr/local/bin /usr/local/sbin $HOME/go/bin $HOME/bin)
|
||||
for dir in $custom_paths; do
|
||||
if [[ -d "$dir" ]]; then
|
||||
path=($dir $path)
|
||||
|
|
@ -68,10 +94,6 @@ if mac; then
|
|||
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$HOME/homebrew/opt/openssl@1.1"
|
||||
fi
|
||||
|
||||
if [[ -x $HOME/homebrew/bin/brew ]]; then
|
||||
eval "$($HOME/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
# Set Apple Terminal.app resume directory
|
||||
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] {
|
||||
function chpwd {
|
||||
|
|
@ -93,17 +115,17 @@ if [[ -d ~/Library/Mobile\ Documents/com\~apple\~CloudDocs ]]; then
|
|||
export icloud=~/Library/Mobile\ Documents/com\~apple\~CloudDocs
|
||||
fi
|
||||
|
||||
# 2. Shell Options
|
||||
### Shell Options
|
||||
# ================
|
||||
|
||||
# 2.1. Parameters and Shell Functionality
|
||||
### Parameters and Shell Functionality
|
||||
# ---------------------------------------
|
||||
#setopt ignoreeof # ignore EOF ('^D') (i.e. don't log out on it)
|
||||
setopt braceccl # {a-d} expands to a b c d
|
||||
setopt noclobber # don't overwrite existing files w/ > output redir
|
||||
setopt hist_allow_clobber # C-p or UP and command has >| now, ready to go
|
||||
|
||||
# 2.2. Changing Directories
|
||||
### Changing Directories
|
||||
# -------------------------
|
||||
setopt autocd # automatically cd to a directory if not cmd
|
||||
setopt autopushd # automatically pushd directories on dirstack
|
||||
|
|
@ -114,18 +136,18 @@ export DIRSTACKSIZE=8
|
|||
setopt autonamedirs # % export h=/home/sjs; cd ~h; pwd => /home/sjs
|
||||
setopt cdablevars # blah=~/media/movies; cd blah; pwd => ~/media/movies
|
||||
|
||||
# 2.3. Shell Completion
|
||||
### Shell Completion
|
||||
# ---------------------
|
||||
setopt correct # try to correct spelling...
|
||||
setopt no_correctall # ...only for commands, not filenames
|
||||
setopt no_listbeep # don't beep on ambiguous listings
|
||||
setopt listpacked # variable col widths (takes up less space)
|
||||
|
||||
# 2.4. Shell Expansion and Globbing
|
||||
### Shell Expansion and Globbing
|
||||
# ---------------------------------
|
||||
setopt extendedglob # use extended globbing (#, ~, ^)
|
||||
|
||||
# 2.5. History and History Expansion
|
||||
### History and History Expansion
|
||||
# ----------------------------------
|
||||
export HISTFILE="$ZDOTDIR/zhistory" # save history
|
||||
export HISTSIZE=2000000 # huge internal buffer
|
||||
|
|
@ -139,16 +161,16 @@ setopt histreduceblanks # compact consecutive white space chars (cool)
|
|||
setopt histnostore # don't store history related functions
|
||||
setopt incappendhistory # incrementally add items to HISTFILE
|
||||
|
||||
# 2.6. Job Control
|
||||
### Job Control
|
||||
# ----------------
|
||||
setopt longlistjobs # list jobs in long format
|
||||
|
||||
# 2.7. Shell Prompt
|
||||
### Shell Prompt
|
||||
# -----------------
|
||||
setopt promptsubst # allow parameter, command, so on in prompt
|
||||
setopt transient_rprompt # hide RPROMPT after cmdline is executed
|
||||
|
||||
# 2.8. ZLE
|
||||
### ZLE
|
||||
# --------
|
||||
setopt no_beep # don't beep on errors (in ZLE)
|
||||
|
||||
|
|
@ -164,12 +186,12 @@ for op in \| \< \> \&
|
|||
do bindkey "$op" self-insert-redir
|
||||
done
|
||||
|
||||
# 2.9. Auto quote pasted URLs
|
||||
### Auto quote pasted URLs
|
||||
# ---------------------------
|
||||
autoload -U url-quote-magic
|
||||
zle -N self-insert url-quote-magic
|
||||
|
||||
# 3. Terminal Settings
|
||||
### Terminal Settings
|
||||
# ====================
|
||||
function precmd {
|
||||
rehash
|
||||
|
|
@ -177,11 +199,11 @@ function precmd {
|
|||
autoload -U colors # we need the colors for some formats below
|
||||
colors
|
||||
|
||||
# 4. ZLE Keybindings
|
||||
### ZLE Keybindings
|
||||
# ==================
|
||||
bindkey '\ep' history-beginning-search-backward
|
||||
|
||||
# 5. Prompt Subsystem
|
||||
### Prompt Subsystem
|
||||
# ===================
|
||||
# Load the prompt theme system
|
||||
autoload -U promptinit
|
||||
|
|
@ -190,10 +212,10 @@ promptinit
|
|||
# Use my prompt theme, based on wunjo (zsh-git)
|
||||
prompt sjs
|
||||
|
||||
# 6. Aliases
|
||||
### Aliases
|
||||
# ===========
|
||||
|
||||
# 6.1. Convenience Aliases/Macros
|
||||
### Convenience Aliases/Macros
|
||||
# --------------------------------
|
||||
alias bgd='bg; disown %1'
|
||||
alias cp='nocorrect cp' # don't correct spelling for 'cp'
|
||||
|
|
@ -211,7 +233,7 @@ alias myip='curl -4 icanhazip.com'
|
|||
alias be='bundle exec'
|
||||
alias doc='docker-compose'
|
||||
|
||||
# 6.2 ls Aliases
|
||||
### ls Aliases
|
||||
# ----------------
|
||||
if command_exists ls-comma; then
|
||||
alias ls='ls-comma'
|
||||
|
|
@ -233,10 +255,10 @@ alias ll='ls -l'
|
|||
alias lsd='ls -d'
|
||||
alias lld='ls -dl'
|
||||
|
||||
# 6.3 ruby
|
||||
### ruby
|
||||
alias irb='irb --readline -r irb/completion'
|
||||
|
||||
# 6.4 git
|
||||
### git
|
||||
if command_exists git; then
|
||||
alias a='git add'
|
||||
alias b='git branch'
|
||||
|
|
@ -278,7 +300,7 @@ function cd () {
|
|||
fi
|
||||
}
|
||||
|
||||
# 7. Unsorted (new) stuff
|
||||
### Unsorted (new) stuff
|
||||
# =======================
|
||||
# if commands takes more than 60 seconds tell me how long it took
|
||||
export REPORTTIME=60
|
||||
|
|
@ -292,10 +314,10 @@ setopt no_hup # leave bg tasks running (a la nohup)
|
|||
|
||||
bindkey -e # emacs style key bindings
|
||||
|
||||
# 8. Completion
|
||||
### Completion
|
||||
# =============
|
||||
|
||||
if type brew &>/dev/null; then
|
||||
if command_exists brew; then
|
||||
FPATH=$(brew --prefix)/share/zsh/site-functions:$FPATH
|
||||
fi
|
||||
|
||||
|
|
@ -313,20 +335,3 @@ else
|
|||
compinit
|
||||
fi
|
||||
|
||||
# 9. Various environments
|
||||
# =======================
|
||||
if command_exists rbenv; then
|
||||
eval "$(rbenv init -)"
|
||||
fi
|
||||
if command_exists pyenv; then
|
||||
eval "$(pyenv init -)"
|
||||
fi
|
||||
if command_exists direnv; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
|
||||
# 10. SSH keys
|
||||
# ============
|
||||
if mac; then
|
||||
ssh-add --apple-load-keychain
|
||||
fi
|
||||
|
|
|
|||
Loading…
Reference in a new issue