diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/aliases.zsh | 6 | ||||
| -rw-r--r-- | lib/completion.zsh | 31 | ||||
| -rw-r--r-- | lib/grep.zsh | 22 | ||||
| -rw-r--r-- | lib/history.zsh | 1 | ||||
| -rw-r--r-- | lib/key-bindings.zsh | 91 | ||||
| -rw-r--r-- | lib/prompt_info_functions.zsh | 33 | ||||
| -rw-r--r-- | lib/rbenv.zsh | 2 | ||||
| -rw-r--r-- | lib/rvm.zsh | 8 | ||||
| -rw-r--r-- | lib/spectrum.zsh | 8 | ||||
| -rw-r--r-- | lib/termsupport.zsh | 10 | 
10 files changed, 135 insertions, 77 deletions
| diff --git a/lib/aliases.zsh b/lib/aliases.zsh index b279bf855..3044c9660 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -27,9 +27,9 @@ else  fi  # List direcory contents  alias lsa='ls -lah' -alias l='ls -la' -alias ll='ls -l' -alias la='ls -lA' +alias l='ls -lah' +alias ll='ls -lh' +alias la='ls -lAh'  alias sl=ls # often screw this up  alias afind='ack-grep -il' diff --git a/lib/completion.zsh b/lib/completion.zsh index e0cdcf626..c54249c52 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -31,35 +31,20 @@ zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm  zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories  cdpath=(.) -# use /etc/hosts and known_hosts for hostname completion -[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=() -[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=() -[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=() -[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=() -hosts=( -  "$_ssh_config[@]" -  "$_global_ssh_hosts[@]" -  "$_ssh_hosts[@]" -  "$_etc_hosts[@]" -  "$HOST" -  localhost -) -zstyle ':completion:*:hosts' hosts $hosts -zstyle ':completion:*' users off -  # Use caching so that commands like apt and dpkg complete are useable  zstyle ':completion::complete:*' use-cache 1  zstyle ':completion::complete:*' cache-path $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 +        adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ +        clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ +        gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ +        ldap lp mail mailman mailnull man messagebus  mldonkey mysql nagios \ +        named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ +        operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ +        rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ +        usbmux uucp vcsa wwwrun xfs  # ... unless we really want to.  zstyle '*' single-ignored show diff --git a/lib/grep.zsh b/lib/grep.zsh index 93c4270b6..276fec382 100644 --- a/lib/grep.zsh +++ b/lib/grep.zsh @@ -2,5 +2,23 @@  # Color grep results  # Examples: http://rubyurl.com/ZXv  # -export GREP_OPTIONS='--color=auto' -export GREP_COLOR='1;32'
\ No newline at end of file + +GREP_OPTIONS="--color=auto" + +# avoid VCS folders (if the necessary grep flags are available) +grep-flag-available() { +    echo | grep $1 "" >/dev/null 2>&1 +} +if grep-flag-available --exclude-dir=.cvs; then +    for PATTERN in .cvs .git .hg .svn; do +        GREP_OPTIONS+=" --exclude-dir=$PATTERN" +    done +elif grep-flag-available --exclude=.cvs; then +    for PATTERN in .cvs .git .hg .svn; do +        GREP_OPTIONS+=" --exclude=$PATTERN" +    done +fi +unfunction grep-flag-available + +export GREP_OPTIONS="$GREP_OPTIONS" +export GREP_COLOR='1;32' diff --git a/lib/history.zsh b/lib/history.zsh index 655945166..1d83e56e3 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -5,7 +5,6 @@ fi  HISTSIZE=10000  SAVEHIST=10000 -setopt append_history  setopt extended_history  setopt hist_expire_dups_first  setopt hist_ignore_dups # ignore duplication command history list diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 49f80c8f3..9063c6a18 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -1,34 +1,63 @@ -# TODO: Explain what some of this does.. - -bindkey -e -bindkey '\ew' kill-region -bindkey -s '\el' "ls\n" -bindkey '^r' history-incremental-search-backward -bindkey "^[[5~" up-line-or-history -bindkey "^[[6~" down-line-or-history - -# make search up and down work, so partially type and hit up/down to find relevant stuff -bindkey '^[[A' up-line-or-search -bindkey '^[[B' down-line-or-search - -bindkey "^[[H" beginning-of-line -bindkey "^[[1~" beginning-of-line -bindkey "^[OH" beginning-of-line -bindkey "^[[F"  end-of-line -bindkey "^[[4~" end-of-line -bindkey "^[OF" end-of-line -bindkey ' ' magic-space    # also do history expansion on space - -bindkey "^[[1;5C" forward-word -bindkey "^[[1;5D" backward-word - -bindkey '^[[Z' reverse-menu-complete - -# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~ -bindkey '^?' backward-delete-char -bindkey "^[[3~" delete-char -bindkey "^[3;5~" delete-char -bindkey "\e[3~" delete-char +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins +# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets + +# Make sure that the terminal is in application mode when zle is active, since +# only then values from $terminfo are valid +if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then +  function zle-line-init() { +    echoti smkx +  } +  function zle-line-finish() { +    echoti rmkx +  } +  zle -N zle-line-init +  zle -N zle-line-finish +fi + +bindkey -e                                            # Use emacs key bindings + +bindkey '\ew' kill-region                             # [Esc-w] - Kill from the cursor to the mark +bindkey -s '\el' 'ls\n'                               # [Esc-l] - run command: ls +bindkey '^r' history-incremental-search-backward      # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. +if [[ "${terminfo[kpp]}" != "" ]]; then +  bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history +fi +if [[ "${terminfo[knp]}" != "" ]]; then +  bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history +fi + +if [[ "${terminfo[kcuu1]}" != "" ]]; then +  bindkey "${terminfo[kcuu1]}" up-line-or-search      # start typing + [Up-Arrow] - fuzzy find history forward +fi +if [[ "${terminfo[kcud1]}" != "" ]]; then +  bindkey "${terminfo[kcud1]}" down-line-or-search    # start typing + [Down-Arrow] - fuzzy find history backward +fi + +if [[ "${terminfo[khome]}" != "" ]]; then +  bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line +fi +if [[ "${terminfo[kend]}" != "" ]]; then +  bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line +fi + +bindkey ' ' magic-space                               # [Space] - do history expansion + +bindkey '^[[1;5C' forward-word                        # [Ctrl-RightArrow] - move forward one word +bindkey '^[[1;5D' backward-word                       # [Ctrl-LeftArrow] - move backward one word + +if [[ "${terminfo[kcbt]}" != "" ]]; then +  bindkey "${terminfo[kcbt]}" reverse-menu-complete   # [Shift-Tab] - move through the completion menu backwards +fi + +bindkey '^?' backward-delete-char                     # [Backspace] - delete backward +if [[ "${terminfo[kdch1]}" != "" ]]; then +  bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward +else +  bindkey "^[[3~" delete-char +  bindkey "^[3;5~" delete-char +  bindkey "\e[3~" delete-char +fi  # Edit the current command line in $EDITOR  autoload -U edit-command-line diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh new file mode 100644 index 000000000..335c02a3d --- /dev/null +++ b/lib/prompt_info_functions.zsh @@ -0,0 +1,33 @@ +# *_prompt_info functions for usage in your prompt +# +# Plugin creators, please add your *_prompt_info function to the list +# of dummy implementations to help theme creators not receiving errors +# without the need of implementing conditional clauses. +# +# See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for +# git_prompt_info, bzr_prompt_info and nvm_prompt_info + +# Dummy implementations that return false to prevent command_not_found +# errors with themes, that implement these functions +# Real implementations will be used when the respective plugins are loaded +function chruby_prompt_info hg_prompt_info pyenv_prompt_info \ +  rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \ +  virtualenv_prompt_info { +  return 1 +} + +# oh-my-zsh supports an rvm prompt by default +# get the name of the rvm ruby version +function rvm_prompt_info() { +  [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 +  local rvm_prompt +  rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) +  [[ "${rvm_prompt}x" == "x" ]] && return 1 +  echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" +} + +# use this to enable users to see their ruby version, no matter which +# version management system they use +function ruby_prompt_info() { +  echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info) +} diff --git a/lib/rbenv.zsh b/lib/rbenv.zsh deleted file mode 100644 index a8b6c323c..000000000 --- a/lib/rbenv.zsh +++ /dev/null @@ -1,2 +0,0 @@ -# using the rbenv plugin will override this with a real implementation -function rbenv_prompt_info() {} diff --git a/lib/rvm.zsh b/lib/rvm.zsh deleted file mode 100644 index e8744e61e..000000000 --- a/lib/rvm.zsh +++ /dev/null @@ -1,8 +0,0 @@ -# get the name of the ruby version -function rvm_prompt_info() { -  [ -f $HOME/.rvm/bin/rvm-prompt ] || return -  local rvm_prompt -  rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) -  [[ "${rvm_prompt}x" == "x" ]] && return -  echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" -} diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh index 166c942fb..b683aca29 100644 --- a/lib/spectrum.zsh +++ b/lib/spectrum.zsh @@ -19,17 +19,19 @@ for color in {000..255}; do      BG[$color]="%{[48;5;${color}m%}"  done + +ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris} +  # Show all 256 colors with color number  function spectrum_ls() {    for code in {000..255}; do -    print -P -- "$code: %F{$code}Test%f" +    print -P -- "$code: %F{$code}$ZSH_SPECTRUM_TEXT%f"    done  }  # Show all 256 colors where the background is set to specific color  function spectrum_bls() {    for code in {000..255}; do -    ((cc = code + 1)) -    print -P -- "$BG[$code]$code: Test %{$reset_color%}" +    print -P -- "$BG[$code]$code: $ZSH_SPECTRUM_TEXT %{$reset_color%}"    done  } diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 80319e1a8..9c0a430fb 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -26,10 +26,12 @@ function omz_termsupport_precmd {  function omz_termsupport_preexec {    emulate -L zsh    setopt extended_glob -  local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd -  local LINE="${2:gs/$/\\$}" -  LINE="${LINE:gs/%/%%}" -  title "$CMD" "%100>...>$LINE%<<" + +  # cmd name only, or if this is sudo or ssh, the next cmd +  local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]:gs/%/%%} +  local LINE="${2:gs/%/%%}" + +  title '$CMD' '%100>...>$LINE%<<'  }  autoload -U add-zsh-hook | 
