From 39548f2301ef4faf6cf19f4a6f379f183c6e2fc5 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Wed, 23 Mar 2016 09:28:03 -0700 Subject: [zsh] clean up zsh config. Keep as few files as possible, and document the order this files are loaded in OS X. --- Makefile | 8 ++------ aliases | 10 ---------- docs/zsh.org | 7 +++++-- zprofile | 20 ++++++++++++++++++++ zshenv | 26 -------------------------- zshrc | 23 +++++++++++++++++++---- 6 files changed, 46 insertions(+), 48 deletions(-) create mode 100644 zprofile delete mode 100644 zshenv diff --git a/Makefile b/Makefile index bc9b2be..af15df7 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,10 @@ INSTALL = \ aliases \ aspell.en.pws \ emacs.d \ - env \ gitconfig \ gitignore \ tmux.conf \ - zshenv \ + zprofile \ zshrc git: @@ -18,7 +17,7 @@ git: INSTALLED = $(patsubst %,$(INTO)/.%,$(INSTALL)) LN = @ln -sf -install: $(INSTALLED) $(HOME)/bin $(HOME)/src $(HOME)/tmp $(HOME)/.ssh/authorized_keys git +install: $(INSTALLED) $(HOME)/bin $(HOME)/src $(HOME)/.ssh/authorized_keys git $(INTO)/.% : % @[ ! -e $@ ] || [ -h $@ ] || mv -f $@ $@.bak @@ -33,9 +32,6 @@ $(HOME)/bin: $(HOME)/src: mkdir -p $(HOME)/src -$(HOME)/tmp: - mkdir -p $(HOME)/tmp - check-dead: @find ~ -maxdepth 1 -name '.*' -type l -exec test ! -e {} \; -print @find ~/bin -maxdepth 1 -name '.*' -type l -exec test ! -e {} \; -print diff --git a/aliases b/aliases index 005d856..9349fa1 100644 --- a/aliases +++ b/aliases @@ -21,21 +21,11 @@ alias utc="date -u" # tools alias tmuxa="tmux new-session -A -s work" -alias gerp="grep --color=auto" alias grep="grep --color=auto" -alias pjson="python -mjson.tool" # git alias g="git" alias gclean="git clean -dfx" -alias gst="git status" - -# navigation -alias s="cd ~/src/source" -alias eb="cd ~/src/source/eventbus" -alias ops="cd ~/src/twitter-ops" -alias science="cd ~/src/source/science/" -alias gcode="cd ~/gocode/src" # zsh stuff alias zshrc="source ~/.zshrc" diff --git a/docs/zsh.org b/docs/zsh.org index 1f4afb7..5a34193 100644 --- a/docs/zsh.org +++ b/docs/zsh.org @@ -11,8 +11,11 @@ The configuration files are loaded in that order: + $HOME/.zprofile + /etc/zshrc + $HOME/.zshrc -+ /etc/zlogin (if logging shell) -+ $HOME/.zlogin (if logging shell) ++ /etc/zlogin (if login shell) ++ $HOME/.zlogin (if login shell) ** Tips /etc/zshenv is run for all instances of zsh, it is important that it be kept as small as possible. + +** On OS X +On OS X, terminal emulators are starting every shell as a login shells (since OS X doesn't source the profile). diff --git a/zprofile b/zprofile new file mode 100644 index 0000000..3843e85 --- /dev/null +++ b/zprofile @@ -0,0 +1,20 @@ +export EDITOR="emacsclient -a ''" +export HISTFILE= +export LANG="en_US.UTF-8" +export LC_ALL="$LANG" +export LC_CTYPE="$LANG" +export PAGER="less" +export TZ=America/Los_Angeles +export GOPATH="${HOME}/gocode" + +# build the PATH +path=( + "$HOME/bin" + "$HOME/gocode/bin" + "$HOME/src/source/dist" + "/opt/twitter/bin" + "/opt/twitter/opt/go/libexec/bin" + "/Applications/Racket v6.3/bin/" + $path +) + diff --git a/zshenv b/zshenv deleted file mode 100644 index 0d7c3aa..0000000 --- a/zshenv +++ /dev/null @@ -1,26 +0,0 @@ -export EDITOR="emacsclient -a ''" -export HISTFILE= -export LANG="en_US.UTF-8" -export LC_ALL="$LANG" -export LC_CTYPE="$LANG" -export PAGER="less" -export TZ=America/Los_Angeles -export GOPATH="${HOME}/gocode" - -# FIXME enable auto completion - This is stupid, this should be in .zshrc -autoload -U compinit -compinit -C - -# this is for local stuff -[ -f ~/.zshenv_local ] && source ~/.zshenv_local - -# build the PATH -path=( - "$HOME/bin" - "$HOME/gocode/bin" - "$HOME/src/source/dist" - "/opt/twitter/bin" - "/opt/twitter/opt/go/libexec/bin" - "/Applications/Racket v6.3/bin/" - $path -) diff --git a/zshrc b/zshrc index 52f9a1f..95f0f72 100644 --- a/zshrc +++ b/zshrc @@ -4,15 +4,30 @@ autoload -U colors colors +# enable auto completion +autoload -U compinit +compinit -C +zstyle ':completion:*' completer _expand _complete _match _prefix + # I want word boundary to be similar to bash autoload -U select-word-style select-word-style bash -local ret_status="%{$reset_color%}%(?:%{$fg_bold[green]%}➜:%{$fg_bold[red]%}➜)%{$reset_color%}" -PROMPT="${ret_status} %1~ %# " +# keep the prompt simple and short +PROMPT="%1~ %# " + +# emacs style +bindkey -e # load custom aliases source ~/.aliases -# emacs style -bindkey -e +# aliases for some directories +hash -d s="$HOME/src/source" +hash -d eb="$HOME/src/source/eventbus" +hash -d ops="$HOME/src/twitter-ops/" +hash -d science="$HOME/src/source/science/" +hash -d gcode="$HOME/gocode/src/" + +# this is for local stuff +[ -f ~/.zlogin_local ] && source ~/.zlogin_local -- cgit 1.4.1