diff options
Diffstat (limited to 'zsh')
-rw-r--r-- | zsh/appearance.zsh | 41 | ||||
-rw-r--r-- | zsh/completion.zsh | 58 | ||||
-rw-r--r-- | zsh/correction.zsh | 9 | ||||
-rw-r--r-- | zsh/functions.zsh-overrides | 10 | ||||
-rw-r--r-- | zsh/git.zsh | 19 | ||||
-rw-r--r-- | zsh/history.zsh | 18 | ||||
-rw-r--r-- | zsh/key-bindings.zsh | 22 | ||||
-rw-r--r-- | zsh/svn.zsh | 15 | ||||
-rw-r--r-- | zsh/termsupport.zsh | 23 |
9 files changed, 215 insertions, 0 deletions
diff --git a/zsh/appearance.zsh b/zsh/appearance.zsh new file mode 100644 index 0000000..e8d6dff --- /dev/null +++ b/zsh/appearance.zsh @@ -0,0 +1,41 @@ +#done + +autoload colors; colors; +setopt prompt_subst # expansion of color codes, etc. + +# Find the option for using colors in ls, depending on the version: Linux or BSD +ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' +export LSCOLORS="exgxbxdxcxegedxbxgxcxd" + +export GREP_OPTIONS='--color=auto' +export GREP_COLOR='1;32' + +export LESS_TERMCAP_mb=$'\e[0;31m' # begin blinking - red +export LESS_TERMCAP_md=$'\e[0;34m' # begin bold - blue +export LESS_TERMCAP_me=$'\e[0m' # end mode +export LESS_TERMCAP_so=$'\e[38;5;246m' # begin standout mode - info box +export LESS_TERMCAP_se=$'\e[0m' # end standout mode +export LESS_TERMCAP_us=$'\e[4;33m' # begin underline - yellow underline +export LESS_TERMCAP_ue=$'\e[0m' # end underline + +function theme_preexec () { + echo "($fg[magenta]`date +%r`$reset_color) $fg[cyan]$3$reset_color" +} + +function prompt_char { + git branch >/dev/null 2>/dev/null && echo '±' && return + svn info >/dev/null 2>/dev/null && echo 'ϟ' && return + echo '$' +} + +function return_code { + code=$(echo $?) + if [[ $code == "0" ]]; then + return + else + echo "%{$fg[red]%}$code%{$reset_color%} " + fi +} + +PROMPT='%{$fg[yellow]%}%n%{$reset_color%}@%{$fg[green]%}%m%{$reset_color%}:%{$fg[blue]%}%~%{$reset_color%} +$(return_code)$(git_prompt_info)$(prompt_char) %{$reset_color%}' diff --git a/zsh/completion.zsh b/zsh/completion.zsh new file mode 100644 index 0000000..4a6322c --- /dev/null +++ b/zsh/completion.zsh @@ -0,0 +1,58 @@ +# TODO: figure this thing out + +unsetopt menu_complete # do not autoselect the first completion entry +unsetopt flowcontrol +setopt auto_menu # show completion menu on succesive tab press +setopt complete_in_word +setopt always_to_end + +WORDCHARS='' + +autoload -U compinit +compinit -i + +zmodload -i zsh/complist + +zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' + +zstyle ':completion:*' list-colors '' + +# should this be in keybindings? +bindkey -M menuselect '^o' accept-and-infer-next-history + +zstyle ':completion:*:*:*:*:*' menu select +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' +zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" + +# disable named-directories autocompletion +zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories +cdpath=(.) + +# use /etc/hosts and known_hosts for hostname completion +[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() +[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=() +hosts=( + "$_ssh_hosts[@]" + "$_etc_hosts[@]" + `hostname` + localhost +) +zstyle ':completion:*:hosts' hosts $hosts + +# Use caching so that commands like apt and dpkg complete are useable +zstyle ':completion::complete:*' use-cache 1 +zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/ + +# Don't complete uninteresting users +zstyle ':completion:*:*:*:users' ignored-patterns \ + adm amanda apache avahi beaglidx bin cacti canna clamav daemon \ + dbus distcache dovecot fax ftp games gdm gkrellmd gopher \ + hacluster haldaemon halt hsqldb ident junkbust ldap lp mail \ + mailman mailnull mldonkey mysql nagios \ + named netdump news nfsnobody nobody nscd ntp nut nx openvpn \ + operator pcap postfix postgres privoxy pulse pvm quagga radvd \ + rpc rpcuser rpm shutdown squid sshd sync uucp vcsa xfs + +# ... unless we really want to. +zstyle '*' single-ignored show + diff --git a/zsh/correction.zsh b/zsh/correction.zsh new file mode 100644 index 0000000..72692a6 --- /dev/null +++ b/zsh/correction.zsh @@ -0,0 +1,9 @@ +#done + +setopt correct_all + +alias man='nocorrect man' +alias mv='nocorrect mv' +alias mysql='nocorrect mysql' +alias psql='nocorrect psql' +alias mkdir='nocorrect mkdir' diff --git a/zsh/functions.zsh-overrides b/zsh/functions.zsh-overrides new file mode 100644 index 0000000..b2db877 --- /dev/null +++ b/zsh/functions.zsh-overrides @@ -0,0 +1,10 @@ +#done + +preexec () { + term_preexec $* + theme_preexec $* +} + +precmd () { + term_precmd +} diff --git a/zsh/git.zsh b/zsh/git.zsh new file mode 100644 index 0000000..b0ec297 --- /dev/null +++ b/zsh/git.zsh @@ -0,0 +1,19 @@ +#done + +function parse_git_branch { + echo "${ref#refs/heads/}" +} + +function parse_git_staged { + $(git diff-index --quiet --cached HEAD) && return + echo "staged" +} +function parse_git_unstaged { + $(git diff-files --quiet) && return + echo "unstaged" +} + +function git_prompt_info { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + echo "(${ref#refs/heads/}) " +} diff --git a/zsh/history.zsh b/zsh/history.zsh new file mode 100644 index 0000000..0619fbe --- /dev/null +++ b/zsh/history.zsh @@ -0,0 +1,18 @@ +#TODO: optimize these rules. they are redundant + +## Command history configuration +HISTFILE=$HOME/.zsh_history +HISTSIZE=10000 +SAVEHIST=10000 + +setopt hist_ignore_dups # ignore duplication command history list +setopt share_history # share command history data + +setopt hist_verify +setopt inc_append_history +setopt extended_history +setopt hist_expire_dups_first +setopt hist_ignore_space + +setopt SHARE_HISTORY +setopt APPEND_HISTORY diff --git a/zsh/key-bindings.zsh b/zsh/key-bindings.zsh new file mode 100644 index 0000000..b63a68b --- /dev/null +++ b/zsh/key-bindings.zsh @@ -0,0 +1,22 @@ +# TODO: figure these out + +autoload -U compinit +compinit -i + +bindkey -e +bindkey '\ew' kill-region +bindkey -s '\el' "ls\n" +bindkey -s '\e.' "..\n" +bindkey '^r' history-incremental-search-backward +bindkey "^[[5~" up-line-or-history +bindkey "^[[6~" down-line-or-history + +bindkey "^[[H" beginning-of-line +bindkey "^[[1~" beginning-of-line +bindkey "^[[F" end-of-line +bindkey "^[[4~" end-of-line +bindkey ' ' magic-space # also do history expansion on space + +bindkey '^[[Z' reverse-menu-complete + +bindkey "\e[3~" delete-char # make sure delete key works diff --git a/zsh/svn.zsh b/zsh/svn.zsh new file mode 100644 index 0000000..bbcc69f --- /dev/null +++ b/zsh/svn.zsh @@ -0,0 +1,15 @@ +#done + +function svn_dirty { + if [[ -n $(svn status) ]]; then + echo "$ZSH_THEME_SVN_PROMPT_DIRTY" + else + echo "$ZSH_THEME_SVN_PROMPT_CLEAN" + fi +} + +function svn_prompt_info { + info=$(svn info 2>/dev/null) || return + rev=$(echo "$info" | grep Revision | sed 's/Revision: //') + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}r${rev}$(svn_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" +} diff --git a/zsh/termsupport.zsh b/zsh/termsupport.zsh new file mode 100644 index 0000000..6768222 --- /dev/null +++ b/zsh/termsupport.zsh @@ -0,0 +1,23 @@ +#done + +case "$TERM" in + xterm*|rxvt*) + term_preexec () { + print -Pn "\e]0;%n@%m:%~ ($1)\a" # xterm + } + term_precmd () { + print -Pn "\e]0;%n@%m:%~\a" # xterm + } + ;; + screen*) + term_preexec () { + local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} + echo -ne "\ek$CMD\e\\" + print -Pn "\e]0;%n@%m:%~($1)\a" # xterm + } + term_precmd () { + echo -ne "\ekzsh\e\\" + print -Pn "\e]0;%n@%m:%~\a" # xterm + } + ;; +esac |