From cbc5af5c9ec9dfe319dd0974adbc9475bcdfa8c1 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 28 Jan 2016 16:34:38 -0500 Subject: Rewrite zshrc --- .zshrc | 86 ++++++++++++++++++++++++------------------------------------------ 1 file changed, 31 insertions(+), 55 deletions(-) diff --git a/.zshrc b/.zshrc index d07db0d3..91ae92fd 100644 --- a/.zshrc +++ b/.zshrc @@ -1,96 +1,72 @@ unsetopt beep setopt nomatch interactive_comments - HISTFILE=~/.history HISTSIZE=SAVEHIST=5000 setopt inc_append_history hist_ignore_dups +autoload -Uz compinit && compinit +autoload -Uz colors && colors + bindkey -v KEYTIMEOUT=1 -autoload -Uz compinit && compinit -autoload colors && colors - PATH=$PATH:~/.bin export EDITOR=vim -export CLICOLOR=1 # color ls output on OS X [[ "$OSTYPE" =~ 'darwin' ]] && alias osx=true || alias osx=false -osx || alias ls='ls --color' -osx || alias grep='grep --color' -osx && alias rm='rm -v' || alias rm='rm -vI' +osx && export CLICOLOR=1 || alias ls='ls --color' grep='grep --color' +osx || alias rm='rm -I' osx && alias gvim=mvim || alias gvim='gvim 2> /dev/null' -tn() { [ -n "$1" ] && tmux new -s "$1" || tmux new } -ta() { [ -n "$1" ] && tmux attach -t "$1" || tmux attach } - +alias gcl='git clone' +alias gs='git status -sb' alias ga='git add' -alias gb='git branch' alias gc='git commit' alias gca='git commit --amend' -alias gcl='git clone' +alias gmv='git mv' +alias grm='git rm' +alias gst='git stash' +alias gt='git tag' +alias gsh='git show' alias gco='git checkout' -alias gd='git diff' -alias gl='git log --graph --pretty=log' +alias gb='git branch' alias gm='git merge' -alias gmv='git mv' alias gp='git push' +alias gf='git fetch' +alias gu='git pull' alias gr='git rebase' alias grc='git rebase --continue' alias grs='git rebase --skip' alias gra='git rebase --abort' -alias grm='git rm' -alias gs='git status -sb' -alias gsh='git show' -alias gst='git stash' -alias gt='git tag' -alias gu='git pull' -alias gf='git fetch' - -[[ -n "$SSH_CLIENT" ]] && _prompt_ssh_color="$fg[magenta]" - -function zle-line-init zle-keymap-select { - _prompt_vi_color= - [[ "$KEYMAP" == "vicmd" ]] && _prompt_vi_color="$fg[yellow]" - zle reset-prompt -} -zle -N zle-line-init -zle -N zle-keymap-select +alias gd='git diff' +alias gl='git log --graph --pretty=log' -_prompt_git_branch() { +setopt prompt_subst +[[ -n "$SSH_CLIENT" ]] && _prompt_ssh="$fg[magenta]" +_prompt_git() { [[ -f .git/HEAD ]] || return 0 local head read head < .git/HEAD case "$head" in - ref:*) - echo ":${head#*/*/}" - ;; - *) - echo ":${head:0:7}" - ;; + ref:*) echo ":${head#*/*/}";; + *) echo ":${head:0:7}";; esac } +PROMPT='%{%(?.$fg[green]$_prompt_ssh.$fg[red])%}»%{$reset_color%} ' +RPROMPT='%{$fg[blue]%}%-50<…<%~%{$fg[yellow]%}$(_prompt_git)%{$reset_color%}' -setopt prompt_subst -PROMPT='%{%(?.$fg[green]$_prompt_ssh_color.$fg[red])$_prompt_vi_color%}»%{$reset_color%} ' -RPROMPT='%{$fg[blue]%}%-50<…<%~%{$fg[yellow]%}$(_prompt_git_branch)%{$reset_color%}' - -_newline_precmd() { _newline_precmd() { echo } } +typeset -ga preexec_functions precmd_functions -_title() { - [[ "$TERM" =~ 'xterm' ]] && print -Pn "\e]0;$@\a" -} -[[ -n "$SSH_CLIENT" ]] && _title_host='%m:' -_title_preexec() { _title "$_title_host%1~: $1" } -_title_precmd() { _title "$_title_host%1~" } +_n() { _n() { echo } } +precmd_functions+=(_n) -typeset -ga preexec_functions -typeset -ga precmd_functions +_title() { print -Pn "\e]0;$@\a" } +_title_precmd() { _title "%1~" } +_title_preexec() { _title "%1~: $1" } +precmd_functions+=(_title_precmd) preexec_functions+=(_title_preexec) -precmd_functions+=(_newline_precmd _title_precmd) [[ -f ~/.nvm/nvm.sh ]] && source ~/.nvm/nvm.sh - if [[ -d /usr/local/share/chruby ]]; then source /usr/local/share/chruby/chruby.sh chruby ruby -- cgit 1.4.1