Please bear with us as we work to restore functionality to dotfiles.org.
Found out the hard way that usernames with spaces don't work. Anyway...
This is my first crack at zsh. Most useful on debian/ubuntu systems with aptitude. It also includes a fun little easter egg.
updated: 17 Jul 2008
#########################################################################
# #
# 383_Inc's zshrc for ubuntu v1.1 #
# nullum magnum ingenium sine mixtura dementiae fuit #
# --Seneca #
#########################################################################
export PAGER='less'
export EDITOR='vim'
##############
# Prompt #
##############
export PS1='%n@%m:%~ %# '
autoload -U promptinit
promptinit
##############
# Title #
##############
export DEFAULT_TITLE='%n@%m: %~'
export TITLE=$DEFAULT_TITLE
case $TERM in (xterm*|rxvt|screen)
precmd () { print -Pn "\e]0;$TITLE \a" }
;;
esac
function title (){
if [ -z $1 ]; then
export TITLE=$DEFAULT_TITLE
else
export TITLE=$1
fi
}
##############
# Completion #
##############
autoload -Uz compinit
compinit
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' max-errors 3 numeric
zstyle :compinstall filename '/home/chris/.zshrc'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
setopt correct_all
setopt auto_menu
setopt complete_aliases
#############
# History #
#############
export HISTFILE=~/.zsh_history
export HISTSIZE=1000
export SAVEHIST=$HISTSIZE
setopt hist_ignore_dups
setopt share_history
##############
# Options #
##############
setopt autocd
setopt glob
setopt extendedglob
setopt chase_links
setopt auto_resume
setopt hash_cmds
setopt hash_dirs
setopt hash_list_all
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
##############
# Aliases #
##############
# Apt #
alias install='sudo aptitude install'
alias reinstall='sudo aptitude reinstall'
alias remove='uninst && sudo aptitude $UNINSTALL'
alias uninstall='uninst && sudo aptitude $UNINSTALL'
alias purge='uninst && sudo aptitude $UNINSTALL'
alias update='sudo aptitude update'
alias upgrade='sudo aptitude safe-upgrade'
alias full-upgrade='sudo aptitude full-upgrade'
alias reconfigure='sudo dpkg-reconfigure'
alias search='aptitude search'
# File Management #
alias mv='nocorrect mv -i'
alias cp='nocorrect cp -i'
alias mkdir='nocorrect mkdir'
alias ls='ls --color=auto'
alias l='ls -gh --color=auto'
alias la='ls -a --color=auto'
alias rm='rm -i'
alias rf='rm -rf'
alias mcd='nocorrect mkdir $1 && cd $1'
# Directories #
alias music=$HOME/Music
alias videos=$HOME/Videos
alias pictures=$HOME/Pictures
alias desktop=$HOME/Desktop
alias downloads=$HOME/Downloads
# Miscellaneous #
alias untar='extract'
alias c=clear
alias exit='clear && exit'
alias download='wget'
alias dnld='wget'
alias figfonts='ls /usr/share/figlet/*.(flf|tlf)'
alias zshrc='vim $HOME/.zshrc'
alias sources.list='sudo vim /etc/apt/sources.list'
alias conkyrc='vim $HOME/.conkyrc'
# Suffixes #
alias -s com=links
alias -s org=links
alias -s net=links
alias -s php=links
alias -s txt=vim
alias -s list=vim
alias -s lst=vim
##############
# Scripts #
##############
#--------------------#
# Purge on Uninstall #
#--------------------#
uninst () {
echo "Remove Configuration Files [y/n/q]"
read var
if [ $var = "y" ]; then
export UNINSTALL=purge
elif [ $var = "n" ]; then
export UNINSTALL=remove
elif [ $var = "q" ]; then
echo "Bye"
fi
}
#-------------------------#
# Move Files to the Trash #
#-------------------------#
trash() {
if [ -z $1 ]; then
echo "Empty Trash? [y/n]"
read var
if [ $var = y ]; then
sudo rm -rf $HOME/.local/share/Trash/files/*
else
echo "Bye"
fi
elif [ -f $1 ]; then
echo "Move to Trash or Delete [t/d/?]"
read var
if [ $var = t ]; then
mv -rv $1 $HOME/.local/share/Trash/files
elif [ $var = d ]; then
rm -ri $1
elif [ $var = ? ]; then
echo "t to Trash or d to Delete"
else
echo 'The requested file/folder, $1, does not exist'
fi
fi
}
#--------------------------#
# Extract Various Archives #
#--------------------------#
extract() {
if [ -f $1 ]; then
case $1 in
(*.tar.gz | *.tgz) tar -xvzf $1;;
(*.tar.bz2 | *.tbz2) tar -xvjf $1;;
(*.gz) gunzip -v $1;;
(*.bz2) bunzip2 -v $1;;
(*.zip) unzip $1;;
(*.rar) unrar xv $1;;
esac
else
echo 'Can not handle file. Does it exist?'
fi
}
#------------------#
# Rationalise Dots #
#------------------#
rationalise-dot() {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+=/..
else
LBUFFER+=.
fi
}
zle -N rationalise-dot
bindkey . rationalise-dot
##############
# EasterEggs #
##############
littlelamb() {
beep -f 10
if [ $? = 0 ]; then
echo 'Marry Had A Little Lamb'
beep -f 466.2 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 370.0 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 466.2 -l 250 -r 2 -d 0 -D 20 -n -f 466.2 -l 500 -n -f 10 -l 20
echo 'Little Lamb, Little Lamb'
beep -f 415.3 -l 250 -r 2 -d 0 -D 20 -n -f 415.3 -l 500 -D 20 -n -f 466.2 -l 250 -D 20 -n -f 568.8 -l 250 -D 20 -n -f 568.8 -l 500 -n -f 10 -l 20
echo 'Marry Had A Little Lamb'
beep -f 466.2 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 370.0 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 466.2 -l 250 -r 2 -d 0 -D 20 -n -f 466.2 -l 250 -n -f 10 -l 20
echo 'Whose Fleece Was White As Snow'
beep -f 415.3 -l 250 -r 3 -D 20 -n -f 466.2 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 370.0 -l 500
elif [ $? = '127' ]; then
echo 'Requires beep to be installed. Install now y/n?'
read var
if [ $var = 'y' ]; then
sudo aptitude install beep
littlelamb
elif [ $var = 'n' ]; then
echo 'Bye'
fi
fi
}