diff options
Diffstat (limited to '')
-rw-r--r-- | .zshrc | 108 |
1 files changed, 39 insertions, 69 deletions
diff --git a/.zshrc b/.zshrc index e30f41ee..d07db0d3 100644 --- a/.zshrc +++ b/.zshrc @@ -1,29 +1,54 @@ -# Save 5000 lines of history, writing after each command, ignoring duplicates. +unsetopt beep +setopt nomatch interactive_comments + HISTFILE=~/.history HISTSIZE=SAVEHIST=5000 setopt inc_append_history hist_ignore_dups -# Error if glob does not match. -setopt nomatch - -# Allow comments in interactive shell. -setopt interactive_comments - -# No. -unsetopt beep - -# Vim line editing, eliminate escape key delay. bindkey -v KEYTIMEOUT=1 -# Initialize completion and colors. autoload -Uz compinit && compinit autoload colors && colors -# Color prompt magenta over SSH. +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 && 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 ga='git add' +alias gb='git branch' +alias gc='git commit' +alias gca='git commit --amend' +alias gcl='git clone' +alias gco='git checkout' +alias gd='git diff' +alias gl='git log --graph --pretty=log' +alias gm='git merge' +alias gmv='git mv' +alias gp='git push' +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]" -# Color prompt yellow in vi normal mode. function zle-line-init zle-keymap-select { _prompt_vi_color= [[ "$KEYMAP" == "vicmd" ]] && _prompt_vi_color="$fg[yellow]" @@ -32,7 +57,6 @@ function zle-line-init zle-keymap-select { zle -N zle-line-init zle -N zle-keymap-select -# Show git branch or commit in right prompt. _prompt_git_branch() { [[ -f .git/HEAD ]] || return 0 local head @@ -47,16 +71,12 @@ _prompt_git_branch() { esac } -# Single colored character prompt, directory and git branch in right prompt. 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%}' -# Print a newline before every prompt after the first one. _newline_precmd() { _newline_precmd() { echo } } -# Set title to directory name at prompt, prefixed with hostname over SSH. Add -# current command to title while running. _title() { [[ "$TERM" =~ 'xterm' ]] && print -Pn "\e]0;$@\a" } @@ -69,55 +89,6 @@ typeset -ga precmd_functions preexec_functions+=(_title_preexec) precmd_functions+=(_newline_precmd _title_precmd) -# General environment setup. -PATH=$PATH:~/.bin -export EDITOR=vim -export CLICOLOR=1 # color ls output on OS X - -# Detect OS X for conditional aliases. -[[ "$OSTYPE" =~ 'darwin' ]] && alias osx=true || alias osx=false - -# Color output on Linux. -osx || alias ls='ls --color' -osx || alias grep='grep --color' - -# Verbose output from rm with confirmation on Linux. -osx || alias rm='rm -vI' -osx && alias rm='rm -v' - -# Suppress output from Linux gvim, alias gvim to MacVim. -osx || alias gvim='gvim 2> /dev/null' -osx && alias gvim=mvim - -tn() { [ -n "$1" ] && tmux new -s "$1" || tmux new } -ta() { [ -n "$1" ] && tmux attach -t "$1" || tmux attach } - -alias g=git -alias ga='git add' -alias gb='git branch' -alias gc='git commit' -alias gca='git commit --amend' -alias gcl='git clone' -alias gco='git checkout' -alias gd='git diff' -alias gl='git log --graph --pretty=log' -alias gm='git merge' -alias gmv='git mv' -alias gp='git push' -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' - -alias hu=heroku - [[ -f ~/.nvm/nvm.sh ]] && source ~/.nvm/nvm.sh if [[ -d /usr/local/share/chruby ]]; then @@ -125,5 +96,4 @@ if [[ -d /usr/local/share/chruby ]]; then chruby ruby fi -# Prevent red first prompt. true |