Please bear with us as we work to restore functionality to dotfiles.org.
#
# .zshrc is sourced in interactive shells.
# It should contain commands to set up aliases,
# functions, options, key bindings, etc.
#
# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
eval `dircolors 2>/dev/null` # set up color-ls variables
########################################################################
# prompt, shell parameters
########################################################################
precmd () {
(( PR_PATHSPACE=${COLUMNS:-80} - ${#${(%):--(%n@%m)-(%T)[]-}} ))
if (( $PR_PATHSPACE < 2 )); then
PR_PATHSPACE=3
fi
(( PR_LINESPACE=PR_PATHSPACE - ${#${(%):-%~}} ))
if (( $PR_LINESPACE < 0 )); then
PR_LINESPACE=0
fi
PR_FILLBAR="$PR_SHIFT_IN\${(l.PR_LINESPACE..${PR_HBAR}.)}${PR_SHIFT_OUT}[%B%"$PR_PATHSPACE$'<..<%~%<<%b'
}
chpwd () {
[[ -t 1 ]] || return
if [[ -n $ZFTP_USER ]]
then
zftp_chpwd
else
case $TERM in
(sun-cmd)
print -Pn "\e]l$TERM %m %~\e\\" ;;
(*xterm*|cygwin|rxvt|(dt|k|E)term)
print -Pn "\e]0;%~\a"
print -Pn "\e]2;$TERM %m %~\a" ;;
(screen)
print -Pn "\e]0;%~\a" ;;
esac
fi
}
chpwd;
autoload -U colors && colors
setopt prompt_subst
###
# See if we can use extended characters to look nicer.
typeset -A altchar
set -A altchar ${(s..)terminfo[acsc]}
PR_SET_CHARSET="%{$terminfo[enacs]%}"
PR_SHIFT_IN="%{$terminfo[smacs]%}"
PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
PR_HBAR=${altchar[q]:--}
PR_ULCORNER=${altchar[l]:--}
PR_LLCORNER=${altchar[m]:--}
PR_LRCORNER=${altchar[j]:--}
PR_URCORNER=${altchar[k]:--}
#setting PS1 = "-"
PS1='$PR_SET_CHARSET$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT'
#adding "(user@machine)", root hilited in red
if [[ $USER == root ]];
then
PS1=$PS1'($fg[red]%n$fg[$PS1color]@%m$fg[default])'
else
PS1=$PS1'($fg[$PS1color]%n@%m$fg[default])'
fi
#adding "-(time)PR_FILLBAR]-{newline}$ "
PS1=$PS1'$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(%T)${(e)PR_FILLBAR}]$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT'$'\n$ '
case $TERM in
(cygwin|linux|screen.linux)
: ${PS1color:=green} ;;
(xterm)
: ${PS1color:=cyan} ;;
(screen)
: ${PS1color:=blue}
PS1=$'%{\ek\e\\%}'$PS1 ;;
(*)
: ${PS1color:=default} ;;
esac
########################################################################
# zsh parameters
########################################################################
HISTFILE=~/.zsh/$HOST/history
HISTSIZE=3000
SAVEHIST=3000
DIRSTACKSIZE=12
########################################################################
# zsh options
########################################################################
# Allow jobs that finish to send a message (Done) asynchronously
setopt notify monitor nohup
setopt noclobber
setopt correct
setopt nolistbeep
setopt autolist
setopt automenu
setopt autocd
setopt autoparamkeys
setopt autoparamslash
setopt autoremoveslash
setopt brace_ccl
setopt no_glob_dots extended_glob numeric_glob_sort
setopt histignorespace extendedhistory hist_find_no_dups
setopt hist_no_store hist_expire_dups_first hist_reduce_blanks
setopt inc_append_history
setopt pushdtohome pushdsilent autopushd pushdignoredups nopushdminus
setopt complete_in_word
setopt interactive_comments
setopt no_bgnice
########################################################################
# fine tuning of completion system
########################################################################
[[ -d ~/.zsh/$HOST ]] || mkdir -p ~/.zsh/$HOST
zstyle ':completion:*' file-sort 'time'
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}'
zstyle ':completion:*' max-errors 1
zstyle ':completion:*' completer _complete _approximate
zstyle -e ':completion::complete:s(cp|sh):*' hosts "reply=( \$( gawk '
/^#/ { next }
/^Host\>/ { \$1 = \"\"; print }
ARGIND > 1 && !FS_set { FS = \"[, ]\"; FS_set++; \$0 = \$0; }
FS_set { print \$1, \$2 }
' ~/.ssh/config ~/.ssh/known_hosts )
)"
zstyle ':zftp:*' progress 'percent'
zstyle ':completion:history-words:*' range 500:50
zstyle ':completion:history-words:*' remove-all-dups true
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/${HOST}/zcompcache
zstyle ':completion:*:(kill|renice):*:processes' menu yes select
zstyle ':completion:*:kill:*:processes' force-list always
zstyle ':completion:*:(kill|renice):*:processes' \
list-colors "=(#b) #([0-9]#)*=30=32"
zstyle ':completion:*:(kill|renice):*:processes' \
command 'ps -u $USERNAME -o pid,s,nice,stime,args'
# Filename suffixes to ignore during completion (except after rm command)
zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.obj' \
'*?.old' '*?.pro' '*?.c~'
# The following lines were added by compinstall
zstyle :compinstall filename ${HOME}/.zshrc
autoload -U compinit
compinit -d ~/.zsh/$HOST/zcompdump_$ZSH_VERSION
# End of lines added by compinstall
compdef _grep zgrep zegrep zfgrep bzgrep
zstyle ':completion:*:*:(z|ze|zf)grep:*:*' file-patterns \
'*.[gG][zZ]:compressed-files:compressed\ files' \
'*(-/):directories:directories' \
'^*.[gG][zZ](-^/):other-files:other\ files'
zstyle ':completion:*:*:bzgrep:*:*' file-patterns \
'*.bz2:compressed-files:compressed\ files' \
'*(-/):directories:directories' \
'^*.bz2(-^/):other-files:other\ files'
########################################################################
# keep .zcompdump.zwc up to date
if [[ ! -f ~/.zsh/$HOST/zcompdump_$ZSH_VERSION.zwc ||
-n ${~:-~/.zshrc(Nmm+1)} &&
~/.zsh/$HOST/zcompdump_$ZSH_VERSION -nt \
~/.zsh/$HOST/zcompdump_$ZSH_VERSION.zwc ]];
then
print "compiling ~/.zsh/$HOST/zcompdump_$ZSH_VERSION"
zcompile ~/.zsh/$HOST/zcompdump_$ZSH_VERSION
fi
########################################################################
# remove bindings defined in _history_complete_word
bindkey -r '\e/'
bindkey -r '\e,'
########################################################################
## Setting the proper behavior for Delete, Home, End e.t.c.:
#case $TERM in
# linux)
bindkey "^[[2~" yank
bindkey "^[[3~" delete-char
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line
bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command
bindkey "^[[A" up-line-or-search ## up arrow for back-history-search
bindkey "^[[B" down-line-or-search ## down arrow for fwd-history-search
bindkey " " magic-space ## do history expansion on space
#;;
#*xterm*|rxvt|(dt|k|E)term)
bindkey "^[[2~" yank
bindkey "^[[3~" delete-char
bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
bindkey "^[e" expand-cmd-path ## C-e for expanding path of typed command
bindkey "^[[A" up-line-or-search ## up arrow for back-history-search
bindkey "^[[B" down-line-or-search ## down arrow for fwd-history-search
bindkey " " magic-space ## do history expansion on space
#;;
#esac
# P.S.: if you choose konsole in KDE and select 'Linux console' type,
# then there is no need in the second section
########################################################################
## cpd Change to a Previous Directory (contained in the directory stack)
##
## Author W.Friebel friebel@ifh.de 13/04/95
##
## Usage: cpd
## displays the directories in the buffer stack
## chose the directory you want to cd to with the cursor keys
## optionally edit the directory string
## select the directory by pressing Enter (or ^X^W)
## or leave the menu with ^C
##
## The function is of little use unless the option autopushd is set.
## It is furthermore useful to set pushdsilent and pushdignoredups
## the dirs or pushd function can be used in addition to preload
## frequently used directories into the directory stack
cpd()
{
TRAPINT () {
bindkey "^M" accept-line
setopt +B
trap - INT
builtin let "$1 > 0" && return $[128+$1]
}
setopt -B
bindkey -s "^M" "^X^W"
bindkey "^[k" kill-region
# Select_Key definition:
# to column 2; to begin of line; insert cd ;
# to begin of line; mark position; to begin of buffer; delete up to mark
# to end of line; mark position; to end of buffer; to end of line
# delete up to mark; put cd command into input buffer and execute
bindkey -s "^X^W" "^[2^[|^A cd ^A^@^[<^[k^E^@^[>^E^[k^[a^X^K"
cpd_var=`builtin print "### Select (and Edit) directory, Enter to accept it, ^C to quit ###"
builtin print -l \`dirs \``
vared cpd_var
bindkey "^M" accept-line
setopt +B
eval $cpd_var
}
# grabs latest .zshrc from dotfiles.org, and moves .zshrc to .zshrc.old
# backs up .zshrc.old to .zshrc.old.old just in case ;)
function updatezshrc() {
echo "Starting in 5 seconds... Ctrl+C to abort..."
sleep 5
# back up .zshrc.old just in case, only if it exists
if [[ $(file .zshrc.old) != "" ]]; then
mv .zshrc.old .zshrc.old.old
fi
# Back up .zshrc
mv .zshrc .zshrc.old
# Get new .zshrc from dotfiles.org
curl -o .zshrc http://dotfiles.org/~bryndin/.zshrc
}