summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-02 23:46:23 (GMT)
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-02 23:50:24 (GMT)
commit2bda9018c3c3441ba8d66e28711e0f9dafe66ac0 (patch)
tree0028547b03159932a27337c08059bf0ffface1fa
parentba13130b3cf4256bfef9b47f04da53c804e7a4f1 (diff)
downloaddotfiles-2bda9018c3c3441ba8d66e28711e0f9dafe66ac0.tar.xz
zshrc: standardized variables and quotes
-rwxr-xr-xxinitrc2
-rw-r--r--zshrc331
2 files changed, 168 insertions, 165 deletions
diff --git a/xinitrc b/xinitrc
index 31730e5..40e513c 100755
--- a/xinitrc
+++ b/xinitrc
@@ -106,7 +106,7 @@ case "$1" in
exec startkde
;;
debug)
- exec valgrind "$2"
+ exec valgrind -v "$2"
;;
*)
exec awesome
diff --git a/zshrc b/zshrc
index 4dcd78b..68527f9 100644
--- a/zshrc
+++ b/zshrc
@@ -6,20 +6,21 @@
# {{{ User settings
# {{{ Environment
-export PATH=$PATH:~/code/bin
-export HISTFILE=~/.zsh_history
+export PATH="${PATH}:${HOME}/code/bin"
+export HISTFILE="${HOME}/.zsh_history"
export HISTSIZE=10000
export SAVEHIST=10000
export LESSHISTFILE="-"
export PAGER="less"
+export READNULLCMD="${PAGER}"
export VISUAL="emacsclient"
-export EDITOR=$VISUAL
+export EDITOR="${VISUAL}"
export BROWSER="firefox"
export XTERM="urxvt"
# }}}
# {{{ Mail settings
-export MAIL=~/mail/Inbox
+export MAIL="${HOME}/mail/Inbox"
export MAILCHECK=300
export GPGKEY="0xD20A0618"
# }}}
@@ -32,7 +33,7 @@ export GPGKEY="0xD20A0618"
# {{{ Dircolors
# - with rxvt-256color support
-eval `dircolors -b ~/.dir_colors`
+eval `dircolors -b "${HOME}/.dir_colors"`
# }}}
# {{{ Manual pages
@@ -49,146 +50,107 @@ export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
# {{{ Aliases
# {{{ Main
-alias ..='cd ..'
-alias ...='cd ../..'
-alias ls='ls -aF --color=always'
-alias ll='ls -l'
+alias ..="cd .."
+alias ...="cd ../.."
+alias ls="ls -aF --color=always"
+alias ll="ls -l"
alias lfi="ls -l | egrep -v '^d'"
alias ldi="ls -l | egrep '^d'"
-alias lst="ls -htl | grep $(date +%Y-%m-%d)"
-alias grep='grep --color=always'
-alias cp='cp -ia'
-alias mv='mv -i'
-alias rm='rm -i'
-alias cls='clear'
-alias upmem='ps aux | sort -k 6'
-alias top='htop'
-alias psg='ps auxw | grep -i '
-alias psptree='ps auxwwwf'
-alias df='df -hT'
-alias du='du -hc'
-alias dus='du -S | sort -n'
-alias free='free -m'
-alias su='su - '
-alias x='startx &! logout'
-alias rehash='hash -r'
-alias eject='eject -v '
-alias retract='eject -t -v '
-alias vuser='fuser -v '
-alias ping='ping -c 5'
-alias more='less'
-alias mc='. /usr/lib/mc/mc-wrapper.sh -x'
-alias links='links ~/.links/startpage.html'
-alias cplay='cplay -v'
-alias xtr='extract'
-alias screen='screen -U -l'
-alias scr='screen -r'
-alias scd='screen -rd'
-alias sat='date +%R'
-alias bat='acpitool -b'
-alias calc='bc -l <<<'
-alias iodrag='ionice -c3 nice -n19'
-alias spell='aspell -a <<< '
-alias ec='emacsclient -a emacs -n '
-alias ect='emacsclient -a emacs -t '
-alias gpgd='gpg2 --decrypt'
-alias gpge='gpg2 -ear anrxc'
-alias keyshare='synergys -f --config /etc/synergy.conf'
-alias xpop='xprop | grep --color=none "WM_CLASS\|^WM_NAME" | xmessage -file -'
+alias lst="ls -htl | grep `date +%Y-%m-%d`"
+alias grep="grep --color=always"
+alias cp="cp -ia"
+alias mv="mv -i"
+alias rm="rm -i"
+alias cls="clear"
+alias upmem="ps aux | sort -k 6"
+alias top="htop"
+alias psg="ps auxw | grep -i "
+alias psptree="ps auxwwwf"
+alias df="df -hT"
+alias du="du -hc"
+alias dus="du -S | sort -n"
+alias free="free -m"
+alias su="su - "
+alias x="startx &! logout"
+alias rehash="hash -r"
+alias eject="eject -v "
+alias retract="eject -t -v "
+alias vuser="fuser -v "
+alias ping="ping -c 5"
+alias more="less"
+alias mc=". /usr/lib/mc/mc-wrapper.sh -x"
+alias links="links ${HOME}/.links/startpage.html"
+alias cplay="cplay -v"
+alias xtr="extract"
+alias screen="screen -U -l"
+alias scr="screen -r"
+alias scd="screen -rd"
+alias sat="date +%R"
+alias bat="acpitool -b"
+alias calc="bc -l <<<"
+alias iodrag="ionice -c3 nice -n19"
+alias spell="aspell -a <<< "
+alias ec="emacsclient -a emacs -n "
+alias ect="emacsclient -a emacs -t "
+alias gpgd="gpg2 --decrypt"
+alias gpge="gpg2 -ear anrxc"
+alias passgen="< /dev/urandom tr -cd \[:graph:\] | fold -w 32 | head -n 5"
+alias keyshare="synergys -f --config /etc/synergy.conf"
+alias xpop="xprop | grep --color=none 'WM_CLASS\|^WM_NAME' | xmessage -file -"
# }}}
# {{{ Pacman
-alias pacsy='sudo pacman -Sy' # Sync & Update
-alias pacup='sudo pacman -Syu' # Sync, Update & Upgrade
-alias pacdg='sudo pacman -Syuu' # Sync, Update & Downgrade
-alias paclu='pacman -Qu' # List upgradeable
-alias pacin='sudo pacman -S' # Install a specific package
-alias pacnd='sudo pacman -Sd' # Install a package but ignore deps
-alias pacrm='sudo pacman -Rns' # Remove a specific package
-alias pacrd='sudo pacman -Rd' # Remove a package but ignore deps
-alias pacss='pacman -Ss' # Search for a package
-alias pacsl='pacman -Qs' # Search for a package localy
-alias pacsi='pacman -Si' # Package info
-alias pacqi='pacman -Qi' # Package local info
-alias pacls='pacman -Ql' # List files in a package
-alias pacui='pacman -Qm' # List localy built packages
-alias pacfi='pacman -Qo' # Which package file belongs to
-alias paccl='sudo pacman -Scc' # Fully clean the package cache
-alias pacdl='sudo pacman -Sw' # Download a package without installing
-alias paclo='pacman -Qdt' # List package orphans
-alias paclog='pacman -Qc' # Package changelog
+alias pacsy="sudo pacman -Sy" # Sync & Update
+alias pacup="sudo pacman -Syu" # Sync, Update & Upgrade
+alias pacdg="sudo pacman -Syuu" # Sync, Update & Downgrade
+alias paclu="pacman -Qu" # List upgradeable
+alias pacin="sudo pacman -S" # Install a specific package
+alias pacnd="sudo pacman -Sd" # Install a package but ignore deps
+alias pacrm="sudo pacman -Rns" # Remove a specific package
+alias pacrd="sudo pacman -Rd" # Remove a package but ignore deps
+alias pacss="pacman -Ss" # Search for a package
+alias pacsl="pacman -Qs" # Search for a package localy
+alias pacsi="pacman -Si" # Package info
+alias pacqi="pacman -Qi" # Package local info
+alias pacls="pacman -Ql" # List files in a package
+alias pacui="pacman -Qm" # List localy built packages
+alias pacfi="pacman -Qo" # Which package file belongs to
+alias paccl="sudo pacman -Scc" # Fully clean the package cache
+alias pacdl="sudo pacman -Sw" # Download a package without installing
+alias paclo="pacman -Qdt" # List package orphans
+alias paclog="pacman -Qc" # Package changelog
# }}}
# {{{ Slurpy
-alias aurup='slurpy -c -u -d' # Sync, Update & Download
-alias aurlu='slurpy -c -u' # Update & List upgradeable
-alias aurss='slurpy -c -s' # Search for a package
-alias aursi='slurpy -c -i' # Package info
-alias aurdl='slurpy -c -d' # Download a package without installing
+alias aurup="slurpy -c -u -d" # Sync, Update & Download
+alias aurlu="slurpy -c -u" # Update & List upgradeable
+alias aurss="slurpy -c -s" # Search for a package
+alias aursi="slurpy -c -i" # Package info
+alias aurgo="slurpy -c -g" # Visit AUR page
+alias aurdl="slurpy -c -d" # Download a package without installing
# }}}
# {{{ Swaret
-alias swup='sudo swaret --update --upgrade' # Sync, Update & Upgrade
-alias swsy='sudo swaret --update' # Sync & Update
-alias swlu='sudo swaret --list -u' # List upgradeable
-alias swin='sudo swaret --install' # Install a specific package
-alias swrm='sudo swaret --remove' # Remove a specific package
-alias swss='sudo swaret --search' # Search for a package
-swsl() { sudo swaret --search $1 -i } # Search for a package localy
-swsi() { sudo swaret --show $1 -p } # Package info
-swqi() { sudo swaret --show $1 -i } # Package local info
-swls() { less "$(locate /var/log/packages/$1)" } # List files in a package
-swfi() { grep $1 /var/log/packages/* } # Which package file belongs to
-alias swui='sudo swaret --search aic -i' # List localy built packages
-alias swcl='sudo swaret --purge' # Fully clean the package cache
-alias swdl='sudo swaret --get' # Download a package without installing
-alias swlog='sudo swaret --changelog' # Package changelog
+alias swup="sudo swaret --update --upgrade" # Sync, Update & Upgrade
+alias swsy="sudo swaret --update" # Sync & Update
+alias swlu="sudo swaret --list -u" # List upgradeable
+alias swin="sudo swaret --install" # Install a specific package
+alias swrm="sudo swaret --remove" # Remove a specific package
+alias swss="sudo swaret --search" # Search for a package
+swsl() { sudo swaret --search "$1" -i } # Search for a package localy
+swsi() { sudo swaret --show "$1" -p } # Package info
+swqi() { sudo swaret --show "$1" -i } # Package local info
+swls() { less `locate /var/log/packages/"$1"` } # List files in a package
+swfi() { grep "$1" /var/log/packages/* } # Which package file belongs to
+alias swui="sudo swaret --search aic -i" # List localy built packages
+alias swcl="sudo swaret --purge" # Fully clean the package cache
+alias swdl="sudo swaret --get" # Download a package without installing
+alias swlog="sudo swaret --changelog" # Package changelog
# }}}
# }}}
# {{{ Completion
-compctl -k '(add delete draft edit list import preview publish update)' nb
-# }}}
-
-# {{{ Functions
-function web () { $BROWSER "http://yubnub.org/parser/parse?command=$*" }
-function pmem () { ps -o rss,comm -p $(pgrep $1) }
-function dsync () { rsync -lprt --progress --stats --delete "$1/" "$2/" }
-
-function snap () {
- [ $2 ] && tmout=$2 || tmout=5
- [ $3 ] && format=$3 || format=png
- stamp=`date +%d%m%y-%H%M`
- echo -n "Snapshot in "
- for (( i = $tmout; i >= 1; i-- )) do; echo -n "$i.. "; sleep 1; done
- import -window root -quality 100 ~/$1-$stamp.$format
- convert -resize "15%" ~/$1-$stamp.$format ~/$1-$stamp.th.$format
- echo "saved as: ~/$1-$stamp.$format"
-}
-
-function extract () {
- if [[ -f "$1" ]]; then
- case "$1" in
- *.tbz2 | *.tar.bz2) tar -xvjf "$1" ;;
- *.txz | *.tar.xz) tar -xvJf "$1" ;;
- *.tgz | *.tar.gz) tar -xvzf "$1" ;;
- *.tar | *.cbt) tar -xvf "$1" ;;
- *.zip | *.cbz) unzip "$1" ;;
- *.rar | *.cbr) unrar x "$1" ;;
- *.arj) unarj x "$1" ;;
- *.ace) unace x "$1" ;;
- *.bz2) bunzip2 "$1" ;;
- *.xz) unxz "$1" ;;
- *.gz) gunzip "$1" ;;
- *.7z) 7z x "$1" ;;
- *.Z) uncompress "$1" ;;
- *.gpg) gpg2 -d "$1" | tar -xvzf - ;;
- *) echo "Error: failed to extract '$1'" ;;
- esac
- else
- echo "Error: '$1' is not a valid file for extraction"
- fi
-}
+compctl -k "(add delete draft edit list import preview publish update)" nb
# }}}
# }}}
@@ -214,75 +176,115 @@ autoload colors zsh/terminfo
# New style completion system
autoload -U compinit; compinit
# * List of completers to use
-zstyle ':completion:*' completer _complete _match _approximate
+zstyle ":completion:*" completer _complete _match _approximate
# * Allow approximate
-zstyle ':completion:*:match:*' original only
-zstyle ':completion:*:approximate:*' max-errors 1 numeric
+zstyle ":completion:*:match:*" original only
+zstyle ":completion:*:approximate:*" max-errors 1 numeric
# * Selection prompt as menu
-zstyle ':completion:*' menu select=1
+zstyle ":completion:*" menu select=1
# * Menu selection for PID completion
-zstyle ':completion:*:*:kill:*' menu yes select
-zstyle ':completion:*:kill:*' force-list always
-zstyle ':completion:*:processes' command 'ps -au$USER'
-zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32'
+zstyle ":completion:*:*:kill:*" menu yes select
+zstyle ":completion:*:kill:*" force-list always
+zstyle ":completion:*:processes" command "ps -au$USER"
+zstyle ":completion:*:*:kill:*:processes" list-colors "=(#b) #([0-9]#)*=0=01;32"
# * Don't select parent dir on cd
-zstyle ':completion:*:cd:*' ignore-parents parent pwd
+zstyle ":completion:*:cd:*" ignore-parents parent pwd
# * Complete with colors
-zstyle ':completion:*' list-colors ''
+zstyle ":completion:*" list-colors ""
# }}}
-# {{{ Terminal and prompt settings
+# {{{ Functions
+function web () { "${BROWSER}" "http://yubnub.org/parser/parse?command=${*}" }
+function pmem () { ps -o rss,comm -p `pgrep "$1"` }
+function dsync () { rsync -lprt --progress --stats --delete "$1/" "$2/" }
+
+function snap () {
+ [ "$2" ] && tmout="$2" || tmout=5
+ [ "$3" ] && format="$3" || format=png
+ stamp=`date +%d%m%y-%H%M`
+ echo -n "Snapshot in "
+ for ((i=${tmout}; i >= 1; i--)) do; echo -n "${i}.. "; sleep 1; done
+ import -window root -quality 100 "${HOME}/$1-${stamp}.${format}"
+ convert -resize "15%" -quality 100 "${HOME}/$1-${stamp}.${format}" \
+ "${HOME}/$1-${stamp}.th.${format}"
+ echo "saved as: ${HOME}/$1-${stamp}.${format}"
+}
+
+function extract () {
+ if [[ -f "$1" ]]; then
+ case "$1" in
+ *.tbz2 | *.tar.bz2) tar -xvjf "$1" ;;
+ *.txz | *.tar.xz) tar -xvJf "$1" ;;
+ *.tgz | *.tar.gz) tar -xvzf "$1" ;;
+ *.tar | *.cbt) tar -xvf "$1" ;;
+ *.zip | *.cbz) unzip "$1" ;;
+ *.rar | *.cbr) unrar x "$1" ;;
+ *.arj) unarj x "$1" ;;
+ *.ace) unace x "$1" ;;
+ *.bz2) bunzip2 "$1" ;;
+ *.xz) unxz "$1" ;;
+ *.gz) gunzip "$1" ;;
+ *.7z) 7z x "$1" ;;
+ *.Z) uncompress "$1" ;;
+ *.gpg) gpg2 -d "$1" | tar -xvzf - ;;
+ *) echo 'Error: failed to extract "$1"' ;;
+ esac
+ else
+ echo 'Error: "$1" is not a valid file for extraction'
+ fi
+}
+
+# {{{ Terminal and prompt
function precmd {
# Terminal width = width - 1 (for lineup)
local TERMWIDTH
- (( TERMWIDTH = ${COLUMNS} - 1 ))
+ ((TERMWIDTH=${COLUMNS} - 1))
# Truncate long paths
PR_FILLBAR=""
PR_PWDLEN=""
- local promptsize=${#${(%):---(%n@%m:%l)---()--}}
- local pwdsize=${#${(%):-%~}}
- if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
- ((PR_PWDLEN=$TERMWIDTH - $promptsize))
+ local PROMPTSIZE="${#${(%):---(%n@%m:%l)---()--}}"
+ local PWDSIZE="${#${(%):-%~}}"
+ if [[ "${PROMPTSIZE} + ${PWDSIZE}" -gt ${TERMWIDTH} ]]; then
+ ((PR_PWDLEN=${TERMWIDTH} - ${PROMPTSIZE}))
else
- PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
+ PR_FILLBAR="\${(l.((${TERMWIDTH} - (${PROMPTSIZE} + ${PWDSIZE})))..${PR_HBAR}.)}"
fi
}
function preexec () {
# Screen window titles as currently running programs
- if [[ "$TERM" == "screen-256color" ]]; then
- local CMD=${1[(wr)^(*=*|sudo|-*)]}
+ if [[ "${TERM}" == "screen-256color" ]]; then
+ local CMD="${1[(wr)^(*=*|sudo|-*)]}"
echo -n "\ek$CMD\e\\"
fi
}
function setprompt () {
- if [[ "$terminfo[colors]" -ge 8 ]]; then
+ if [[ "${terminfo[colors]}" -ge 8 ]]; then
colors
fi
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
- eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
- eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
- (( count = $count + 1 ))
+ eval PR_"${color}"="%{${terminfo[bold]}$fg[${(L)color}]%}"
+ eval PR_LIGHT_"${color}"="%{$fg[${(L)color}]%}"
done
- PR_NO_COLOUR="%{$terminfo[sgr0]%}"
+ PR_NO_COLOUR="%{${terminfo[sgr0]}%}"
# Try to 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]:--}
+ 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]:--}"
# Terminal specific settings and titlebar text
- case $TERM in
+ case "${TERM}" in
rxvt*)
PR_TITLEBAR=$'%{\e]0;%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
;;
@@ -292,7 +294,7 @@ function setprompt () {
esac
# Terminal prompt settings
- case $TERM in
+ case "${TERM}" in
dumb) # Simple prompt for dumb terminals
unsetopt zle
PROMPT='%n@%m:%~%% '
@@ -342,3 +344,4 @@ $PR_GREEN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
# Prompt init
setprompt
# }}}
+# }}}