From b8ff51f0d0ad5bd90f8c0b872ccda18122aa0127 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 17 Dec 2015 05:32:03 -0500 Subject: [PATCH] zsh: general clean up --- zsh/prompt.zsh | 13 +++++++++---- zshenv | 9 +++------ zshrc | 26 +++++++++++++++----------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh index c01e972b..37328317 100644 --- a/zsh/prompt.zsh +++ b/zsh/prompt.zsh @@ -15,10 +15,11 @@ _human_time() { echo "${seconds}s" } -# string length ignoring ansi escapes -_string_length() { - # Subtract one since newline is counted as two characters - echo $(( ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} - 1 )) +_strlen () { + FOO=$1 + local zero='%([BSUbfksu]|([FB]|){*})' + LEN=${#${(S%%)FOO//$~zero/}} + echo $LEN } # fastest possible way to check if repo is dirty @@ -54,10 +55,14 @@ prompt_hook_preexec() { } prompt_hook_precmd() { + last_time=$EPOCHSECONDS # shows the full path in the title print -Pn '\e]0;%~\a' # git info vcs_info + # newline before prompt (except on first prompt) + [[ -n "$_DONE" ]] && print "" + _DONE=1 } # Updates cursor shape and prompt symbol based on vim mode diff --git a/zshenv b/zshenv index 73b3a7b3..328b9053 100644 --- a/zshenv +++ b/zshenv @@ -53,20 +53,17 @@ export GOPATH=$HOME/Dropbox/work/go export ANDROID_HOME=/usr/local/opt/android-sdk export ANDROID_SDK=/usr/local/Cellar/android-sdk/24.2 -# basictex -# export PATH=/usr/local/texlive/2015basic/bin/x86_64-darwin:$PATH - # Set the list of directories that Zsh searches for programs. path=( $HOME/.dotfiles/{bin,scripts} - /usr/local/{bin,sbin} - /usr/{bin,sbin} - /{bin,sbin} $HOME/.{rb,py}env/bin $GOPATH/bin $ANDROID_HOME/platform-tools $ANDROID_HOME/tools /Library/TeX/texbin + /usr/local/{bin,sbin} + /usr/{bin,sbin} + /{bin,sbin} $path ) diff --git a/zshrc b/zshrc index 9fa4a294..4e4ed636 100644 --- a/zshrc +++ b/zshrc @@ -4,38 +4,42 @@ DOTFILES=$HOME/.dotfiles -source $DOTFILES/zsh/functions.zsh +ZSH_CACHE_DIR="$HOME/.zsh/cache/$(hostname)" +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) # if not running through emacs' shell-command if [ ! $TERM = dumb ]; then ZGEN_AUTOLOAD_COMPINIT=true - if [[ "${USER}" == "root" ]]; then - ZGEN_AUTOLOAD_COMPINIT=false - fi + [[ "${USER}" == "root" ]] && ZGEN_AUTOLOAD_COMPINIT=false source ~/.zsh/zgen/zgen.zsh if ! zgen saved; then echo "Creating zgen save" zgen load zsh-users/zsh-history-substring-search - zgen load zsh-users/zsh-completions src - zgen load Tarrasch/zsh-bd zgen load willghatch/zsh-hooks zgen load hlissner/zsh-autopair + zgen load StackExchange/blackbox [[ "$SSH_CONNECTION" == '' ]] && zgen load zsh-users/zsh-syntax-highlighting - zgen load $DOTFILES/zsh/config.zsh - zgen load $DOTFILES/zsh/completion.zsh - zgen load $DOTFILES/zsh/keybinds.zsh - zgen load $DOTFILES/zsh/prompt.zsh + zgen load zsh-users/zsh-completions src + + zgen load "$DOTFILES/zsh/config.zsh" + zgen load "$DOTFILES/zsh/completion.zsh" + zgen load "$DOTFILES/zsh/keybinds.zsh" + zgen load "$DOTFILES/zsh/prompt.zsh" zgen save fi cache fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install + + export FZF_DEFAULT_COMMAND='ag -g ""' + export FZF_DEFAULT_OPTS='--reverse --inline-info' + [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh fi -source $DOTFILES/zsh/aliases.zsh +source "$DOTFILES/zsh/aliases.zsh" cache rbenv init - --no-rehash cache pyenv init - --no-rehash