Skip to content

Instantly share code, notes, and snippets.

@dekom
Created August 31, 2012 05:50
Show Gist options
  • Save dekom/3549472 to your computer and use it in GitHub Desktop.
Save dekom/3549472 to your computer and use it in GitHub Desktop.
Someone's ZSH Configuration file
####### zsh configuration file ######
### Init ###
autoload -U compinit promptinit
compinit
promptinit
#prompt walters
prompt own
### Completion ###
zstyle ':completion:*' menu select
# allow approximate
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
# increase number of errors with length of the typed
zstyle -e ':completion:*:approximate:*' \
max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
# ignore completion for commands which are not installed
zstyle ':completion:*:functions' ignored-patterns '_*'
# tab completion for PID
zstyle ':completion:*:*:kill:*' menu yes select
zstyle ':completion:*:kill:*' force-list always
# colorful listings
eval "`dircolors -b`" # sets $LS_COLORS to the default colors used by ls
zmodload -i zsh/complist
zstyle ':completion:*' list-colors ${LS_COLORS}
# cache results
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path $HOME/.zsh_cache
### Zsh Options ###
setopt appendhistory
setopt sharehistory # share history between multiple running terminals
setopt autocd # change dir without 'cd'
### Key Bindings ###
typeset -g -A key
bindkey '^?' backward-delete-char
bindkey '^[[1~' beginning-of-line
bindkey '^[[5~' up-line-or-history
bindkey '^[[3~' delete-char
bindkey '^[[4~' end-of-line
bindkey '^[[6~' down-line-or-history
bindkey '^[[A' up-line-or-search
bindkey '^[[D' backward-char
bindkey '^[[B' down-line-or-search
bindkey '^[[C' forward-char
### Aliases ###
alias sudo="sudo " #Sudo wont recognize aliases without this
alias ls='ls --color=auto'
alias l='ls' # yes, I'm lazy
alias la='ls -a'
alias ll='ls -l'
alias lla='ls -la'
alias fu='sudo $(fc -ln -1)' # start last executed command with sudo
alias ..='cd ..'
# application aliases
alias pacman32='sudo pacman --root /opt/arch32 --cachedir \
/opt/arch32/var/cache/pacman/pkg --config /opt/arch32/pacman.conf'
alias archmobile_enter='sudo archmobile_enter'
alias gtkpod='sudo gtkpod'
### Environment variables ###
export PATH="/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:\
/home/naeg/bin:/opt/jre/bin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:\
/usr/bin/perl/bin/core:/opt/java/jre/bin"
export HISTFILE=~/.zsh_history
export HISTSIZE=50000
export SAVEHIST=50000
export EDITOR=vim
### Random ###
#always start urxvt with screen
[ "$TERM" = "rxvt-unicode" ] && screen
## Functions
## format titles for screen and rxvt
# stolen from dotfiles.org
function title() {
# escape '%' chars in $1, make nonprintables visible
a=${(V)1//\%/\%\%}
# Truncate command, and join lines.
a=$(print -Pn "%40>...>$a" | tr -d "\n")
case $TERM in
screen)
print -Pn "\ek$a:$3\e\\" # screen title (in ^A")
;;
xterm*|rxvt)
print -Pn "\e]2;$2 | $a:$3\a" # plain xterm title
;;
esac
}
# precmd is called just before the prompt is printed
function precmd() {
title "zsh"
}
# preexec is called just before any command line is executed
function preexec() {
title "$1"
}
# end of crime
# extract function for several archive types
extract() {
if [ -f $1 ]; then
case $1 in
(*.tar.gz) tar -xvzf $1;;
(*.tar.bz2) tar -xvjf $1;;
(*.tgz) tar -xvzf $1;;
(*.tbz2) tar -xvjf $1;;
(*.gz) gunzip -v $1;;
(*.bz2) bunzip2 -v $1;;
(*.zip) unzip -v $1;;
(*.rar) unrar xv $1;;
(*) echo 'Can not handle file'
esac
else
echo 'File does not exist'
fi
}
###### EOF .zshrc ######
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment