First commit

Commit 356f1f112a3f · Ahmad Khayyat · 2019-11-09 03:15 +0300

Changeset
356f1f112a3ff561a2c65f617b75417b6371800d

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/.hgignore b/.hgignore
new file mode 100644
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,3 @@
+zsh/syntax-highlighting
+zsh/history-substring-search
+zsh/completion/zsh-completions
diff --git a/.hgtags b/.hgtags
new file mode 100644
--- /dev/null
+++ b/.hgtags
@@ -0,0 +1,1 @@
+586d27b2e3c6cf57a37bc6926663b58c8a0ed37f debian-7
diff --git a/Xresources b/Xresources
new file mode 100644
--- /dev/null
+++ b/Xresources
@@ -0,0 +1,14 @@
+emacs*font: dejavu sans mono-12:hintstyle=hintfull
+XTerm*faceName: dejavu sans mono-12
+XTerm*altSendsEscape: true
+XTerm*metaSendsEscape: true
+XTerm.termName: xterm-256color
+XTerm*color8:      #555555
+XTerm.VT100.geometry: 100x30
+XTerm*on2Clicks: regex [^/@ \n]+
+XTerm*on3Clicks: regex [^ \n]+
+XTerm*on4Clicks: regex [^#$]+
+XTerm*on5Clicks: line
+
+XTerm*VT100.translations: #override Shift <Btn1Up>: select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\
+                                    Shift Ctrl <Key>V: insert-selection(CLIPBOARD)
diff --git a/emacs b/emacs
new file mode 100644
--- /dev/null
+++ b/emacs
@@ -0,0 +1,266 @@
+;;===================
+;;  Global Settings
+;;===================
+
+;; Minor modes
+(savehist-mode t)
+(show-paren-mode t)
+(column-number-mode t)
+(delete-selection-mode t)
+(if window-system (tool-bar-mode 0))
+
+;; Variables
+(setq inhibit-startup-message t)
+(setq initial-scratch-message "")
+(setq-default indicate-empty-lines t)
+(setq-default indent-tabs-mode nil)
+(setq-default show-trailing-whitespace t)
+(setq-default make-backup-files nil)
+(setq scroll-conservatively 1000)
+(setq mouse-wheel-scroll-amount (quote (1)))
+(setq require-final-newline 'visit-save)
+(setq-default fill-column 80)
+
+(set-variable 'sentence-end "\\. ")
+(put 'downcase-region 'disabled nil)
+
+;; InteractivelyDoThings
+(ido-mode t)
+(ido-everywhere t)
+(setq ido-enable-flex-matching t)
+
+;; Browse kill ring (M-y)
+(require 'browse-kill-ring)
+(browse-kill-ring-default-keybindings)
+(setq browse-kill-ring-highlight-current-entry t)
+(setq browse-kill-ring-highlight-inserted-item t)
+(setq browse-kill-ring-show-preview t)
+
+;; Unique buffer names
+(require 'uniquify)
+(setq uniquify-buffer-name-style 'forward)
+
+;; Better expand
+(global-set-key (kbd "M-/") 'hippie-expand)
+(add-to-list 'hippie-expand-try-functions-list 'ispell-complete-word t)
+
+;; Paths
+(setq abbrev-file-name "~/.emacs.d/abbrev")
+(setq desktop-path '("~/.emacs.d"))
+(setq desktop-base-file-name "desktop")
+
+;;==========================
+;;  Mode-Specific Settings
+;;==========================
+
+;; C code indentation style
+(setq c-default-style "linux"
+      c-basic-offset 4)
+
+;; Org-mode
+;(global-set-key "\C-cl" 'org-store-link)
+;(global-set-key "\C-ca" 'org-agenda)
+;(global-set-key "\C-cb" 'org-iswitchb)
+(setq org-agenda-files (list "~/notes/todo.org"))
+(setq org-enforce-todo-checkbox-dependencies t)
+(setq org-enforce-todo-dependencies t)
+(setq org-log-states-order-reversed nil)
+(setq org-log-into-drawer t)
+(setq org-log-done 'time)
+(setq org-log-done-with-time nil)
+(setq org-src-fontify-natively t)
+(setq org-src-tab-acts-natively t)
+(setq org-latex-listings t)
+
+; allow both single and double quotes in the border
+(require 'org)
+(setf (nth 2 org-emphasis-regexp-components) " \t\r\n,")
+(custom-set-variables `(org-emphasis-alist ',org-emphasis-alist))
+
+; define a new onlyenv environment with shortcut O
+(require 'ox-beamer)
+(add-to-list 'org-beamer-environments-extra
+             '("onlyenv" "O" "\\begin{onlyenv}%a" "\\end{onlyenv}"))
+
+(add-hook 'org-mode-hook
+          (lambda ()
+            (local-set-key "\M-\C-n" 'outline-next-visible-heading)
+            (local-set-key "\M-\C-p" 'outline-previous-visible-heading)
+            (local-set-key "\M-\C-f" 'outline-forward-same-level)
+            (local-set-key "\M-\C-b" 'outline-backward-same-level)
+            (local-set-key "\M-\C-u" 'outline-up-heading)
+            ;; table
+            (local-set-key "\M-\C-w" 'org-table-copy-region)
+            (local-set-key "\M-\C-y" 'org-table-paste-rectangle)
+            (local-set-key "\M-\C-l" 'org-table-sort-lines)
+            ;; display images
+            (local-set-key "\M-I" 'org-toggle-iimage-in-org)))
+
+;; All text-mode-based modes
+(add-hook 'text-mode-hook (lambda ()
+                            (turn-on-auto-fill)
+                            (text-mode-hook-identify)
+                            (flyspell-mode t)
+                            (abbrev-mode t)
+                            ))
+
+;; LaTeX (auctex)
+(add-hook 'LaTeX-mode-hook (lambda ()
+                             (turn-on-reftex)
+                             (TeX-fold-mode)
+                             (LaTeX-math-mode)
+                             (TeX-PDF-mode)
+                             ;; (TeX-source-correlate-mode)
+                             ))
+(setq TeX-view-program-list '(("Evince" "evince --page-label=%(outpage) %o")))
+(setq TeX-view-program-selection '((output-pdf "Evince")))
+;;(setq TeX-source-correlate-start-server t)
+
+;; Use cleveref
+(defun reftex-format-cref (label def-fmt)
+  (format "\\cref{%s}" label))
+(setq reftex-format-ref-function 'reftex-format-cref)
+
+;; Fill sentences in latex documents. Line per sentence.
+(defun auto-fill-by-sentences ()
+  (if (looking-back (sentence-end))
+      ;; Break at a sentence
+      (progn
+        (LaTeX-newline)
+        t)
+    ;; Fall back to the default
+    (do-auto-fill)))
+(add-hook 'LaTeX-mode-hook (lambda () (setq auto-fill-function 'auto-fill-by-sentences)))
+
+(defadvice LaTeX-fill-region-as-paragraph (around LaTeX-sentence-filling)
+  "Start each sentence on a new line."
+  (let ((from (ad-get-arg 0))
+        (to-marker (set-marker (make-marker) (ad-get-arg 1)))
+        tmp-end)
+    (while (< from (marker-position to-marker))
+      (forward-sentence)
+      ;; might have gone beyond to-marker --- use whichever is smaller:
+      (ad-set-arg 1 (setq tmp-end (min (point) (marker-position to-marker))))
+      ad-do-it
+      (ad-set-arg 0 (setq from (point)))
+      (unless (or
+               (bolp)
+               (looking-at "\\s *$"))
+        (LaTeX-newline)))
+    (set-marker to-marker nil)))
+(ad-activate 'LaTeX-fill-region-as-paragraph)
+
+;; VHDL-mode
+(setq vhdl-clock-edge-condition (quote function))
+(setq vhdl-standard (quote (93 nil)))
+
+;; Associate .md files with markdown-mode
+(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
+
+;; Haskell-mode
+(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
+
+;;=======================
+;;  Global Key Bindings
+;;=======================
+
+;; Alt-<arrow> moves between windows
+(windmove-default-keybindings 'meta)
+
+;; Use Ibuffer for Buffer List
+(global-set-key (kbd "C-x C-b") 'ibuffer)
+
+;; Use Scroll-Lock key to toggle scroll-lock-mode
+(global-set-key (quote [Scroll_Lock]) 'scroll-lock-mode)
+
+;; Single-line scrolling without moving the point
+(global-set-key [(control down)] (lambda () (interactive) (scroll-up   1)) )
+(global-set-key [(control up  )] (lambda () (interactive) (scroll-down 1)) )
+
+;;====================
+;;  Clipboard Tweaks
+;;====================
+
+;; Stops selection with a mouse being immediately injected to the kill ring
+(setq mouse-drag-copy-region nil)
+;; Stops killing/yanking interacting with primary X11 selection
+(setq x-select-enable-primary nil)
+;; Makes killing/yanking interact with clipboard X11 selection
+(setq x-select-enable-clipboard t)
+;; Active region sets primary X11 selection
+(setq select-active-regions t)
+;; Make mouse middle-click only paste from primary X11 selection, not
+;; clipboard and kill ring.
+(global-set-key [mouse-2] 'mouse-yank-primary)
+
+;;========================
+;;  Compatibility Tweaks
+;;========================
+
+;; Fix keys in screen
+(global-set-key [select] 'end-of-line-nomark)
+
+(mapc (lambda (map)
+        (define-key function-key-map
+          (read-kbd-macro (cadr map))
+          (read-kbd-macro (car map))))
+      '(("<S-up>"       "ESC [1;2A")
+        ("<S-down>"     "ESC [1;2B")
+        ("<S-right>"    "ESC [1;2C")
+        ("<S-left>"     "ESC [1;2D")
+
+        ("<M-up>"       "ESC [1;3A")
+        ("<M-down>"     "ESC [1;3B")
+        ("<M-right>"    "ESC [1;3C")
+        ("<M-left>"     "ESC [1;3D")
+
+        ("<M-S-up>"     "ESC [1;4A")
+        ("<M-S-down>"   "ESC [1;4B")
+        ("<M-S-right>"  "ESC [1;4C")
+        ("<M-S-left>"   "ESC [1;4D")
+
+        ("<C-up>"       "ESC [1;5A")
+        ("<C-down>"     "ESC [1;5B")
+        ("<C-right>"    "ESC [1;5C")
+        ("<C-left>"     "ESC [1;5D")
+
+        ("<C-S-up"      "ESC [1;6A")
+        ("<C-S-down"    "ESC [1;6B")
+        ("<C-S-right>"  "ESC [1;6C")
+        ("<C-S-left>"   "ESC [1;6D")
+
+        ("<C-home>"     "ESC [1;5H")
+        ("<C-end>"      "ESC [1;5F")
+
+        ("<S-home>"     "ESC [1;2H")
+        ("<S-end>"      "ESC [1;2F")
+
+        ("<C-S-home>"   "ESC [1;6H")
+        ("<C-S-end>"    "ESC [1;6F")
+        ))
+
+;;=====================
+;;  Third-Party Modes
+;;=====================
+
+;; Undo Tree
+;;   http://www.dr-qubit.org/emacs.php#undo-tree
+(add-to-list 'load-path (expand-file-name "~/.dotfiles/emacs.d/undo-tree"))
+(require 'undo-tree)
+(global-undo-tree-mode)
+
+;;========================
+;;  Third-Party Packages
+;;========================
+
+;; Package repositories
+(package-initialize)
+(add-to-list 'package-archives
+             '("marmalade" . "http://marmalade-repo.org/packages/"))
+
+(load-theme 'zenburn t)
+
+;; web-mode
+(setq standard-indent 2)
+(setq web-mode-enable-current-element-highlight t)
+(setq web-mode-enable-current-column-highlight t)
diff --git a/emacs.d/emacs.archive b/emacs.d/emacs.archive
new file mode 100644
--- /dev/null
+++ b/emacs.d/emacs.archive
@@ -0,0 +1,17 @@
+; .emacs snippets not used now
+; For reference in case they are needed in the future
+
+; Vala
+(autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t)
+(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
+(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
+(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
+(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))
+
+(tabbar-mode t)
+(global-set-key [(meta shift left)] 'tabbar-backward)
+(global-set-key [(meta shift right)] 'tabbar-forward)
+(global-set-key [(meta shift down)] 'tabbar-backward-group)
+(global-set-key [(meta shift up)] 'tabbar-forward-group)
+
+(desktop-save-mode t)
diff --git a/firefox-userChrome.css b/firefox-userChrome.css
new file mode 100644
--- /dev/null
+++ b/firefox-userChrome.css
@@ -0,0 +1,6 @@
+@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
+
+/* hide the native tabs in favor of the Tree Style Tabs extension */
+#TabsToolbar {
+    visibility: collapse;
+}
diff --git a/gpg.conf b/gpg.conf
new file mode 100644
--- /dev/null
+++ b/gpg.conf
@@ -0,0 +1,8 @@
+personal-cipher-preferences AES256
+personal-digest-preferences SHA512
+personal-compress-preferences BZIP2
+default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
+cert-digest-algo SHA512
+keyserver hkp://keys.gnupg.net
+#keyserver hkp://pgp.mit.edu
+use-agent
diff --git a/gtk-3.0_settings.ini b/gtk-3.0_settings.ini
new file mode 100644
--- /dev/null
+++ b/gtk-3.0_settings.ini
@@ -0,0 +1,3 @@
+[Settings]
+gtk-theme-name = Adwaita
+gtk-fallback-icon-theme = gnome
diff --git a/gtkrc-2.0 b/gtkrc-2.0
new file mode 100644
--- /dev/null
+++ b/gtkrc-2.0
@@ -0,0 +1,1 @@
+gtk-theme-name = "Adwaita"
diff --git a/hg/cwdiff b/hg/cwdiff
new file mode 100755
--- /dev/null
+++ b/hg/cwdiff
@@ -0,0 +1,258 @@
+#! /bin/bash
+
+#(C) 2009-2012 C. Junghans
+# [email protected]
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
+#version 0.1    04.08.10 -- initial version
+#version 0.1.1, 05.08.10 -- added -D and -o
+#version 0.1.2, 04.10.10 -- make -D work again and better help
+#version 0.1.3, 10.05.11 -- added --text to diff_opts to allow diff of binary files (issue #3)
+#version 0.1.4, 10.05.11 -- removed --text again and handle case of binary files
+#version 0.2.0, 15.04.12 -- clean up + bugfix thanks to Arne
+#version 0.2.1, 15.04.12 -- clean up + new bug report address
+#version 0.2.2, 20.04.12 -- fixed a bug if argument were dirs
+#version 0.2.3, 18.12.12 -- replace usage of mktemp with bash built-ins
+#version 0.2.4, 31.08.13 -- fixed deleted leading spaces
+#version 0.2.5, 06.09.13 -- do not expand escape sequences in diff
+#version 0.2.6, 18.09.13 -- allow 1st argument begin a file with --filter
+
+FAT_GREEN=""
+GREEN=""
+FAT_RED=""
+RED=""
+MAGENTA=""
+FAT_BLACK=""
+OFF=""
+NL="
+"
+
+usage="Usage: ${0##*/} [OPTIONS] FILE1 FILE2"
+quiet="no"
+diff="no"
+filter="no"
+diff_opts='--new-file --unified --show-c-function --recursive'
+ab="no"
+out="-"
+style="wdiff"
+a2ps=""
+a2ps_opts="--prologue=color"
+color="yes"
+
+color_filter() {
+  if [[ $a2ps ]]; then
+    #seems like a bug in the a2ps style file
+    sed -e "s/\[-/[wd-/g" -e "s/-\]/-wd]/g" -e "s/{+/{wd+/g" -e "s/+}/+wd}/g" $1
+  elif [[ $color = yes ]]; then
+    sed -e "s/\[-/$RED/g" -e "s/-\]/$OFF/g" -e "s/{+/$GREEN/g" -e "s/+}/$OFF/g" $1
+  else
+    cat $1
+  fi
+}
+
+die() {
+  [[ $* ]] && echo "$*"
+  exit 1
+}
+
+qecho() {
+  [[ $quiet = yes ]] || echo "$*"
+}
+
+show_help () {
+  cat << eof
+A colorized version of wdiff
+$usage
+
+OPTIONS:
+-f, --filter        Act as a wdiff color filter only and don't excute diff/wdiff
+                    internally, just colorize input (no ARGS = read from stdin)
+-d, --diff          Preprocess input with diff and before giving it to wdiff
+                    (very useful for dirs). Option can be used in combination
+                    with --filter option meaning input is a patch.
+-D, --diffonly      Process input with diff, but NOT with wdiff, so ${0##*/}
+                    basically acts like a colorized version of diff. Option
+                    can be used in combination with --filter option meaning
+                    input is a patch.
+    --diffopts XXX  Change opts of diff
+                    Default: '$diff_opts'
+    --ab            replace trunc of dirname by 'a' and 'b'
+    --no-color      Disable color
+                    (implies --a2psopts '--prologue=ul')
+-a, --a2ps          Pipe the output to a2ps, which will produce ps code
+                    (also work with --filter)
+    --a2psopts XXX  Change opts of a2ps
+                    Default: '$a2ps_opts'
+-o, --out FILE      Change output file
+                    Default: stdout
+    --              Stop parsing options
+-h, --help          Show this help
+-v, --version       Show version
+    --hg            Show last log message for hg (or cvs)
+
+Examples:  ${0##*/} -d dir1 dir2
+           ${0##*/} file1 file2
+           ${0##*/} --ab -D dir1 dir2
+	   ${0##*/} -a --ab -D dir1 dir2 > file.ps
+	   wdiff file1 file2 | ${0##*/} -f
+	   diff -u file1 file2 | ${0##*/} -D -f
+
+
+Report bugs and comments at https://code.google.com/p/cj-overlay/issues/list
+                         or [email protected]
+eof
+}
+
+shopt -s extglob
+while [[ ${1} = -?* ]]; do
+  if [[ ${1} = --??*=* ]]; then # case --xx=yy
+    set -- "${1%%=*}" "${1#*=}" "${@:2}" # --xx=yy to --xx yy
+  elif [[ ${1} = -[^-]?* ]]; then # case -xy split
+    if [[ ${1} = -[o]* ]]; then #short opts with arguments
+       set -- "${1:0:2}" "${1:2}" "${@:2}" # -xy to -x y
+    else #short opts without arguments
+       set -- "${1:0:2}" "-${1:2}" "${@:2}" # -xy to -x -y
+    fi
+  fi
+  case $1 in
+   --ab)
+    ab="yes"
+    shift;;
+   --no-color)
+    unset FAT_GREEN GREEN FAT_RED RED MAGENTA OFF FAT_BLACK
+    a2ps_opts="--prologue=ul"
+    color="no"
+    shift;;
+   -f | --filter)
+    filter="yes"
+    shift ;;
+   -d | --diff)
+    diff="yes"
+    shift ;;
+   -D | --diffonly)
+    diff="only"
+    shift ;;
+   -a | --a2ps)
+    a2ps="a2ps"
+    unset FAT_GREEN GREEN FAT_RED RED MAGENTA OFF FAT_BLACK
+    shift ;;
+  --a2psopts)
+    a2ps_opts="$2"
+    shift 2;;
+   -o | --out)
+    out="$2"
+    [[ ! $out ]] && die "Missing filename after --out option"
+    shift 2;;
+   --diffopts)
+    diff_opts="$2"
+    shift ;;
+   -q | --quiet)
+    quiet="yes"
+    shift ;;
+   -h | --help)
+    show_help
+    exit 0;;
+   --hg)
+    echo "${0##*/}: $(sed -ne 's/^#version.* -- \(.*$\)/\1/p' $0 | sed -n '$p')"
+    exit 0;;
+   -v | --version)
+    echo "${0##*/}, $(sed -ne 's/^#\(version.*\) -- .*$/\1/p' $0 | sed -n '$p') by C. Junghans"
+    exit 0;;
+   --)
+    shift
+    break;;
+  *)
+   die "Unknown option '$1'";;
+  esac
+done
+
+[[ $1 = - ]] && filter="yes" && shift
+if [[ $filter = no ]]; then
+  [[ ! $1 || ! $2 ]]  && die "Please specify two files/dirs or add --filter option"
+  #use -e as it could be file or dir
+  [[ -e $1 ]] || die "Could not read file/dir '$1'"
+  [[ -e $2 ]] || die "Could not read file/dir '$2'"
+  [[ $3 ]] && die "I don't know what to do with arguments '${@:3}'"
+else
+  [[ -n $1 && ! -f $1 ]] && die "Could not read file '$1'"
+  [[ $2 ]] && die "I don't know what to do with arguments '$*' together --filter option"
+fi
+
+if [[ $diff != no ]]; then
+  if [[ $filter = no ]]; then
+    exec 3< <(diff $diff_opts "$1" "$2")
+    #don't die here, because diff of binary files give exit code = 2
+  else
+    [[ $1 ]] && exec 3<$1 || exec 3<&0
+  fi
+  # don't do this if we have not files ;-)
+  if [[ $ab = yes && $1 && $2 ]]; then
+    #find the longest equal part in $1 and $2 from the end
+    for ((i=1;i<=(${#1}<${#2}?${#1}:${#2});i++)); do
+      [[ ${1:0-$i} != ${2:0-$i} ]] && break
+    done
+    ((i--))
+    a="${1:0:${#1}-$i}"
+    b="${2:0:${#2}-$i}"
+  else
+    a=a; b=b
+  fi
+  # -r to not expand escape sequences in diff
+  while read -r -u 3; do
+    #small trick, because "read -u 3 i" would split the line and
+    #leading space would be lost.
+    i="${REPLY}"
+    if [[ $i = "Files "*" and "*" differ" ]]; then # binary case
+      i="${i/$a/a}"
+      i="${i/$b/b}"
+      echo "$i"
+    elif [[ $i = diff* ]]; then # diff header line
+      i="${i/ $diff_opts}"
+      i="${i/$a/a}"
+      echo "$FAT_BLACK${i/$b/b}$OFF"
+    elif [[ $i = ---* ]]; then
+      echo "${FAT_RED}${i/$a/a}${OFF}"
+    elif [[ $i = +++* ]]; then
+      echo "${FAT_GREEN}${i/$b/b}${OFF}"
+    elif [[ $i = @@* ]]; then
+      echo "${MAGENTA}${i}${OFF}"
+    elif [[ $i = -* ]]; then
+      [[ $diff = only ]] && echo "${RED}${i}${OFF}" || t1+="${i#-}$NL"
+    elif [[ $i = +* ]]; then
+      [[ $diff = only ]] && echo "${GREEN}${i}${OFF}" || t2+="${i#+}$NL"
+    else
+      # only true for diff != only
+      # cut the last newline do avoid an empty line at the end (echo append newline)
+      # echo -n would also work, but wdiff has strange behaviour if the 2nd file is
+      # empty, it will not append newline, which make the output look strange
+      [[ $t1 || $t2 ]] && { wdiff <(echo "${t1%$NL}") <(echo "${t2%$NL}") | color_filter; }
+      t1=
+      t2=
+      [[ $diff = only ]] && echo "${i}" || echo "${i## }"
+    fi
+  done
+  # thanks to Arne Babenhauserheide for pointing out this case is missing
+  # if there was + or - lines at the end, which has not been printed yet
+  [[ $t1 || $t2 ]] && { wdiff <(echo "${t1%$NL}") <(echo "${t2%$NL}") | color_filter; }
+elif [[ $filter = yes ]]; then
+  color_filter $1
+else
+  wdiff "$1" "$2" | color_filter
+fi | if [[ $a2ps ]]; then
+  a2ps $a2ps_opts "--pretty-print=$style" -o "$out"
+else
+  [[ $out = - ]] && cat || cat > "$out"
+fi
diff --git a/hgrc b/hgrc
new file mode 100644
--- /dev/null
+++ b/hgrc
@@ -0,0 +1,54 @@
+[ui]
+username = Ahmad Khayyat <[email protected]>
+interface = curses
+
+[extensions]
+graphlog =
+fetch =
+record =
+color =
+hgk =
+pager =
+mq =
+rebase =
+progress =
+prompt = ~/.dotfiles/hg/hg-prompt/prompt.py
+git =
+convert =
+purge =
+remotenames =
+churn =
+histedit =
+extdiff =
+
+[diff]
+git = True
+
+[merge-tools]
+emacs.args = -q --eval "(emerge-files-with-ancestor nil \"$local\" \"$other\" \"$base\" \"$output\" nil 'kill-emacs)"
+emacs.priority = 10
+kdiff3.args = $base $local $other -o $output
+kdiff3.gui = True
+kdiff3.priority = 20
+
+[pager]
+pager = LESS='FSRX' less
+quiet = True
+attend = annotate, cat, diff, export, glog, log, qdiff, help, incoming, outgoing, plog
+
+[mq]
+secret = True
+
+[extdiff]
+# Need to install wdiff and link `/usr/local/bin/cwdiff` to `hg/cwdiff`
+cmd.wdiff = ~/.dotfiles/hg/cwdiff
+opts.wdiff = --diff --ab
+
+[alias]
+upstream = !$HG summary --config paths.default=$(hg showconfig paths.upstream) --remote
+plog = glog --template '\033[0;32m{rev}\033[0m:{phase} \033[0;35m{author|person}\033[0m {desc|firstline|strip} \033[1;30m({date|age})\033[0m \033[0;33m{branches}\033[0m \033[38;5;166m{bookmarks}\033[0m \033[0;32m{tags}\033[0m \033[1;34m{remotenames}\033[0m\n\n'
+pout = out -G --template '\033[0;32m{rev}\033[0m:{phase} \033[0;35m{author|person}\033[0m {desc|firstline|strip} \033[1;30m({date|age})\033[0m \033[0;33m{branches}\033[0m \033[38;5;166m{bookmarks}\033[0m \033[0;32m{tags}\033[0m \033[1;34m{remotenames}\033[0m\n\n'
+pin = in -G --template '\033[0;32m{rev}\033[0m:{phase} \033[0;35m{author|person}\033[0m {desc|firstline|strip} \033[1;30m({date|age})\033[0m \033[0;33m{branches}\033[0m \033[38;5;166m{bookmarks}\033[0m \033[0;32m{tags}\033[0m \033[1;34m{remotenames}\033[0m\n\n'
+
+[subrepos]
+git:allowed = True
diff --git a/install.sh b/install.sh
new file mode 100755
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,122 @@
+#! /bin/sh
+
+# define color codes
+WHITE="\\033[1;37m"
+BLUE="\\033[1;34m"
+GREEN="\\033[0;32m"
+RED="\\033[0;31m"
+PURPLE="\\033[0;35m"
+YELLOW="\\033[0;33m"
+RST="\\033[m"
+
+# create $2 as a symlink to $1 and verify that it actually is
+link_and_check() {
+    echo -n "${WHITE}${2#$HOME/}:${RST} "
+    if [ -L $2 -a "$(readlink -f $2)" = "$1" ]
+    then
+        echo "${YELLOW}already installed!${RST}"
+    else
+        if [ ! -d $(dirname $2) ]
+        then
+            mkdir -p $(dirname $2)
+        fi
+        if [ -d $2 ]
+        then
+            echo "${PURPLE}NOT installed${RST} - directory exists"
+            return 1
+        else
+            ln -sf $1 $2
+            if [ -L $2 -a "$(readlink -f $2)" = "$1" ]
+            then
+                echo "${GREEN}installed successfully!${RST}"
+            else
+                echo "${PURPLE}NOT installed${RST} - something went wrong!"
+                return 1
+            fi
+        fi
+    fi
+}
+
+cd $(dirname $0)
+
+# make sure ~/.dotfiles exists
+# some dotfiles rely on that path
+if [ "$PWD" != "$HOME/.dotfiles" ]
+then
+    link_and_check $PWD $HOME/.dotfiles
+    if [ $? -ne 0 ]
+    then
+        echo "~/.dotfiles is required to be valid. Cannot continue"
+        exit 1
+    fi
+fi
+
+# dot files in the home directory
+homefiles="screenrc emacs hgrc muttrc stalonetrayrc Xresources gtkrc-2.0"
+for i in $homefiles
+do
+    link_and_check $PWD/$i $HOME/.$i
+done
+
+# desktop themes: openbox, gnome, gtk, icons, etc.
+themes="ak"
+for i in $themes
+do
+    link_and_check $PWD/themes/$i $HOME/.themes/$i
+done
+
+# special cases
+link_and_check $PWD/zsh/zshrc             $HOME/.zshrc
+link_and_check $PWD/openbox               $HOME/.config/openbox
+link_and_check $PWD/gtk-3.0_settings.ini  $HOME/.config/gtk-3.0/settings.ini
+link_and_check $PWD/gpg.conf              $HOME/.gnupg/gpg.conf
+
+thunderbird_default_profile=$(ls -d $HOME/.thunderbird/*.default)
+if [ -d $thunderbird_default_profile ]
+then
+    mkdir -p $thunderbird_default_profile/chrome
+    link_and_check $PWD/thunderbird-userChrome.css $thunderbird_default_profile/chrome/userChrome.css
+fi
+
+firefox_default_profile=$(ls -d $HOME/.mozilla/firefox/*.default)
+if [ -d $firefox_default_profile ]
+then
+    mkdir -p $firefox_default_profile/chrome
+    link_and_check $PWD/firefox-userChrome.css $firefox_default_profile/chrome/userChrome.css
+fi
+
+# clone or update external repositories
+update_hg_repo() {
+    repo=$1
+    dir=$2
+    if [ "$3" ]; then rev="-r $3"; else rev=""; fi
+
+    if [ ! -d "$dir"/.hg ]
+    then
+        hg clone $rev $repo $dir
+    else
+        hg pull $rev
+        hg update $rev
+    fi
+}
+
+update_git_repo() {
+    repo=$1
+    dir=$2
+    if [ "$3" ]; then branch="-b $3"; ref=$3; else branch=""; ref=""; fi
+
+    if [ ! -d "$dir"/.git ]
+    then
+        git clone $branch $repo $dir
+    else
+        git pull --ff-only $repo $ref
+    fi
+}
+
+update_hg_repo  https://bitbucket.org/sjl/hg-prompt                           hg/hg-prompt                   dc481ce24b60
+update_git_repo https://github.com/zsh-users/zsh-history-substring-search.git zsh/history-substring-search
+update_git_repo https://github.com/zsh-users/zsh-syntax-highlighting.git      zsh/syntax-highlighting
+update_git_repo https://github.com/zsh-users/zsh-completions.git              zsh/completion/zsh-completions
+
+
+cd $OLDPWD
diff --git a/muttrc b/muttrc
new file mode 100644
--- /dev/null
+++ b/muttrc
@@ -0,0 +1,1 @@
+set folder = /dev/null
diff --git a/openbox/autostart b/openbox/autostart
new file mode 100644
--- /dev/null
+++ b/openbox/autostart
@@ -0,0 +1,83 @@
+# Add Arabic keyboard layout
+setxkbmap -option grp:shift_caps_toggle "us,ara(qwerty_digits)"
+
+# Fix rhe right Alt key
+xmodmap -e "keycode 108 = Alt_R"
+
+# Start repeating sooner after a key has been kept pressed
+xset r rate 300 30
+
+# Keep the screen on
+xset dpms 0 0 0
+xset s off
+
+# Disable slow keys
+xkbset -a
+
+# Set desktop background
+nitrogen --restore
+
+# System tray
+stalonetray --kludges force_icons_size &
+
+# Tray applications
+cameramonitor &
+parcellite -n &
+minbar &
+volti &
+skype &
+bluetooth-applet &
+#blueman-applet &
+
+# Desktop applications
+gkrellm &
+xterm &
+
+# Battery status
+
+[ ! -x /usr/bin/acpi ] && exit
+
+if [ "$(acpi 2>&1)" = "No support for device type: power_supply" ]
+then
+    exit
+fi
+
+#### Get screen resolution of the main screen
+xy=$(xrandr --current | awk '
+BEGIN {
+    found_main_screen = 0
+}
+/\+0\+0/ {
+    found_main_screen = 1
+}
+/\*/ {
+    split($1, xy, "x")
+    x = xy[1]
+    y = xy[2]
+    if (found_main_screen)
+        exit
+}
+END {
+    print x, y
+}')
+set $xy; x=$1; y=$2
+
+#### Display battery status
+w=64; h=14
+(
+    sleep 2 &&
+    while true
+    do
+        acpi | awk '
+BEGIN {
+  FS="[ :]"
+}
+{
+  if ($4 == "Discharging,")
+    print "- " $6 ":" $7
+  else if ($4 == "Charging,")
+    print "+ " $6 ":" $7
+  else print "Full"
+}'
+        sleep 30
+    done | dzen2 -x $((x-w)) -y $((y-h)) -w $w -fn '-*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*' -bg "#474747" -fg "#b1c8d6" -e 'onstart=lower') &
diff --git a/openbox/rc.xml b/openbox/rc.xml
new file mode 100644
--- /dev/null
+++ b/openbox/rc.xml
@@ -0,0 +1,1111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<openbox_config xmlns="http://openbox.org/3.4/rc">
+  <resistance>
+    <strength>10</strength>
+    <screen_edge_strength>20</screen_edge_strength>
+  </resistance>
+  <focus>
+    <focusNew>yes</focusNew>
+    <!-- always try to focus new windows when they appear. other rules do
+       apply -->
+    <followMouse>no</followMouse>
+    <!-- move focus to a window when you move the mouse into it -->
+    <focusLast>yes</focusLast>
+    <!-- focus the last used window when changing desktops, instead of the one
+       under the mouse pointer. when followMouse is enabled -->
+    <underMouse>no</underMouse>
+    <!-- move focus under the mouse, even when the mouse is not moving -->
+    <focusDelay>200</focusDelay>
+    <!-- when followMouse is enabled, the mouse must be inside the window for
+       this many milliseconds (1000 = 1 sec) before moving focus to it -->
+    <raiseOnFocus>no</raiseOnFocus>
+    <!-- when followMouse is enabled, and a window is given focus by moving the
+       mouse into it, also raise the window -->
+  </focus>
+  <placement>
+    <policy>Smart</policy>
+    <!-- 'Smart' or 'UnderMouse' -->
+    <center>yes</center>
+    <!-- whether to place windows in the center of the free area found or
+       the top left corner -->
+    <monitor>Active</monitor>
+    <!-- with Smart placement on a multi-monitor system, try to place new windows
+       on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
+       the active window is -->
+    <primaryMonitor/>
+  </placement>
+  <theme>
+    <name>ak</name>
+    <titleLayout>NLIMC</titleLayout>
+    <!--
+      available characters are NDSLIMC, each can occur at most once.
+      N: window icon
+      L: window label (AKA title).
+      I: iconify
+      M: maximize
+      C: close
+      S: shade (roll up/down)
+      D: omnipresent (on all desktops).
+  -->
+    <keepBorder>yes</keepBorder>
+    <animateIconify>yes</animateIconify>
+    <font place="ActiveWindow">
+      <name>sans</name>
+      <size>8</size>
+      <!-- font size in points -->
+      <weight>normal</weight>
+      <!-- 'bold' or 'normal' -->
+      <slant>normal</slant>
+      <!-- 'italic' or 'normal' -->
+    </font>
+    <font place="InactiveWindow">
+      <name>sans</name>
+      <size>8</size>
+      <!-- font size in points -->
+      <weight>normal</weight>
+      <!-- 'bold' or 'normal' -->
+      <slant>normal</slant>
+      <!-- 'italic' or 'normal' -->
+    </font>
+    <font place="MenuHeader">
+      <name>sans</name>
+      <size>9</size>
+      <!-- font size in points -->
+      <weight>normal</weight>
+      <!-- 'bold' or 'normal' -->
+      <slant>normal</slant>
+      <!-- 'italic' or 'normal' -->
+    </font>
+    <font place="MenuItem">
+      <name>sans</name>
+      <size>9</size>
+      <!-- font size in points -->
+      <weight>normal</weight>
+      <!-- 'bold' or 'normal' -->
+      <slant>normal</slant>
+      <!-- 'italic' or 'normal' -->
+    </font>
+    <font place="ActiveOnScreenDisplay">
+      <name/>
+    </font>
+    <font place="InactiveOnScreenDisplay">
+      <name>Sans</name>
+      <size>8</size>
+      <weight/>
+      <slant/>
+    </font>
+  </theme>
+  <desktops>
+    <!-- this stuff is only used at startup, pagers allow you to change them
+       during a session
+
+       these are default values to use when other ones are not already set
+       by other applications, or saved in your session
+
+       use obconf if you want to change these without having to log out
+       and back in -->
+    <number>10</number>
+    <firstdesk>1</firstdesk>
+    <names>
+      <!-- set names up here if you want to, like this: -->
+      <name>1 Terminals</name>
+      <name>2 Web</name>
+      <name>3 Misc</name>
+      <name>4 Emacs</name>
+      <name>5 Files</name>
+      <name>6 Chat</name>
+      <name>7 Misc</name>
+      <name>8 Monitor</name>
+      <name>9 Me</name>
+      <name>10 VNC</name>
+    </names>
+    <popupTime>875</popupTime>
+    <!-- The number of milliseconds to show the popup for when switching
+       desktops.  Set this to 0 to disable the popup. -->
+  </desktops>
+  <resize>
+    <drawContents>yes</drawContents>
+    <popupShow>Nonpixel</popupShow>
+    <!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) -->
+    <popupPosition>Center</popupPosition>
+    <!-- 'Center', 'Top', or 'Fixed' -->
+    <popupFixedPosition>
+      <!-- these are used if popupPosition is set to 'Fixed' -->
+      <x>10</x>
+      <!-- positive number for distance from left edge, negative number for
+         distance from right edge, or 'Center' -->
+      <y>10</y>
+      <!-- positive number for distance from top edge, negative number for
+         distance from bottom edge, or 'Center' -->
+    </popupFixedPosition>
+  </resize>
+  <!-- You can reserve a portion of your screen where windows will not cover when
+     they are maximized, or when they are initially placed.
+     Many programs reserve space automatically, but you can use this in other
+     cases. -->
+  <margins>
+    <top>0</top>
+    <bottom>0</bottom>
+    <left>0</left>
+    <right>0</right>
+  </margins>
+  <dock>
+    <position>TopRight</position>
+    <!-- (Top|Bottom)(Left|Right|)|Top|Bottom|Left|Right|Floating -->
+    <floatingX>0</floatingX>
+    <floatingY>0</floatingY>
+    <noStrut>no</noStrut>
+    <stacking>Above</stacking>
+    <!-- 'Above', 'Normal', or 'Below' -->
+    <direction>Vertical</direction>
+    <!-- 'Vertical' or 'Horizontal' -->
+    <autoHide>no</autoHide>
+    <hideDelay>300</hideDelay>
+    <!-- in milliseconds (1000 = 1 second) -->
+    <showDelay>300</showDelay>
+    <!-- in milliseconds (1000 = 1 second) -->
+    <moveButton>Middle</moveButton>
+    <!-- 'Left', 'Middle', 'Right' -->
+  </dock>
+  <keyboard>
+    <chainQuitKey>C-g</chainQuitKey>
+    <!-- Keybindings for desktop switching -->
+    <keybind key="W-1">
+      <action name="Desktop">
+        <desktop>1</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-2">
+      <action name="Desktop">
+        <desktop>2</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-3">
+      <action name="Desktop">
+        <desktop>3</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-4">
+      <action name="Desktop">
+        <desktop>4</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-5">
+      <action name="Desktop">
+        <desktop>5</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-6">
+      <action name="Desktop">
+        <desktop>6</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-7">
+      <action name="Desktop">
+        <desktop>7</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-8">
+      <action name="Desktop">
+        <desktop>8</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-9">
+      <action name="Desktop">
+        <desktop>9</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-0">
+      <action name="Desktop">
+        <desktop>10</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-Next">
+      <action name="DesktopNext"/>
+    </keybind>
+    <keybind key="W-Prior">
+      <action name="DesktopPrevious"/>
+    </keybind>
+    <keybind key="W-S-1">
+      <action name="SendToDesktop">
+        <desktop>1</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-2">
+      <action name="SendToDesktop">
+        <desktop>2</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-3">
+      <action name="SendToDesktop">
+        <desktop>3</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-4">
+      <action name="SendToDesktop">
+        <desktop>4</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-5">
+      <action name="SendToDesktop">
+        <desktop>5</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-6">
+      <action name="SendToDesktop">
+        <desktop>6</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-7">
+      <action name="SendToDesktop">
+        <desktop>7</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-8">
+      <action name="SendToDesktop">
+        <desktop>8</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-9">
+      <action name="SendToDesktop">
+        <desktop>9</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-0">
+      <action name="SendToDesktop">
+        <desktop>10</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-S-Next">
+      <action name="SendToDesktopNext"/>
+    </keybind>
+    <keybind key="W-S-Prior">
+      <action name="SendToDesktopPrevious"/>
+    </keybind>
+    <keybind key="W-d">
+      <action name="ToggleShowDesktop"/>
+    </keybind>
+    <!-- Keybindings for windows -->
+    <keybind key="W-F4">
+      <action name="Close"/>
+    </keybind>
+    <keybind key="W-Escape">
+      <action name="Lower"/>
+      <action name="FocusToBottom"/>
+      <action name="Unfocus"/>
+    </keybind>
+    <keybind key="W-C-space">
+      <action name="ShowMenu">
+        <menu>client-menu</menu>
+      </action>
+    </keybind>
+    <keybind key="W-space">
+      <action name="ShowMenu">
+        <menu>client-list-combined-menu</menu>
+      </action>
+    </keybind>
+    <keybind key="W-M-space">
+      <action name="ShowMenu">
+        <menu>client-list-menu</menu>
+      </action>
+    </keybind>
+    <keybind key="Print">
+      <action name="Execute">
+        <!-- <execute>scrot</execute> -->
+        <execute>gnome-screenshot</execute>
+      </action>
+    </keybind>
+    <keybind key="W-Print">
+      <action name="Execute">
+        <!-- <execute>scrot -u</execute> -->
+        <execute>gnome-screenshot -w</execute>
+      </action>
+    </keybind>
+    <keybind key="W-f">
+      <action name="ToggleMaximizeFull"/>
+    </keybind>
+    <keybind key="W-A-Up">
+      <action name="ToggleMaximizeVert"/>
+    </keybind>
+    <keybind key="W-A-Right">
+      <action name="ToggleMaximizeHorz"/>
+    </keybind>
+    <keybind key="W-C-f">
+      <action name="ToggleFullScreen"/>
+    </keybind>
+    <keybind key="W-c">
+      <action name="MoveResizeTo">
+        <x>center</x>
+        <y>center</y>
+      </action>
+    </keybind>
+    <keybind key="W-Up">
+      <action name="MoveRelative">
+        <y>-5</y>
+      </action>
+    </keybind>
+    <keybind key="W-Down">
+      <action name="MoveRelative">
+        <y>5</y>
+      </action>
+    </keybind>
+    <keybind key="W-Left">
+      <action name="MoveRelative">
+        <x>-5</x>
+      </action>
+    </keybind>
+    <keybind key="W-Right">
+      <action name="MoveRelative">
+        <x>5</x>
+      </action>
+    </keybind>
+    <keybind key="W-C-Right">
+      <action name="ResizeRelative">
+        <right>5</right>
+      </action>
+    </keybind>
+    <keybind key="W-C-Left">
+      <action name="ResizeRelative">
+        <right>-5</right>
+      </action>
+    </keybind>
+    <keybind key="W-C-Up">
+      <action name="ResizeRelative">
+        <bottom>-5</bottom>
+      </action>
+    </keybind>
+    <keybind key="W-C-Down">
+      <action name="ResizeRelative">
+        <bottom>5</bottom>
+      </action>
+    </keybind>
+    <keybind key="W-S-Left">
+      <action name="MoveToEdgeWest"/>
+    </keybind>
+    <keybind key="W-S-Right">
+      <action name="MoveToEdgeEast"/>
+    </keybind>
+    <keybind key="W-S-Up">
+      <action name="MoveToEdgeNorth"/>
+    </keybind>
+    <keybind key="W-S-Down">
+      <action name="MoveToEdgeSouth"/>
+    </keybind>
+    <keybind key="W-C-S-Left">
+      <action name="GrowToEdgeWest"/>
+    </keybind>
+    <keybind key="W-C-S-Right">
+      <action name="GrowToEdgeEast"/>
+    </keybind>
+    <keybind key="W-C-S-Up">
+      <action name="GrowToEdgeNorth"/>
+    </keybind>
+    <keybind key="W-C-S-Down">
+      <action name="GrowToEdgeSouth"/>
+    </keybind>
+    <!-- Keybindings for window switching -->
+    <keybind key="W-Tab">
+      <action name="NextWindow"/>
+    </keybind>
+    <keybind key="W-S-Tab">
+      <action name="PreviousWindow"/>
+    </keybind>
+    <keybind key="W-C-Tab">
+      <action name="NextWindow">
+        <panels>yes</panels>
+        <desktop>yes</desktop>
+      </action>
+    </keybind>
+    <keybind key="W-b">
+      <action name="ToggleDecorations"/>
+    </keybind>
+    <keybind key="W-q">
+      <action name="Reconfigure"/>
+    </keybind>
+    <keybind key="W-S-q">
+      <action name="Exit"/>
+    </keybind>
+    <!-- Keybindings for running applications -->
+    <keybind key="W-e">
+      <action name="Execute">
+        <startupnotify>
+          <enabled>true</enabled>
+          <name>File Manager</name>
+        </startupnotify>
+        <command>thunar</command>
+      </action>
+    </keybind>
+    <keybind key="W-w">
+      <action name="Execute">
+        <startupnotify>
+          <enabled>true</enabled>
+          <name>Firefox</name>
+        </startupnotify>
+        <command>firefox -P default -new-instance</command>
+      </action>
+    </keybind>
+    <keybind key="W-S-w">
+      <action name="Execute">
+        <startupnotify>
+          <enabled>true</enabled>
+          <name>Chromium</name>
+        </startupnotify>
+        <command>chromium --purge-memory-button --memory-model=low</command>
+      </action>
+    </keybind>
+    <keybind key="W-C-w">
+      <keybind key="1">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 1 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="2">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 2 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="3">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 3 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="4">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 4 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="5">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 5 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="6">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 6 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="0">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P 0 -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="r">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P r -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="a">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P a -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="p">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P p -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="n">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P n -new-instance</command>
+        </action>
+      </keybind>
+      <keybind key="k">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Firefox (alt profile)</name>
+          </startupnotify>
+          <command>firefox -P k -new-instance</command>
+        </action>
+      </keybind>
+    </keybind>
+    <keybind key="W-C-S-w">
+      <keybind key="1">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Chromium (alt profile)</name>
+          </startupnotify>
+          <command>chromium --purge-memory-button --memory-model=low --user-data-dir=.config/chromium/1</command>
+        </action>
+      </keybind>
+      <keybind key="2">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Chromium (alt profile)</name>
+          </startupnotify>
+          <command>chromium --purge-memory-button --memory-model=low --user-data-dir=.config/chromium/2</command>
+        </action>
+      </keybind>
+      <keybind key="3">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Chromium (alt profile)</name>
+          </startupnotify>
+          <command>chromium --purge-memory-button --memory-model=low --user-data-dir=.config/chromium/3</command>
+        </action>
+      </keybind>
+      <keybind key="4">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Chromium (alt profile)</name>
+          </startupnotify>
+          <command>chromium --purge-memory-button --memory-model=low --user-data-dir=.config/chromium/4</command>
+        </action>
+      </keybind>
+      <keybind key="5">
+        <action name="Execute">
+          <startupnotify>
+            <enabled>true</enabled>
+            <name>Chromium (alt profile)</name>
+          </startupnotify>
+          <command>chromium --purge-memory-button --memory-model=low --user-data-dir=.config/chromium/5</command>
+        </action>
+      </keybind>
+    </keybind>
+    <keybind key="W-s">
+      <action name="Execute">
+        <command>sh -c 'wmctrl -a $(zenity --entry --title "Switch Window" --text "Window Name")'</command>
+      </action>
+    </keybind>
+    <keybind key="W-S-s">
+      <action name="Execute">
+        <command>sh -c 'wmctrl -x -a $(zenity --entry --title "Switch Window" --text "Window Class")'</command>
+      </action>
+    </keybind>
+    <keybind key="W-x">
+      <action name="Execute">
+        <command>xterm</command>
+      </action>
+    </keybind>
+    <keybind key="W-v">
+      <action name="Execute">
+        <command>vncviewer</command>
+      </action>
+    </keybind>
+    <keybind key="W-S-v">
+      <action name="Execute">
+        <command>rdesktop</command>
+      </action>
+    </keybind>
+    <keybind key="W-C-u">
+      <action name="Execute">
+        <startupnotify>
+          <enabled>true</enabled>
+        </startupnotify>
+        <command>unison-gtk</command>
+      </action>
+    </keybind>
+    <keybind key="W-p">
+      <action name="Execute">
+        <command>keepassx</command>
+      </action>
+    </keybind>
+    <keybind key="W-m">
+      <action name="Execute">
+        <command>thunderbird</command>
+      </action>
+    </keybind>
+    <keybind key="W-z">
+      <action name="Execute">
+        <command>amixer -c 0 set Master 2dB- unmute</command>
+      </action>
+    </keybind>
+    <keybind key="XF86AudioLowerVolume">
+      <action name="Execute">
+        <command>amixer -c 0 set Master 2dB- unmute</command>
+      </action>
+    </keybind>
+    <keybind key="W-a">
+      <action name="Execute">
+        <command>amixer -c 0 set Master 2dB+ unmute</command>
+      </action>
+    </keybind>
+    <keybind key="XF86AudioRaiseVolume">
+      <action name="Execute">
+        <command>amixer -c 0 set Master 2dB+ unmute</command>
+      </action>
+    </keybind>
+    <keybind key="W-less">
+      <action name="Execute">
+        <command>amixer set Master toggle</command>
+      </action>
+    </keybind>
+    <keybind key="XF86AudioMute">
+      <action name="Execute">
+        <command>amixer set Master toggle</command>
+      </action>
+    </keybind>
+    <keybind key="XF86TouchpadToggle">
+      <action name="Execute">
+        <command>sh -c 'synclient TouchpadOff=`synclient -l | grep -ce TouchpadOff.*0`'</command>
+      </action>
+    </keybind>
+    <keybind key="XF86MonBrightnessUp">
+      <action name="Execute">
+        <command>xbacklight -inc 10%</command>
+      </action>
+    </keybind>
+    <keybind key="XF86MonBrightnessDown">
+      <action name="Execute">
+        <command>xbacklight -dec 10%</command>
+      </action>
+    </keybind>
+    <keybind key="C-XF86MonBrightnessUp">
+      <action name="Execute">
+        <command>xbacklight -inc 2%</command>
+      </action>
+    </keybind>
+    <keybind key="C-XF86MonBrightnessDown">
+      <action name="Execute">
+        <command>xbacklight -dec 2%</command>
+      </action>
+    </keybind>
+    <keybind key="W-F2">
+      <action name="Execute">
+        <startupnotify>
+          <enabled>true</enabled>
+          <name>Run Dialog</name>
+        </startupnotify>
+        <command>gmrun</command>
+      </action>
+    </keybind>
+    <keybind key="W-r">
+      <action name="Execute">
+        <startupnotify>
+          <enabled>true</enabled>
+          <name>Run Dialog</name>
+        </startupnotify>
+        <command>gmrun</command>
+      </action>
+    </keybind>
+    <keybind key="W-C-t">
+      <action name="Execute">
+        <command>transset -p 0.1 --inc</command>
+      </action>
+    </keybind>
+    <keybind key="W-S-t">
+      <action name="Execute">
+        <command>transset -p 0.1 --dec</command>
+      </action>
+    </keybind>
+    <keybind key="W-l">
+      <action name="Execute">
+        <command>sh -c "sleep 1; xset dpms force off"</command>
+      </action>
+    </keybind>
+    <keybind key="W-C-l">
+      <action name="Execute">
+        <command>i3lock -c000000 -d</command>
+      </action>
+    </keybind>
+    <keybind key="W-C-S-l">
+      <action name="Execute">
+        <command>sh -c "gnome-screensaver-command -l; xset dpms force off"</command>
+      </action>
+    </keybind>
+  </keyboard>
+  <mouse>
+    <dragThreshold>8</dragThreshold>
+    <!-- number of pixels the mouse must move before a drag begins -->
+    <doubleClickTime>200</doubleClickTime>
+    <!-- in milliseconds (1000 = 1 second) -->
+    <screenEdgeWarpTime>400</screenEdgeWarpTime>
+    <!-- Time before changing desktops when the pointer touches the edge of the
+       screen while moving a window, in milliseconds (1000 = 1 second).
+       Set this to 0 to disable warping -->
+    <context name="Frame">
+      <mousebind button="W-Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="W-Left" action="Click">
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="W-Left" action="Drag">
+        <action name="Move"/>
+      </mousebind>
+      <mousebind button="W-Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="W-Right" action="Drag">
+        <action name="Resize"/>
+      </mousebind>
+      <mousebind button="W-Middle" action="Press">
+        <action name="Lower"/>
+        <action name="FocusToBottom"/>
+        <action name="Unfocus"/>
+      </mousebind>
+      <mousebind button="W-Up" action="Click">
+        <action name="DesktopPrevious"/>
+      </mousebind>
+      <mousebind button="W-Down" action="Click">
+        <action name="DesktopNext"/>
+      </mousebind>
+      <mousebind button="C-W-Up" action="Click">
+        <action name="DesktopPrevious"/>
+      </mousebind>
+      <mousebind button="C-W-Down" action="Click">
+        <action name="DesktopNext"/>
+      </mousebind>
+      <mousebind button="W-S-Up" action="Click">
+        <action name="SendToDesktopPrevious"/>
+      </mousebind>
+      <mousebind button="W-S-Down" action="Click">
+        <action name="SendToDesktopNext"/>
+      </mousebind>
+    </context>
+    <context name="Titlebar">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Move"/>
+      </mousebind>
+      <mousebind button="Left" action="DoubleClick">
+        <action name="ToggleMaximizeFull"/>
+      </mousebind>
+      <mousebind button="Middle" action="Press">
+        <action name="Lower"/>
+        <action name="FocusToBottom"/>
+        <action name="Unfocus"/>
+      </mousebind>
+      <mousebind button="Up" action="Click">
+        <action name="Shade"/>
+        <action name="FocusToBottom"/>
+        <action name="Unfocus"/>
+        <action name="Lower"/>
+      </mousebind>
+      <mousebind button="Down" action="Click">
+        <action name="Unshade"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="ShowMenu">
+          <menu>client-menu</menu>
+        </action>
+      </mousebind>
+    </context>
+    <context name="Top">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize">
+          <edge>top</edge>
+        </action>
+      </mousebind>
+    </context>
+    <context name="Left">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize">
+          <edge>left</edge>
+        </action>
+      </mousebind>
+    </context>
+    <context name="Right">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize">
+          <edge>right</edge>
+        </action>
+      </mousebind>
+    </context>
+    <context name="Bottom">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize">
+          <edge>bottom</edge>
+        </action>
+      </mousebind>
+      <mousebind button="Middle" action="Press">
+        <action name="Lower"/>
+        <action name="FocusToBottom"/>
+        <action name="Unfocus"/>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="ShowMenu">
+          <menu>client-menu</menu>
+        </action>
+      </mousebind>
+    </context>
+    <context name="BLCorner">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize"/>
+      </mousebind>
+    </context>
+    <context name="BRCorner">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize"/>
+      </mousebind>
+    </context>
+    <context name="TLCorner">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize"/>
+      </mousebind>
+    </context>
+    <context name="TRCorner">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Left" action="Drag">
+        <action name="Resize"/>
+      </mousebind>
+    </context>
+    <context name="Client">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Middle" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+    </context>
+    <context name="Icon">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+        <action name="ShowMenu">
+          <menu>client-menu</menu>
+        </action>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="ShowMenu">
+          <menu>client-menu</menu>
+        </action>
+      </mousebind>
+    </context>
+    <context name="AllDesktops">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Left" action="Click">
+        <action name="ToggleOmnipresent"/>
+      </mousebind>
+    </context>
+    <context name="Shade">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Click">
+        <action name="ToggleShade"/>
+      </mousebind>
+    </context>
+    <context name="Iconify">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Left" action="Click">
+        <action name="Iconify"/>
+      </mousebind>
+    </context>
+    <context name="Maximize">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Middle" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Left" action="Click">
+        <action name="ToggleMaximizeFull"/>
+      </mousebind>
+      <mousebind button="Middle" action="Click">
+        <action name="ToggleMaximizeVert"/>
+      </mousebind>
+      <mousebind button="Right" action="Click">
+        <action name="ToggleMaximizeHorz"/>
+      </mousebind>
+    </context>
+    <context name="Close">
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+        <action name="Unshade"/>
+      </mousebind>
+      <mousebind button="Left" action="Click">
+        <action name="Close"/>
+      </mousebind>
+    </context>
+    <context name="Desktop">
+      <mousebind button="W-Up" action="Click">
+        <action name="DesktopPrevious"/>
+      </mousebind>
+      <mousebind button="W-Down" action="Click">
+        <action name="DesktopNext"/>
+      </mousebind>
+      <mousebind button="W-C-Up" action="Click">
+        <action name="DesktopPrevious"/>
+      </mousebind>
+      <mousebind button="W-C-Down" action="Click">
+        <action name="DesktopNext"/>
+      </mousebind>
+      <mousebind button="Left" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="Focus"/>
+        <action name="Raise"/>
+      </mousebind>
+    </context>
+    <context name="Root">
+      <!-- Menus -->
+      <mousebind button="Middle" action="Press">
+        <action name="ShowMenu">
+          <menu>client-list-combined-menu</menu>
+        </action>
+      </mousebind>
+      <mousebind button="Right" action="Press">
+        <action name="ShowMenu">
+          <menu>root-menu</menu>
+        </action>
+      </mousebind>
+    </context>
+    <context name="MoveResize">
+      <mousebind button="Up" action="Click">
+        <action name="DesktopPrevious"/>
+      </mousebind>
+      <mousebind button="Down" action="Click">
+        <action name="DesktopNext"/>
+      </mousebind>
+      <mousebind button="W-Up" action="Click">
+        <action name="DesktopPrevious"/>
+      </mousebind>
+      <mousebind button="W-Down" action="Click">
+        <action name="DesktopNext"/>
+      </mousebind>
+    </context>
+  </mouse>
+  <menu>
+    <!-- You can specify more than one menu file in here and they are all loaded,
+       just don't make menu ids clash or, well, it'll be kind of pointless -->
+    <!-- default menu file (or custom one in $HOME/.config/openbox/) -->
+    <!-- system menu files on Debian systems -->
+    <file>/var/lib/openbox/debian-menu.xml</file>
+    <file>debian-menu.xml</file>
+    <file>menu.xml</file>
+    <hideDelay>200</hideDelay>
+    <!-- if a press-release lasts longer than this setting (in milliseconds), the
+       menu is hidden again -->
+    <middle>no</middle>
+    <!-- center submenus vertically about the parent entry -->
+    <submenuShowDelay>100</submenuShowDelay>
+    <!-- this one is easy, time to delay before showing a submenu after hovering
+       over the parent entry -->
+    <applicationIcons>yes</applicationIcons>
+    <!-- controls if icons appear in the client-list-(combined-)menu -->
+    <manageDesktops>yes</manageDesktops>
+    <!-- show the manage desktops section in the client-list-(combined-)menu -->
+  </menu>
+  <applications>
+    <application name="stalonetray">
+      <decor>yes</decor>
+      <desktop>all</desktop>
+      <layer>below</layer>
+      <skip_pager>yes</skip_pager>
+      <skip_taskbar>yes</skip_taskbar>
+    </application>
+  </applications>
+</openbox_config>
diff --git a/screen/screen-stats.awk b/screen/screen-stats.awk
new file mode 100755
--- /dev/null
+++ b/screen/screen-stats.awk
@@ -0,0 +1,73 @@
+#! /usr/bin/awk -f
+
+BEGIN {
+    cpufile = "/proc/stat";
+    memfile = "/proc/meminfo";
+    uptimefile = "/proc/uptime";
+
+    cpu_period = 2;
+    uptime_period = 60;
+    uptime_counter = 0;
+    updates_downcounter = 0;
+    updates_command = "aptitude search ~U -F %p --disable-columns | wc -l";
+
+    while (1) {
+        # updates
+        if (updates_downcounter == 0) {
+            nexttime = mktime(strftime("%Y %m %d") " 09 00 00");
+            if (nexttime < systime())
+                nexttime += 24*3600;
+            updates_downcounter = int((nexttime - systime()) / cpu_period);
+            updates_command | getline updates;
+            if (updates == 0)
+                updates = "up-to-date"
+            else
+                updates = "\005{Y}" updates "\005{-} updates"
+            close(updates_command);
+        }
+        updates_downcounter--;
+
+        # cpu
+        getline < cpufile;
+        u=$2-up; n=$3-np; s=$4-sp; i=$5-ip; w=$6-wp; q=$7-qp; f=$8-fp;
+        cpu = sprintf("%3.0f",(u+n+s)/(u+n+s+i+w+q+f)*100);
+        up=$2;np=$3;sp=$4;ip=$5;wp=$6;qp=$7;fp=$8;
+        close(cpufile);
+
+        # memory
+        avail = -1; cached = -1; buffers = 0;
+        while (avail == -1 && cached == -1) {
+            getline < memfile;
+            if ($1 == "MemTotal:")     total=$2;
+            if ($1 == "MemFree:")      free=$2;
+            if ($1 == "MemAvailable:") avail=$2;
+            if ($1 == "Buffers:")      buffers=$2;
+            if ($1 == "Cached:")       cached=$2;
+        }
+        if (avail == -1)
+            avail = free + buffers + cached;
+        mem = sprintf("%.0f", (total - avail) / total * 100);
+        close(memfile);
+
+        # uptime
+        if (uptime_counter * cpu_period == uptime_period)
+            uptime_counter = 0;
+        if (uptime_counter == 0) {
+            getline < uptimefile
+            if ($1 > 86400)
+                uptime = sprintf("\005{Y}%d\005{-}d \005{Y}%d\005{-}h", $1/86400, $1%86400/3600);
+            else if ($1 > 3600)
+                uptime = sprintf("\005{Y}%d\005{-}h \005{Y}%d\005{-}m", $1/3600, $1%3600/60);
+            else
+                uptime = sprintf("\005{Y}%d\005{-}m", $1/60);
+            close(uptimefile);
+        }
+        uptime_counter++;
+
+        printf "%s \005{w}|\005{-} cpu\005{Y}%s\005{-}%% \005{w}|\005{-} mem \005{Y}%s\005{-}%% \005{w}|\005{-} up %s\n", updates, cpu, mem, uptime;
+
+        if (system(sprintf("sleep %d", cpu_period)) != 0)
+            break
+    }
+    exit
+}
diff --git a/screenrc b/screenrc
new file mode 100644
--- /dev/null
+++ b/screenrc
@@ -0,0 +1,36 @@
+startup_message off
+vbell off
+altscreen on
+hardstatus on
+hardstatus alwayslastline
+backtick 1 86400 86400 whoami
+backtick 2 86400 86400 uname -m
+
+backtick 100 0 0 $HOME/.dotfiles/screen/screen-stats.awk
+
+hardstatus string "%{= kY}%1`%{+b G}@%{+b Y}%H%{-b G} (%2`) %-=%{G}%100` %{w}|%{-} %{Y}%Y%{-}.%{Y}%m%{-}.%{Y}%d%{-} %D %{Y}%C%{-}:%{Y}%s%{-} %a"
+
+caption always
+caption string "%-Lw%{= bw}%50>%n %t%{-}%+Lw%<"
+
+term screen-256color
+
+shelltitle '$ |shell'
+
+# Set GNU screen command entry character to C-t
+escape ^Tt
+
+# Two C-t = literal C-t
+escape ^t^t
+
+defscrollback 10000
+bindkey -k k2 screen
+bindkey -k k3 prev
+bindkey -k k4 next
+bindkey -k k5 copy
+bindkey -k k8 title
+bindkey -k k9 focus
+bind x
+bind s
+bind ^s
+bind u source ~/.screenrc
diff --git a/stalonetrayrc b/stalonetrayrc
new file mode 100644
--- /dev/null
+++ b/stalonetrayrc
@@ -0,0 +1,6 @@
+geometry 3x5-0+0
+icon_size 21
+icon_gravity NE
+transparent true
+window_strut right
+window_type dock
diff --git a/themes/ak/openbox-3/bullet.xbm b/themes/ak/openbox-3/bullet.xbm
new file mode 100644
--- /dev/null
+++ b/themes/ak/openbox-3/bullet.xbm
@@ -0,0 +1,4 @@
+#define bullet_width 6
+#define bullet_height 6
+static unsigned char bullet_bits[] = {
+   0x00, 0x02, 0x04, 0x08, 0x04, 0x02 };
diff --git a/themes/ak/openbox-3/close.xbm b/themes/ak/openbox-3/close.xbm
new file mode 100755
--- /dev/null
+++ b/themes/ak/openbox-3/close.xbm
@@ -0,0 +1,5 @@
+#define close_width 10
+#define close_height 10
+static unsigned char close_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x48, 0x00, 0x30, 0x00, 0x30, 0x00,
+   0x48, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/themes/ak/openbox-3/iconify.xbm b/themes/ak/openbox-3/iconify.xbm
new file mode 100755
--- /dev/null
+++ b/themes/ak/openbox-3/iconify.xbm
@@ -0,0 +1,5 @@
+#define iconify_width 10
+#define iconify_height 10
+static unsigned char iconify_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x44, 0x00, 0x28, 0x00,
+   0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/themes/ak/openbox-3/max.xbm b/themes/ak/openbox-3/max.xbm
new file mode 100755
--- /dev/null
+++ b/themes/ak/openbox-3/max.xbm
@@ -0,0 +1,5 @@
+#define max_width 10
+#define max_height 10
+static unsigned char max_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x28, 0x00, 0x44, 0x00,
+   0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
diff --git a/themes/ak/openbox-3/themerc b/themes/ak/openbox-3/themerc
new file mode 100644
--- /dev/null
+++ b/themes/ak/openbox-3/themerc
@@ -0,0 +1,113 @@
+!! ak openbox theme
+!! based on:
+!! - Turquoise Nights Ob
+!! - 1977
+
+!! menu title
+menu.title.bg: flat gradient vertical
+menu.title.bg.color:  #282828
+menu.title.text.color:#aaaaaa
+menu.title.text.justify: center
+menu.title.bg.colorTo: #121212
+
+!! menu borders
+menu.separator.color:#454545
+menu.border.color: #000000
+menu.border.width: 1
+
+!! menu items
+menu.items.font: shadow=n
+menu.items.bg: flat solid
+menu.items.bg.color:#282828
+menu.items.bg.colorTo:#0b0b0b
+menu.items.text.color:#cccccc
+menu.items.justify: left
+menu.items.disabled.text.color: #777777
+menu.items.active.bg: flat solid
+menu.items.active.bg.color:#0f0f0f
+menu.items.active.bg.color.To:#0b0b0b
+menu.items.active.text.color:#00ffff
+
+!! window title
+window.active.title.bg: flat solid
+window.active.title.bg.color: #282828
+window.inactive.title.bg: flat solid
+window.inactive.title.bg.color:  #282828
+
+!! window text
+window.active.label.bg: parentrelative
+window.active.label.bg.color: #282828
+window.active.label.text.color:#ffffff
+window.inactive.label.bg: parentrelative
+window.inactive.label.bg.color: #282828
+window.inactive.label.text.color: #777777
+
+!! window borders
+window.active.client.color: #ffffff
+window.inactive.client.color: #282828
+window.active.title.separator.color:  #282828
+window.inactive.title.separator.color: #282828
+
+!! window buttons
+window.active.button.unpressed.bg: parentrelative
+window.active.button.unpressed.bg.color: #282828
+window.active.button.unpressed.image.color: #888888
+
+window.active.button.pressed.bg: parentrelative
+window.active.button.pressed.bg.color: #282828
+window.active.button.pressed.image.color: #ffffff
+
+window.active.button.disabled.bg: parentrelative
+window.active.button.disabled.bg.color: #282828
+window.active.button.disabled.image.color: #454545
+
+
+window.active.button.hover.bg: parentrelative
+window.active.button.hover.bg.color: #282828
+window.active.button.hover.image.color: #00ffff
+
+window.active.button.toggled.bg: parentrelative
+window.active.button.toggled.bg.color: #282828
+window.active.button.toggled.image.color: #888888
+
+window.inactive.button.unpressed.bg: parentrelative
+window.inactive.button.unpressed.bg.color: #282828
+window.inactive.button.unpressed.image.color: #888888
+
+window.inactive.button.pressed.bg: parentrelative
+window.inactive.button.pressed.bg.color: #282828
+window.inactive.button.pressed.image.color: #ffffff
+
+window.inactive.button.disabled.bg: parentrelative
+window.inactive.button.disabled.bg.color: #282828
+window.inactive.button.disabled.image.color: #454545
+
+window.inactive.button.hover.bg: parentrelative
+window.inactive.button.hover.bg.color: #282828
+window.inactive.button.hover.image.color: #00ffff
+
+window.inactive.button.toggled.bg: parentrelative
+window.inactive.button.toggled.bg.color: #282828
+window.inactive.button.toggled.image.color: #888888
+
+!! misc settings
+border.color: #282828
+border.width: 2
+padding.width: 6
+padding.height: 6
+window.handle.width: 0
+window.client.padding.width: 0
+menu.overlap.x: 1
+menu.overlap.y: 0
+
+!! osd
+osd.border.width: 4
+osd.border.color:  #282828
+osd.bg: flat solid
+osd.bg.color: #282828
+osd.hilight.bg: solid flat
+osd.hilight.bg.color: #000000
+osd.unhilight.bg: flat solid
+osd.unhilight.bg.color: #ffffff
+osd.label.bg: Parentrelative
+osd.label.text.color: #ffffff
diff --git a/thunderbird-userChrome.css b/thunderbird-userChrome.css
new file mode 100644
--- /dev/null
+++ b/thunderbird-userChrome.css
@@ -0,0 +1,8 @@
+treechildren::-moz-tree-row {
+    min-height: 24px !important;
+}
+
+#threadTree >treechildren::-moz-tree-row {
+    min-height: 26px !important;
+    border-bottom: 1px solid #ccc !important;
+}
diff --git a/zsh/agents.zsh b/zsh/agents.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/agents.zsh
@@ -0,0 +1,8 @@
+#
+# Agents
+#
+
+# ssh and gpg agents
+if [ -x /usr/bin/keychain ]; then
+    eval $(keychain --eval --quick --quiet)
+fi;
diff --git a/zsh/completion.zsh b/zsh/completion.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/completion.zsh
@@ -0,0 +1,138 @@
+#
+# Completion
+#
+
+# Add completion functions to $fpath
+fpath=($ZSHROOT/completion(/FN) $fpath)
+fpath=($ZSHROOT/completion/zsh-completions/src(/FN) $fpath)
+
+# Load and initialize the completion system ignoring insecure directories
+autoload -Uz compinit && compinit -i
+
+#
+# Options
+#
+
+setopt complete_in_word    # Complete from both ends of a word
+setopt always_to_end       # Move cursor to the end of a completed word
+setopt path_dirs           # Perform path search even on command names with slashes
+setopt auto_menu           # Show completion menu on a succesive tab press
+setopt auto_list           # Automatically list choices on ambiguous completion
+setopt auto_param_slash    # If completed parameter is a directory, add a trailing slash
+unsetopt menu_complete     # Do not autoselect the first completion entry
+unsetopt flow_control      # Disable start/stop characters in shell editor
+
+# Treat these characters as part of a word
+WORDCHARS=''
+
+#
+# Styles
+#
+
+# Use caching to make completion for cammands such as dpkg and apt usable
+zstyle ':completion::complete:*' use-cache on
+zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-$HOME}/.zcompcache"
+
+# Case-insensitive (all), partial-word, and then substring completion
+zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
+unsetopt CASE_GLOB
+
+# Group matches and describe
+zstyle ':completion:*:*:*:*:*' menu select
+zstyle ':completion:*:matches' group 'yes'
+zstyle ':completion:*:options' description 'yes'
+zstyle ':completion:*:options' auto-description '%d'
+zstyle ':completion:*:corrections' format ' %F{green}-- %d (errors: %e) --%f'
+zstyle ':completion:*:descriptions' format ' %F{yellow}-- %d --%f'
+zstyle ':completion:*:messages' format ' %F{purple} -- %d --%f'
+zstyle ':completion:*:warnings' format ' %F{red}-- no matches found --%f'
+zstyle ':completion:*:default' list-prompt '%S%M matches%s'
+zstyle ':completion:*' format ' %F{yellow}-- %d --%f'
+zstyle ':completion:*' group-name ''
+zstyle ':completion:*' verbose yes
+
+# Fuzzy match mistyped completions
+zstyle ':completion:*' completer _complete _match _approximate
+zstyle ':completion:*:match:*' original only
+zstyle ':completion:*:approximate:*' max-errors 1 numeric
+
+# Increase the number of errors based on the length of the typed word
+zstyle -e ':completion:*:approximate:*' max-errors 'reply=($((($#PREFIX+$#SUFFIX)/3))numeric)'
+
+# Don't complete unavailable commands
+zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec))'
+
+# Array completion element sorting
+zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
+
+# Directories
+zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
+zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
+zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
+zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'users' 'expand'
+zstyle ':completion:*' squeeze-slashes true
+
+# History
+zstyle ':completion:*:history-words' stop yes
+zstyle ':completion:*:history-words' remove-all-dups yes
+zstyle ':completion:*:history-words' list false
+zstyle ':completion:*:history-words' menu yes
+
+# Environmental Variables
+zstyle ':completion::*:(-command-|export):*' fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-}
+
+# Populate hostname completion
+zstyle -e ':completion:*:hosts' hosts 'reply=(
+  ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) 2>/dev/null)"}%%[#| ]*}//,/ }
+  ${=${(f)"$(cat /etc/hosts(|)(N) <<(ypcat hosts 2>/dev/null))"}%%\#*}
+  ${=${${${${(@M)${(f)"$(cat ~/.ssh/config 2>/dev/null)"}:#Host *}#Host }:#*\**}:#*\?*}}
+)'
+
+# 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 '_*'
+
+# ... unless we really want to
+zstyle '*' single-ignored show
+
+# Ignore multiple entries
+zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
+zstyle ':completion:*:rm:*' file-patterns '*:all-files'
+
+# Kill
+zstyle ':completion:*:*:*:*:processes' command 'ps -u $USER -o pid,user,comm -w'
+zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01'
+zstyle ':completion:*:*:kill:*' menu yes select
+zstyle ':completion:*:*:kill:*' force-list always
+
+# Man
+zstyle ':completion:*:manuals' separate-sections true
+zstyle ':completion:*:manuals.(^1*)' insert-sections true
+
+
+# Mutt
+if [[ -s "$HOME/.mutt/aliases" ]]; then
+  zstyle ':completion:*:*:mutt:*' menu yes select
+  zstyle ':completion:*:mutt:*' users ${${${(f)"$(<"$HOME/.mutt/aliases")"}#alias[[:space:]]}%%[[:space:]]*}
+fi
+
+# SSH/SCP/RSYNC
+zstyle ':completion:*:(scp|rsync):*' tag-order 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
+zstyle ':completion:*:(scp|rsync):*' group-order users files all-files hosts-domain hosts-host hosts-ipaddr
+zstyle ':completion:*:ssh:*' tag-order users 'hosts:-host:host hosts:-domain:domain hosts:-ipaddr:ip\ address *'
+zstyle ':completion:*:ssh:*' group-order hosts-domain hosts-host users hosts-ipaddr
+zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost
+zstyle ':completion:*:(ssh|scp|rsync):*:hosts-domain' ignored-patterns '<->.<->.<->.<->' '^[-[:alnum:]]##(.[-[:alnum:]]##)##' '*@*'
+zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*'
+
+# Highlight matching substring while completing
+zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
+highlights='${PREFIX:+=(#bi)($PREFIX:t)(?)*==31=1;32}':${(s.:.)LS_COLORS}}
+zstyle -e ':completion:*' list-colors 'if [[ $words[1] != kill && $words[1] != strace ]]; then reply=( "'$highlights'" ); fi'
+unset highlights
diff --git a/zsh/completion/_hg b/zsh/completion/_hg
new file mode 100644
--- /dev/null
+++ b/zsh/completion/_hg
@@ -0,0 +1,1222 @@
+#compdef hg
+
+# Zsh completion script for mercurial.  Rename this file to _hg and copy
+# it into your zsh function path (/usr/share/zsh/site-functions for
+# instance)
+#
+# If you do not want to install it globally, you can copy it somewhere
+# else and add that directory to $fpath. This must be done before
+# compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc
+# file could look like this:
+#
+# fpath=("$HOME/.zsh.d" $fpath)
+# autoload -U compinit
+# compinit
+#
+# Copyright (C) 2005, 2006 Steve Borho <[email protected]>
+# Copyright (C) 2006-10 Brendan Cully <[email protected]>
+#
+# Permission is hereby granted, without written agreement and without
+# licence or royalty fees, to use, copy, modify, and distribute this
+# software and to distribute modified versions of this software for any
+# purpose, provided that the above copyright notice and the following
+# two paragraphs appear in all copies of this software.
+#
+# In no event shall the authors be liable to any party for direct,
+# indirect, special, incidental, or consequential damages arising out of
+# the use of this software and its documentation, even if the authors
+# have been advised of the possibility of such damage.
+#
+# The authors specifically disclaim any warranties, including, but not
+# limited to, the implied warranties of merchantability and fitness for
+# a particular purpose.  The software provided hereunder is on an "as
+# is" basis, and the authors have no obligation to provide maintenance,
+# support, updates, enhancements, or modifications.
+
+emulate -LR zsh
+setopt extendedglob
+
+local curcontext="$curcontext" state line
+typeset -A _hg_cmd_globals
+
+_hg() {
+  local cmd _hg_root
+  integer i=2
+  _hg_cmd_globals=()
+
+  while (( i < $#words ))
+  do
+    case "$words[$i]" in
+      -R|--repository)
+        eval _hg_root="$words[$i+1]"
+        _hg_cmd_globals+=("$words[$i]" "$_hg_root")
+        (( i += 2 ))
+        continue
+      ;;
+      -R*)
+        _hg_cmd_globals+="$words[$i]"
+        eval _hg_root="${words[$i]#-R}"
+       (( i++ ))
+       continue
+      ;;
+      --cwd|--config)
+        # pass along arguments to hg completer
+        _hg_cmd_globals+=("$words[$i]" "$words[$i+1]")
+        (( i += 2 ))
+        continue
+      ;;
+      -*)
+        # skip option
+        (( i++ ))
+        continue
+      ;;
+    esac
+    if [[ -z "$cmd" ]]
+    then
+      cmd="$words[$i]"
+      words[$i]=()
+      (( CURRENT-- ))
+    fi
+    (( i++ ))
+  done
+
+  if [[ -z "$cmd" ]]
+  then
+    _arguments -s -w : $_hg_global_opts \
+    ':mercurial command:_hg_commands'
+    return
+  fi
+
+  # resolve abbreviations and aliases
+  if ! (( $+functions[_hg_cmd_${cmd}] ))
+  then
+    local cmdexp
+    (( $#_hg_cmd_list )) || _hg_get_commands
+
+    cmdexp=$_hg_cmd_list[(r)${cmd}*]
+    if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]]
+    then
+      # might be nice to rewrite the command line with the expansion
+      cmd="$cmdexp"
+    fi
+    if [[ -n $_hg_alias_list[$cmd] ]]
+    then
+      cmd=$_hg_alias_list[$cmd]
+    fi
+  fi
+
+  curcontext="${curcontext%:*:*}:hg-${cmd}:"
+
+  zstyle -s ":completion:$curcontext:" cache-policy update_policy
+
+  if [[ -z "$update_policy" ]]
+  then
+    zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy
+  fi
+
+  if (( $+functions[_hg_cmd_${cmd}] ))
+  then
+    _hg_cmd_${cmd}
+  else
+    # complete unknown commands normally
+    _arguments -s -w : $_hg_global_opts \
+      '*:files:_hg_files'
+  fi
+}
+
+_hg_cache_policy() {
+  typeset -a old
+
+  # cache for a minute
+  old=( "$1"(mm+10) )
+  (( $#old )) && return 0
+
+  return 1
+}
+
+_hg_get_commands() {
+  typeset -ga _hg_cmd_list
+  typeset -gA _hg_alias_list
+  local hline cmd cmdalias
+
+  _call_program hg hg debugcomplete -v | while read -A hline
+  do
+    cmd=$hline[1]
+    _hg_cmd_list+=($cmd)
+
+    for cmdalias in $hline[2,-1]
+    do
+      _hg_cmd_list+=($cmdalias)
+      _hg_alias_list+=($cmdalias $cmd)
+    done
+  done
+}
+
+_hg_commands() {
+  (( $#_hg_cmd_list )) || _hg_get_commands
+  _describe -t commands 'mercurial command' _hg_cmd_list
+}
+
+_hg_revrange() {
+  compset -P 1 '*:'
+  _hg_labels "$@"
+}
+
+_hg_labels() {
+  labels=("${(f)$(_hg_cmd debuglabelcomplete)}")
+  (( $#labels )) && _describe -t labels 'labels' labels
+}
+
+_hg_bookmarks() {
+  typeset -a bookmark bookmarks
+
+  _hg_cmd bookmarks | while read -A bookmark
+  do
+    if test -z ${bookmark[-1]:#[0-9]*}
+    then
+      bookmarks+=($bookmark[-2])
+    fi
+  done
+  (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
+}
+
+_hg_branches() {
+  typeset -a branches
+  local branch
+
+  _hg_cmd branches | while read branch
+  do
+    branches+=(${branch/ #[0-9]#:*})
+  done
+  (( $#branches )) && _describe -t branches 'branches' branches
+}
+
+# likely merge candidates
+_hg_mergerevs() {
+  typeset -a heads
+  local myrev
+
+  heads=(${(f)"$(_hg_cmd heads --template '{rev}:{branch}\\n')"})
+  # exclude own revision
+  myrev=$(_hg_cmd log -r . --template '{rev}:{branch}\\n')
+  heads=(${heads:#$myrev})
+
+  (( $#heads )) && _describe -t heads 'heads' heads
+
+  branches=(${(f)"$(_hg_cmd heads --template '{branch}\\n')"})
+  # exclude own revision
+  myrev=$(_hg_cmd log -r . --template '{branch}\\n')
+  branches=(${branches:#$myrev})
+
+  (( $#branches )) && _describe -t branches 'branches' branches
+}
+
+_hg_files() {
+  if [[ -n "$_hg_root" ]]
+  then
+    [[ -d "$_hg_root/.hg" ]] || return
+    case "$_hg_root" in
+      /*)
+        _files -W $_hg_root
+      ;;
+      *)
+        _files -W $PWD/$_hg_root
+      ;;
+    esac
+  else
+    _files
+  fi
+}
+
+_hg_status() {
+  [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
+  status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
+}
+
+_hg_unknown() {
+  typeset -a status_files
+  _hg_status u
+  _wanted files expl 'unknown files' _multi_parts / status_files
+}
+
+_hg_missing() {
+  typeset -a status_files
+  _hg_status d
+  _wanted files expl 'missing files' _multi_parts / status_files
+}
+
+_hg_modified() {
+  typeset -a status_files
+  _hg_status m
+  _wanted files expl 'modified files' _multi_parts / status_files
+}
+
+_hg_resolve() {
+  local rstate rpath
+
+  [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
+
+  _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
+  do
+    [[ $rstate == 'R' ]] && resolved_files+=($rpath)
+    [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
+  done
+}
+
+_hg_resolved() {
+  typeset -a resolved_files unresolved_files
+  _hg_resolve
+  _wanted files expl 'resolved files' _multi_parts / resolved_files
+}
+
+_hg_unresolved() {
+  typeset -a resolved_files unresolved_files
+  _hg_resolve
+  _wanted files expl 'unresolved files' _multi_parts / unresolved_files
+}
+
+_hg_config() {
+    typeset -a items
+    items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
+    (( $#items )) && _describe -t config 'config item' items
+}
+
+_hg_addremove() {
+  _alternative 'files:unknown files:_hg_unknown' \
+    'files:missing files:_hg_missing'
+}
+
+_hg_ssh_urls() {
+  if [[ -prefix */ ]]
+  then
+    if zstyle -T ":completion:${curcontext}:files" remote-access
+    then
+      local host=${PREFIX%%/*}
+      typeset -a remdirs
+      compset -p $(( $#host + 1 ))
+      local rempath=${(M)PREFIX##*/}
+      local cacheid="hg:${host}-${rempath//\//_}"
+      cacheid=${cacheid%[-_]}
+      compset -P '*/'
+      if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
+      then
+        remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
+        _store_cache "$cacheid" remdirs
+      fi
+      _describe -t directories 'remote directory' remdirs -S/
+    else
+      _message 'remote directory'
+    fi
+  else
+    if compset -P '*@'
+    then
+      _hosts -S/
+    else
+      _alternative 'hosts:remote host name:_hosts -S/' \
+        'users:user:_users -S@'
+    fi
+  fi
+}
+
+_hg_urls() {
+  if compset -P bundle://
+  then
+    _files
+  elif compset -P ssh://
+  then
+    _hg_ssh_urls
+  elif [[ -prefix *: ]]
+  then
+    _urls
+  else
+    local expl
+    compset -S '[^:]*'
+    _wanted url-schemas expl 'URL schema' compadd -S '' - \
+      http:// https:// ssh:// bundle://
+  fi
+}
+
+_hg_paths() {
+  typeset -a paths pnames
+  _hg_cmd paths | while read -A pnames
+  do
+    paths+=($pnames[1])
+  done
+  (( $#paths )) && _describe -t path-aliases 'repository alias' paths
+}
+
+_hg_remote() {
+  _alternative 'path-aliases:repository alias:_hg_paths' \
+    'directories:directory:_files -/' \
+    'urls:URL:_hg_urls'
+}
+
+_hg_clone_dest() {
+  _alternative 'directories:directory:_files -/' \
+    'urls:URL:_hg_urls'
+}
+
+_hg_add_help_topics=(
+    config dates diffs environment extensions filesets glossary hgignore hgweb
+    merge-tools multirevs obsolescence patterns phases revisions revsets
+    subrepos templating urls
+)
+
+_hg_help_topics() {
+    local topics
+    (( $#_hg_cmd_list )) || _hg_get_commands
+    topics=($_hg_cmd_list $_hg_add_help_topics)
+    _describe -t help_topics 'help topics' topics
+}
+
+# Common options
+_hg_global_opts=(
+    '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
+    '--cwd[change working directory]:new working directory:_files -/'
+    '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
+    '(--verbose -v)'{-v,--verbose}'[enable additional output]'
+    '*--config[set/override config option]:defined config items:_hg_config'
+    '(--quiet -q)'{-q,--quiet}'[suppress output]'
+    '(--help -h)'{-h,--help}'[display help and exit]'
+    '--debug[debug mode]'
+    '--debugger[start debugger]'
+    '--encoding[set the charset encoding]'
+    '--encodingmode[set the charset encoding mode]'
+    '--lsprof[print improved command execution profile]'
+    '--traceback[print traceback on exception]'
+    '--time[time how long the command takes]'
+    '--profile[profile]'
+    '--version[output version information and exit]'
+)
+
+_hg_pat_opts=(
+  '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
+  '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
+
+_hg_clone_opts=(
+  $_hg_remote_opts
+  '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]'
+  '--pull[use pull protocol to copy metadata]'
+  '--uncompressed[use uncompressed transfer (fast over LAN)]')
+
+_hg_date_user_opts=(
+  '(--currentdate -D)'{-D,--currentdate}'[record the current date as commit date]'
+  '(--currentuser -U)'{-U,--currentuser}'[record the current user as committer]'
+  '(--date -d)'{-d+,--date}'[record the specified date as commit date]:date:'
+  '(--user -u)'{-u+,--user}'[record the specified user as committer]:user:')
+
+_hg_gitlike_opts=(
+  '(--git -g)'{-g,--git}'[use git extended diff format]')
+
+_hg_diff_opts=(
+  $_hg_gitlike_opts
+  '(--text -a)'{-a,--text}'[treat all files as text]'
+  '--nodates[omit dates from diff headers]')
+
+_hg_mergetool_opts=(
+  '(--tool -t)'{-t+,--tool}'[specify merge tool]:tool:')
+
+_hg_dryrun_opts=(
+  '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
+
+_hg_ignore_space_opts=(
+  '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]'
+  '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]'
+  '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]')
+
+_hg_style_opts=(
+  '--style[display using template map file]:'
+  '--template[display with template]:')
+
+_hg_log_opts=(
+  $_hg_global_opts $_hg_style_opts $_hg_gitlike_opts
+  '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:'
+  '(--no-merges -M)'{-M,--no-merges}'[do not show merges]'
+  '(--patch -p)'{-p,--patch}'[show patch]'
+  '--stat[output diffstat-style summary of changes]'
+)
+
+_hg_commit_opts=(
+  '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
+  '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
+  '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
+
+_hg_remote_opts=(
+  '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
+  '--remotecmd[specify hg command to run on the remote side]:')
+
+_hg_branch_bmark_opts=(
+  '(--bookmark -B)'{-B+,--bookmark}'[specify bookmark(s)]:bookmark:_hg_bookmarks'
+  '(--branch -b)'{-b+,--branch}'[specify branch(es)]:branch:_hg_branches'
+)
+
+_hg_subrepos_opts=(
+  '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]')
+
+_hg_cmd() {
+  _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
+}
+
+_hg_cmd_add() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \
+  '*:unknown files:_hg_unknown'
+}
+
+_hg_cmd_addremove() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
+  '*:unknown or missing files:_hg_addremove'
+}
+
+_hg_cmd_annotate() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+  '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
+  '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
+  '(--text -a)'{-a,--text}'[treat all files as text]' \
+  '(--user -u)'{-u,--user}'[list the author]' \
+  '(--date -d)'{-d,--date}'[list the date]' \
+  '(--number -n)'{-n,--number}'[list the revision number (default)]' \
+  '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
+  '*:files:_hg_files'
+}
+
+_hg_cmd_archive() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
+  '--no-decode[do not pass files through decoders]' \
+  '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
+  '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
+  '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
+  '*:destination:_files'
+}
+
+_hg_cmd_backout() {
+  _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
+    '--merge[merge with old dirstate parent after backout]' \
+    '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
+    '--parent[parent to choose when backing out merge]' \
+    '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
+    '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
+    '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
+    '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files'
+}
+
+_hg_cmd_bisect() {
+  _arguments -s -w : $_hg_global_opts \
+  '(-)'{-r,--reset}'[reset bisect state]' \
+  '(--extend -e)'{-e,--extend}'[extend the bisect range]' \
+  '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
+  '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
+  '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
+  '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \
+  '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
+}
+
+_hg_cmd_bookmarks() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--force -f)'{-f,--force}'[force]' \
+  '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
+  '(--rev -r --delete -d --rename -m)'{-r+,--rev}'[revision]:revision:_hg_labels' \
+  '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
+  '(--rev -r --delete -d --rename -m)'{-m+,--rename}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
+  ':bookmark:_hg_bookmarks'
+}
+
+_hg_cmd_branch() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
+  '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
+}
+
+_hg_cmd_branches() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]' \
+  '(--closed -c)'{-c,--closed}'[show normal and closed branches]'
+}
+
+_hg_cmd_bundle() {
+  _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+  '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
+  '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_labels' \
+  '(--branch -b)'{-b+,--branch}'[a specific branch to bundle]' \
+  '(--rev -r)'{-r+,--rev}'[changeset(s) to bundle]:' \
+  '--all[bundle all changesets in the repository]' \
+  ':output file:_files' \
+  ':destination repository:_files -/'
+}
+
+_hg_cmd_cat() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+  '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
+  '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
+  '--decode[apply any matching decode filter]' \
+  '*:file:_hg_files'
+}
+
+_hg_cmd_clone() {
+  _arguments -s -w : $_hg_global_opts $_hg_clone_opts \
+  '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
+  '(--updaterev -u)'{-u+,--updaterev}'[revision, tag or branch to check out]' \
+  '(--branch -b)'{-b+,--branch}'[clone only the specified branch]' \
+  ':source repository:_hg_remote' \
+  ':destination:_hg_clone_dest'
+}
+
+_hg_cmd_commit() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
+  '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
+  '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
+  '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files' \
+  '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
+  '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
+  '--amend[amend the parent of the working dir]' \
+  '--close-branch[mark a branch as closed]' \
+  '*:file:_hg_files'
+}
+
+_hg_cmd_copy() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
+  '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
+  '*:file:_hg_files'
+}
+
+_hg_cmd_diff() {
+  typeset -A opt_args
+  _arguments -s -w : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \
+                     $_hg_pat_opts $_hg_subrepos_opts \
+  '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
+  '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
+  '(--change -c)'{-c,--change}'[change made by revision]' \
+  '(--text -a)'{-a,--text}'[treat all files as text]' \
+  '--reverse[produce a diff that undoes the changes]' \
+  '(--unified -U)'{-U,--unified}'[number of lines of context to show]' \
+  '--stat[output diffstat-style summary of changes]' \
+  '*:file:->diff_files'
+
+  if [[ $state == 'diff_files' ]]
+  then
+    if [[ -n $opt_args[-r] ]]
+    then
+      _hg_files
+    else
+      _hg_modified
+    fi
+  fi
+}
+
+_hg_cmd_export() {
+  _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
+  '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
+  '--switch-parent[diff against the second parent]' \
+  '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
+  '*:revision:_hg_labels'
+}
+
+_hg_cmd_forget() {
+  _arguments -s -w : $_hg_global_opts \
+  '*:file:_hg_files'
+}
+
+_hg_cmd_graft() {
+  _arguments -s -w : $_hg_global_opts $_hg_dryrun_opts \
+                     $_hg_date_user_opts $_hg_mergetool_opts \
+  '(--continue -c)'{-c,--continue}'[resume interrupted graft]' \
+  '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
+  '--log[append graft info to log message]' \
+  '*:revision:_hg_labels'
+}
+
+_hg_cmd_grep() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+  '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
+  '--all[print all revisions with matches]' \
+  '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
+  '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
+  '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
+  '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
+  '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
+  '(--user -u)'{-u,--user}'[print user who committed change]' \
+  '(--date -d)'{-d,--date}'[print date of a changeset]' \
+  '1:search pattern:' \
+  '*:files:_hg_files'
+}
+
+_hg_cmd_heads() {
+  _arguments -s -w : $_hg_global_opts $_hg_style_opts \
+  '(--topo -t)'{-t,--topo}'[show topological heads only]' \
+  '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \
+  '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_labels'
+}
+
+_hg_cmd_help() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--extension -e)'{-e,--extension}'[show only help for extensions]' \
+  '(--command -c)'{-c,--command}'[show only help for commands]' \
+  '(--keyword -k)'{-k+,--keyword}'[show topics matching keyword]' \
+  '*:mercurial help topic:_hg_help_topics'
+}
+
+_hg_cmd_identify() {
+  _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+  '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
+  '(--num -n)'{-n+,--num}'[show local revision number]' \
+  '(--id -i)'{-i+,--id}'[show global revision id]' \
+  '(--branch -b)'{-b+,--branch}'[show branch]' \
+  '(--bookmark -B)'{-B+,--bookmark}'[show bookmarks]' \
+  '(--tags -t)'{-t+,--tags}'[show tags]'
+}
+
+_hg_cmd_import() {
+  _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
+  '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
+  '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
+  '--bypass[apply patch without touching the working directory]' \
+  '--no-commit[do not commit, just update the working directory]' \
+  '--exact[apply patch to the nodes from which it was generated]' \
+  '--import-branch[use any branch information in patch (implied by --exact)]' \
+  '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
+  '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
+  '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
+  '*:patch:_files'
+}
+
+_hg_cmd_incoming() {
+  _arguments -s -w : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
+                     $_hg_subrepos_opts \
+  '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
+  '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_labels' \
+  '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
+  '--bundle[file to store the bundles into]:bundle file:_files' \
+  ':source:_hg_remote'
+}
+
+_hg_cmd_init() {
+  _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
+  ':dir:_files -/'
+}
+
+_hg_cmd_locate() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+  '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_labels' \
+  '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
+  '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
+  '*:search pattern:_hg_files'
+}
+
+_hg_cmd_log() {
+  _arguments -s -w : $_hg_log_opts $_hg_pat_opts \
+  '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
+  '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
+  '(--copies -C)'{-C,--copies}'[show copied files]' \
+  '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
+  '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
+  '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
+  '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
+  '(--graph -G)'{-G+,--graph}'[show the revision DAG]' \
+  '(--branch -b)'{-b+,--branch}'[show changesets within the given named branch]:branch:_hg_branches' \
+  '(--user -u)'{-u+,--user}'[revisions committed by user]:user:' \
+  '(--date -d)'{-d+,--date}'[show revisions matching date spec]:date:' \
+  '*:files:_hg_files'
+}
+
+_hg_cmd_manifest() {
+  _arguments -s -w : $_hg_global_opts \
+  '--all[list files from all revisions]' \
+  '(--rev -r)'{-r+,--rev}'[revision to display]:revision:_hg_labels' \
+  ':revision:_hg_labels'
+}
+
+_hg_cmd_merge() {
+  _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts \
+  '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
+  '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
+  '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
+  ':revision:_hg_mergerevs'
+}
+
+_hg_cmd_outgoing() {
+  _arguments -s -w : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
+                     $_hg_subrepos_opts \
+  '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
+  '*'{-r,--rev}'[a specific revision you would like to push]:revision:_hg_revrange' \
+  '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
+  ':destination:_hg_remote'
+}
+
+_hg_cmd_parents() {
+  _arguments -s -w : $_hg_global_opts $_hg_style_opts \
+  '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_labels' \
+  ':last modified file:_hg_files'
+}
+
+_hg_cmd_paths() {
+  _arguments -s -w : $_hg_global_opts \
+  ':path:_hg_paths'
+}
+
+_hg_cmd_phase() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--public -p)'{-p,--public}'[set changeset phase to public]' \
+  '(--draft -d)'{-d,--draft}'[set changeset phase to draft]' \
+  '(--secret -s)'{-s,--secret}'[set changeset phase to secret]' \
+  '(--force -f)'{-f,--force}'[allow to move boundary backward]' \
+  '(--rev -r)'{-r+,--rev}'[target revision]:revision:_hg_labels' \
+  ':revision:_hg_labels'
+}
+
+_hg_cmd_pull() {
+  _arguments -s -w : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
+  '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
+  '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
+  '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
+  ':source:_hg_remote'
+}
+
+_hg_cmd_push() {
+  _arguments -s -w : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
+  '(--force -f)'{-f,--force}'[force push]' \
+  '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_labels' \
+  '--new-branch[allow pushing a new branch]' \
+  ':destination:_hg_remote'
+}
+
+_hg_cmd_remove() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
+  '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
+  '(--force -f)'{-f,--force}'[remove file even if modified]' \
+  '*:file:_hg_files'
+}
+
+_hg_cmd_rename() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
+  '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
+  '*:file:_hg_files'
+}
+
+_hg_cmd_resolve() {
+  local context state line
+  typeset -A opt_args
+
+  _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
+  '(--all -a)'{-a,--all}'[select all unresolved files]' \
+  '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
+  '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
+  '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
+  '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
+  '*:file:_hg_unresolved'
+
+  if [[ $state == 'resolve_files' ]]
+  then
+    _alternative 'files:resolved files:_hg_resolved' \
+      'files:unresolved files:_hg_unresolved'
+  fi
+}
+
+_hg_cmd_revert() {
+  local context state line
+  typeset -A opt_args
+
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
+  '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
+  '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
+  '(--date -d)'{-d+,--date}'[tipmost revision matching date]:date code:' \
+  '*:file:->diff_files'
+
+  if [[ $state == 'diff_files' ]]
+  then
+    if [[ -n $opt_args[-r] ]]
+    then
+      _hg_files
+    else
+      typeset -a status_files
+      _hg_status mard
+      _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
+    fi
+  fi
+}
+
+_hg_cmd_rollback() {
+  _arguments -s -w : $_hg_global_opts $_hg_dryrun_opts \
+  '(--force -f)'{-f,--force}'[ignore safety measures]' \
+}
+
+_hg_cmd_serve() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
+  '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
+  '(--daemon -d)'{-d,--daemon}'[run server in background]' \
+  '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
+  '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
+  '--prefix[prefix path to serve from]:directory:_files' \
+  '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
+  '--web-conf[name of the hgweb config file]:webconf_file:_files' \
+  '--pid-file[name of file to write process ID to]:pid_file:_files' \
+  '--cmdserver[cmdserver mode]:mode:' \
+  '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
+  '--style[web template style]:style' \
+  '--stdio[for remote clients]' \
+  '--certificate[certificate file]:cert_file:_files' \
+  '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
+}
+
+_hg_cmd_showconfig() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
+  ':config item:_hg_config'
+}
+
+_hg_cmd_status() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
+  '(--all -A)'{-A,--all}'[show status of all files]' \
+  '(--modified -m)'{-m,--modified}'[show only modified files]' \
+  '(--added -a)'{-a,--added}'[show only added files]' \
+  '(--removed -r)'{-r,--removed}'[show only removed files]' \
+  '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
+  '(--clean -c)'{-c,--clean}'[show only files without changes]' \
+  '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
+  '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
+  '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
+  '(--copies -C)'{-C,--copies}'[show source of copied files]' \
+  '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
+  '--rev[show difference from revision]:revision:_hg_labels' \
+  '--change[list the changed files of a revision]:revision:_hg_labels' \
+  '*:files:_files'
+}
+
+_hg_cmd_summary() {
+  _arguments -s -w : $_hg_global_opts \
+  '--remote[check for push and pull]'
+}
+
+_hg_cmd_tag() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--local -l)'{-l,--local}'[make the tag local]' \
+  '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
+  '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
+  '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
+  '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
+  '(--force -f)'{-f,--force}'[force tag]' \
+  '--remove[remove a tag]' \
+  '(--edit -e)'{-e,--edit}'[edit commit message]' \
+  ':tag name:'
+}
+
+_hg_cmd_tip() {
+  _arguments -s -w : $_hg_global_opts $_hg_gitlike_opts $_hg_style_opts \
+  '(--patch -p)'{-p,--patch}'[show patch]'
+}
+
+_hg_cmd_unbundle() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
+  ':files:_files'
+}
+
+_hg_cmd_update() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
+  '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
+  '(--check -c)'{-c,--check}'[update across branches if no uncommitted changes]' \
+  '(--date -d)'{-d+,--date}'[tipmost revision matching date]' \
+  ':revision:_hg_labels'
+}
+
+## extensions ##
+
+# HGK
+_hg_cmd_view() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
+  ':revision range:_hg_labels'
+}
+
+# MQ
+_hg_qseries() {
+  typeset -a patches
+  patches=(${(f)"$(_hg_cmd qseries)"})
+  (( $#patches )) && _describe -t hg-patches 'patches' patches
+}
+
+_hg_qapplied() {
+  typeset -a patches
+  patches=(${(f)"$(_hg_cmd qapplied)"})
+  if (( $#patches ))
+  then
+    patches+=(qbase qtip)
+    _describe -t hg-applied-patches 'applied patches' patches
+  fi
+}
+
+_hg_qunapplied() {
+  typeset -a patches
+  patches=(${(f)"$(_hg_cmd qunapplied)"})
+  (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
+}
+
+# unapplied, including guarded patches
+_hg_qdeletable() {
+  typeset -a unapplied
+  unapplied=(${(f)"$(_hg_cmd qseries)"})
+  for p in $(_hg_cmd qapplied)
+  do
+    unapplied=(${unapplied:#$p})
+  done
+
+  (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
+}
+
+_hg_qguards() {
+  typeset -a guards
+  local guard
+  compset -P "+|-"
+  _hg_cmd qselect -s | while read guard
+  do
+    guards+=(${guard#(+|-)})
+  done
+  (( $#guards )) && _describe -t hg-guards 'guards' guards
+}
+
+_hg_qseries_opts=(
+  '(--summary -s)'{-s,--summary}'[print first line of patch header]')
+
+_hg_cmd_qapplied() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
+  '(--last -1)'{-1,--last}'[show only the preceding applied patch]' \
+  '*:patch:_hg_qapplied'
+}
+
+_hg_cmd_qclone() {
+  _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_clone_opts \
+  '(--patches -p)'{-p+,--patches}'[location of source patch repository]' \
+  ':source repository:_hg_remote' \
+  ':destination:_hg_clone_dest'
+}
+
+_hg_cmd_qdelete() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--keep -k)'{-k,--keep}'[keep patch file]' \
+  '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
+  '*:unapplied patch:_hg_qdeletable'
+}
+
+_hg_cmd_qdiff() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
+                     $_hg_ignore_space_opts \
+  '*:pattern:_hg_files'
+}
+
+_hg_cmd_qfinish() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--applied -a)'{-a,--applied}'[finish all applied patches]' \
+  '*:patch:_hg_qapplied'
+}
+
+_hg_cmd_qfold() {
+  _arguments -s -w : $_hg_global_opts $_h_commit_opts \
+  '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
+  '(--force -f)'{-f,--force}'[overwrite any local changes]' \
+  '--no-backup[do not save backup copies of files]' \
+  '*:unapplied patch:_hg_qunapplied'
+}
+
+_hg_cmd_qgoto() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--force -f)'{-f,--force}'[overwrite any local changes]' \
+  '--keep-changes[tolerate non-conflicting local changes]' \
+  ':patch:_hg_qseries'
+}
+
+_hg_cmd_qguard() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--list -l)'{-l,--list}'[list all patches and guards]' \
+  '(--none -n)'{-n,--none}'[drop all guards]' \
+  ':patch:_hg_qseries' \
+  '*:guards:_hg_qguards'
+}
+
+_hg_cmd_qheader() {
+  _arguments -s -w : $_hg_global_opts \
+  ':patch:_hg_qseries'
+}
+
+_hg_cmd_qimport() {
+  _arguments -s -w : $_hg_global_opts $_hg_gitlike_opts \
+  '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
+  '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
+  '(--force -f)'{-f,--force}'[overwrite existing files]' \
+  '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
+  '(--push -P)'{-P,--push}'[qpush after importing]' \
+  '*:patch:_files'
+}
+
+_hg_cmd_qnew() {
+  _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
+  ':patch:'
+}
+
+_hg_cmd_qnext() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
+_hg_cmd_qpop() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--all -a :)'{-a,--all}'[pop all patches]' \
+  '(--force -f)'{-f,--force}'[forget any local changes]' \
+  '--keep-changes[tolerate non-conflicting local changes]' \
+  '--no-backup[do not save backup copies of files]' \
+  ':patch:_hg_qapplied'
+}
+
+_hg_cmd_qprev() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
+_hg_cmd_qpush() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--all -a :)'{-a,--all}'[apply all patches]' \
+  '(--list -l)'{-l,--list}'[list patch name in commit text]' \
+  '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
+  '(--exact -e)'{-e,--exact}'[apply the target patch to its recorded parent]' \
+  '--move[reorder patch series and apply only the patch]' \
+  '--keep-changes[tolerate non-conflicting local changes]' \
+  '--no-backup[do not save backup copies of files]' \
+  ':patch:_hg_qunapplied'
+}
+
+_hg_cmd_qrefresh() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts $_hg_gitlike_opts \
+  '(--short -s)'{-s,--short}'[short refresh]' \
+  '*:files:_hg_files'
+}
+
+_hg_cmd_qrename() {
+  _arguments -s -w : $_hg_global_opts \
+  ':patch:_hg_qunapplied' \
+  ':destination:'
+}
+
+_hg_cmd_qselect() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--none -n :)'{-n,--none}'[disable all guards]' \
+  '(--series -s :)'{-s,--series}'[list all guards in series file]' \
+  '--pop[pop to before first guarded applied patch]' \
+  '--reapply[pop and reapply patches]' \
+  '*:guards:_hg_qguards'
+}
+
+_hg_cmd_qseries() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
+  '(--missing -m)'{-m,--missing}'[print patches not in series]'
+}
+
+_hg_cmd_qunapplied() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
+  '(--first -1)'{-1,--first}'[show only the first patch]'
+}
+
+_hg_cmd_qtop() {
+  _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
+}
+
+_hg_cmd_strip() {
+  _arguments -s -w : $_hg_global_opts \
+  '(--force -f)'{-f,--force}'[force removal, discard uncommitted changes, no backup]' \
+  '(--no-backup -n)'{-n,--no-backup}'[no backups]' \
+  '(--keep -k)'{-k,--keep}'[do not modify working copy during strip]' \
+  '(--bookmark -B)'{-B+,--bookmark}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks' \
+  '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
+  ':revision:_hg_labels'
+}
+
+# Patchbomb
+_hg_cmd_email() {
+  _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_gitlike_opts \
+  '--plain[omit hg patch header]' \
+  '--body[send patches as inline message text (default)]' \
+  '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
+  '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
+  '--bundlename[name of the bundle attachment file (default: bundle)]:' \
+  '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
+  '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
+  '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
+  '--intro[send an introduction email for a single patch]' \
+  '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
+  '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
+  '*--bcc[email addresses of blind carbon copy recipients]:email:' \
+  '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
+  '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
+  '--date[use the given date as the sending date]:date:' \
+  '--desc[use the given file as the series description]:files:_files' \
+  '(--from -f)'{-f,--from}'[email address of sender]:email:' \
+  '(--test -n)'{-n,--test}'[print messages that would be sent]' \
+  '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
+  '*--reply-to[email addresses replies should be sent to]:email:' \
+  '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
+  '--in-reply-to[message identifier to reply to]:msgid:' \
+  '*--flag[flags to add in subject prefixes]:flag:' \
+  '*'{-t,--to}'[email addresses of recipients]:email:' \
+  ':revision:_hg_revrange'
+}
+
+# Rebase
+_hg_cmd_rebase() {
+  _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_mergetool_opts \
+  '*'{-r,--rev}'[rebase these revisions]:revision:_hg_revrange' \
+  '(--source -s)'{-s+,--source}'[rebase from the specified changeset]:revision:_hg_labels' \
+  '(--base -b)'{-b+,--base}'[rebase from the base of the specified changeset]:revision:_hg_labels' \
+  '(--dest -d)'{-d+,--dest}'[rebase onto the specified changeset]:revision:_hg_labels' \
+  '--collapse[collapse the rebased changeset]' \
+  '--keep[keep original changeset]' \
+  '--keepbranches[keep original branch name]' \
+  '(--continue -c)'{-c,--continue}'[continue an interrupted rebase]' \
+  '(--abort -a)'{-a,--abort}'[abort an interrupted rebase]' \
+}
+
+# Record
+_hg_cmd_record() {
+  _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_pat_opts \
+                     $_hg_ignore_space_opts $_hg_subrepos_opts \
+  '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
+  '--close-branch[mark a branch as closed, hiding it from the branch list]' \
+  '--amend[amend the parent of the working dir]' \
+  '(--date -d)'{-d+,--date}'[record the specified date as commit date]:date:' \
+  '(--user -u)'{-u+,--user}'[record the specified user as committer]:user:'
+}
+
+_hg_cmd_qrecord() {
+  _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
+                     $_hg_pat_opts $_hg_ignore_space_opts $_hg_subrepos_opts
+}
+
+# Convert
+_hg_cmd_convert() {
+_arguments -s -w : $_hg_global_opts \
+  '(--source-type -s)'{-s,--source-type}'[source repository type]' \
+  '(--dest-type -d)'{-d,--dest-type}'[destination repository type]' \
+  '(--rev -r)'{-r+,--rev}'[import up to target revision]:revision:' \
+  '(--authormap -A)'{-A+,--authormap}'[remap usernames using this file]:file:_files' \
+  '--filemap[remap file names using contents of file]:file:_files' \
+  '--splicemap[splice synthesized history into place]:file:_files' \
+  '--branchmap[change branch names while converting]:file:_files' \
+  '--branchsort[try to sort changesets by branches]' \
+  '--datesort[try to sort changesets by date]' \
+  '--sourcesort[preserve source changesets order]'
+}
+
+# Graphlog
+_hg_cmd_glog() {
+  _hg_cmd_log $@
+}
+
+# Purge
+_hg_cmd_purge() {
+  _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
+  '(--abort-on-err -a)'{-a,--abort-on-err}'[abort if an error occurs]' \
+  '--all[purge ignored files too]' \
+  '(--print -p)'{-p,--print}'[print filenames instead of deleting them]' \
+  '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs (implies -p/--print)]'
+}
+
+_hg "$@"
diff --git a/zsh/directory.zsh b/zsh/directory.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/directory.zsh
@@ -0,0 +1,26 @@
+#
+# Directory
+#
+
+#
+# Options
+#
+
+setopt auto_cd              # Auto changes to a directory without typing cd.
+setopt auto_pushd           # Push the old directory onto the stack on cd.
+setopt pushd_ignore_dups    # Do not store duplicates in the stack.
+setopt pushd_silent         # Do not print the directory stack after pushd or popd.
+setopt pushd_to_home        # Push to home directory when no argument is given.
+setopt cdable_vars          # Change directory to a path stored in a variable.
+setopt auto_name_dirs       # Auto add variable-stored paths to ~ list.
+setopt multios              # Write to multiple descriptors.
+setopt extended_glob        # Use extended globbing syntax.
+unsetopt clobber            # Do not overwrite existing files with > and >>.
+                            # Use >! and >>! to bypass.
+
+#
+# Aliases
+#
+
+alias d='dirs -v'
+for index ({1..9}) alias "$index"="cd +${index}"; unset index
diff --git a/zsh/editor.zsh b/zsh/editor.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/editor.zsh
@@ -0,0 +1,89 @@
+#
+# Command Line Editor
+#
+
+# Allow command line editing in an external editor.
+autoload -Uz edit-command-line
+zle -N edit-command-line
+
+#
+# Functions
+#
+
+# Inserts 'sudo ' at the beginning of the line.
+function prepend-sudo {
+    if [[ "$BUFFER" != su(do|)\ * ]]; then
+        BUFFER="sudo $BUFFER"
+        (( CURSOR += 5 ))
+    fi
+}
+zle -N prepend-sudo
+
+# Displays an indicator when completing.
+function expand-or-complete-with-dots {
+  print -Pn "%F{red}......%f"
+  zle expand-or-complete
+  zle redisplay
+}
+zle -N expand-or-complete-with-dots
+
+# This was written entirely by Mikael Magnusson (Mikachu)
+# Basically type '...' to get '../..' with successive .'s adding /..
+function rationalise-dot {
+    local MATCH # keep the regex match from leaking to the environment
+    if [[ $LBUFFER =~ '(^|/| |      |'$'\n''|\||;|&)\.\.$' ]]; then
+        LBUFFER+=/
+        zle self-insert
+        zle self-insert
+    else
+        zle self-insert
+    fi
+}
+zle -N rationalise-dot
+
+# Cycle through local history only
+up-line-or-local-history() {
+    zle set-local-history 1
+    zle up-line-or-history
+    zle set-local-history 0
+}
+zle -N up-line-or-local-history
+down-line-or-local-history() {
+    zle set-local-history 1
+    zle down-line-or-history
+    zle set-local-history 0
+}
+zle -N down-line-or-local-history
+
+#
+#  Key bindings
+#
+
+# Use Emacs editing mode, and recongize modifiers
+bindkey -e
+
+# C-right and C-left: jump words (human-friendly keys are not recognized!)
+bindkey "^[[1;5C" emacs-forward-word
+bindkey "^[[1;5D" emacs-backward-word
+
+# Alt-S: insert 'sudo ' at the beginning of the line
+bindkey "\es" prepend-sudo
+
+# C-x C-e: edit the command line in an editor
+bindkey "\C-x\C-e" edit-command-line
+
+# Displays an indicator when completing
+bindkey "\C-I" expand-or-complete-with-dots
+
+# ... -> ../..
+# Then, every subsequent . inserts /..
+bindkey . rationalise-dot
+# without this, typing a . aborts incremental history search
+bindkey -M isearch . self-insert
+
+# Ctrl-p/n cycles through local history only
+bindkey '^p' up-line-or-local-history
+bindkey '^n' down-line-or-local-history
+
+# Bind Shift + Tab to go to the previous menu item.
+bindkey "^[[Z" reverse-menu-complete
diff --git a/zsh/history.zsh b/zsh/history.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/history.zsh
@@ -0,0 +1,35 @@
+#
+# History
+#
+
+#
+# Variables
+#
+
+HISTFILE="${ZDOTDIR:-$HOME}/.zhistory"       # The path to the history file.
+HISTSIZE=10000                   # The maximum number of events to save in the internal history.
+SAVEHIST=10000                   # The maximum number of events to save in the history file.
+
+#
+# Options
+#
+
+setopt bang_hist                 # Treat the '!' character specially during expansion.
+setopt extended_history          # Write the history file in the ':start:elapsed;command' format.
+setopt inc_append_history        # Write to the history file immediately, not when the shell exits.
+setopt share_history             # Share history between all sessions.
+setopt hist_expire_dups_first    # Expire a duplicate event first when trimming history.
+setopt hist_ignore_dups          # Do not record an event that was just recorded again.
+setopt hist_ignore_all_dups      # Delete an old recorded event if a new event is a duplicate.
+setopt hist_find_no_dups         # Do not display a previously found event.
+setopt hist_ignore_space         # Do not record an event starting with a space.
+setopt hist_save_no_dups         # Do not write a duplicate event to the history file.
+setopt hist_verify               # Do not execute immediately upon history expansion.
+setopt hist_beep                 # Beep when accessing non-existent history.
+
+#
+# Aliases
+#
+
+# Lists the ten most used commands
+alias history-stats="history 0 | awk '{print \$2}' | sort | uniq -c | sort -n -r | head"
diff --git a/zsh/programs.zsh b/zsh/programs.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/programs.zsh
@@ -0,0 +1,79 @@
+#
+# Program-specific settings
+#
+
+# Correct commands
+setopt correct
+
+# ls
+eval "$(dircolors)"
+alias ls="ls --color=auto --group-directories-first"
+alias l=ls
+alias lh="ls -lh"
+alias ll="ls -l"
+alias la="ls -A"
+
+# grep
+alias grep='grep --color=auto'
+
+# less
+export LESS='-i -M -R -w -z-2'
+
+# Set the less input preprocessor
+# pless (pretty less) is less with syntax hilighting
+# requies the source-highlight package
+if (( $+commands[lesspipe] )); then
+    export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-'
+    alias pless='LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" less '
+fi
+
+# virtualenvwrapper
+export VIRTUAL_ENV_DISABLE_PROMPT=1
+if [ -r /etc/bash_completion.d/virtualenvwrapper ]; then
+    source /etc/bash_completion.d/virtualenvwrapper
+fi
+
+# pip
+export PATH=~/.local/bin:$PATH
+
+# rvm
+if [ -x $HOME/.rvm/scripts/rvm ]; then
+    source $HOME/.rvm/scripts/rvm
+fi
+export PATH=$HOME/.rvm/bin:$PATH
+
+# grails
+if [ -x $HOME/local/software/grails/bin/grails ]; then
+   export GRAILS_HOME=$HOME/local/software/grails
+   export PATH=$PATH:$GRAILS_HOME/bin
+fi
+
+# Emacs
+alias e="emacsclient -a '' -t"
+alias ew="emacsclient -a '' -c --no-wait"
+
+ediff() {
+    if (($+2)); then
+        emacs --eval "(ediff-files \"$1\" \"$2\")"
+    else
+        echo "Usage: ediff <file-1> <file-2>"
+    fi
+}
+
+# EDITOR
+export EDITOR="emacsclient -a '' -t"
+export VISUAL="emacsclient -a '' -t"
+
+# Apt
+upd() {
+    echo "Reloading sources.."
+    sudo aptitude update > /dev/null
+    n=$(apt-show-versions -u | wc -l)
+    echo "$n updates available"
+}
+
+# Global aliases
+alias -g G="| grep -i"
+alias -g L="| less -R"
+alias -g C="| wc -l"
+alias -g T="| tail"
diff --git a/zsh/prompt.zsh b/zsh/prompt.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/prompt.zsh
@@ -0,0 +1,12 @@
+#
+# Prompt
+#
+
+# Add themes to $fpath
+fpath=($ZSHROOT/themes(/FN) $fpath)
+
+# Load and execute the prompt theming system
+autoload -Uz promptinit && promptinit
+
+# Activate theme
+prompt akhayyat
diff --git a/zsh/terminal.zsh b/zsh/terminal.zsh
new file mode 100644
--- /dev/null
+++ b/zsh/terminal.zsh
@@ -0,0 +1,10 @@
+#
+# Terminal Support
+#
+
+# set xterm title to user@host:pwd
+function terminal_title() {
+    print -Pn "\e]2;%n@%m:%~\a"
+}
+autoload -Uz add-zsh-hook
+add-zsh-hook precmd terminal_title
diff --git a/zsh/themes/prompt_akhayyat_setup b/zsh/themes/prompt_akhayyat_setup
new file mode 100644
--- /dev/null
+++ b/zsh/themes/prompt_akhayyat_setup
@@ -0,0 +1,126 @@
+#
+# Screenshot:
+#   http://i.imgur.com/jmOES.png
+#
+# Dependencies:
+#   git
+#   mercurial
+#   hg-prompt (https://bitbucket.org/sjl/hg-prompt)
+#
+
+function prompt_akhayyat_precmd {
+    vcs_info 'prompt'
+}
+
+function prompt_akhayyat_setup {
+    prompt_opts=(cr percent subst)
+
+    # Load required functions.
+    autoload -Uz add-zsh-hook
+    autoload -Uz vcs_info
+
+    # Use extended color pallete if available.
+    if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
+        orange="166"
+    else
+        orange="yellow"
+    fi
+
+    # Add hook for calling *-info before each command.
+    add-zsh-hook precmd prompt_akhayyat_precmd
+
+    # Set vcs_info parameters.
+    zstyle ':vcs_info:*' enable git
+    zstyle ':vcs_info:*:prompt:*' check-for-changes true
+    zstyle ':vcs_info:*:prompt:*' stagedstr "%F{green}●%f"
+    zstyle ':vcs_info:*:prompt:*' unstagedstr "%F{$orange}●%f"
+    zstyle ':vcs_info:*:prompt:*' formats " on ±%F{cyan}%r%f/%F{yellow}%b%f %c%u %m"
+    zstyle ':vcs_info:*:prompt:*' actionformats " on ±%F{cyan}%r%f/%F{yellow}%b%f in %a %c%u %m"
+    zstyle ':vcs_info:*:prompt:*' nvcsformats   ""
+    zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st
+
+    # Define prompts.
+    PROMPT="
+%F{magenta}%n%f@%F{magenta}%m%f:%F{cyan}%~%f"'$(hg_prompt_1)${vcs_info_msg_0_}$(hg_prompt_2)$(virtualenv_prompt)$(rvm_prompt)
+» '
+
+    RPROMPT="%B%F{black}%D{%Y.%m.%d %a  %I:%M %P}%f%b"
+}
+
+function hg_prompt_1 {
+    hg prompt --angle-brackets "\
+ <on ☿<%F{cyan}<root|basename>%f/>%F{yellow}<branch>%f>\
+<:%F{$orange}<bookmark>%f>\
+ at %F{green}<rev>%f\
+<:%F{green}<tags>%f>\
+<%F{$orange}<status|modified>%f>\
+<%F{red}<status|unknown>%f>\
+<update>\
+< %F{yellow}↑%f:%F{yellow}<outgoing|count>%f>\
+< %F{$orange}↓%f:%F{$orange}<incoming|count>%f>" 2>/dev/null
+}
+
+function hg_prompt_2 {
+    mq=$(hg prompt --angle-brackets "<
+patches: <patches|join( → )|pre_applied(%F{$orange})|post_applied(%f)|\
+pre_unapplied(%B%F{black})|post_unapplied(%f%b)>>" 2>/dev/null)
+
+    if [ $mq ]; then
+        mq="$mq"$(hg prompt --mq --angle-brackets "\
+ <on %F{yellow}<branch>%f>\
+<:%F{$orange}<bookmark>%f>\
+ at %F{green}<rev>%f\
+<:%F{green}<tags>%f>\
+<%F{$orange}<status|modified>%f>\
+<%F{red}<status|unknown>%f>\
+<update>\
+< %F{yellow}↑%f<outgoing>>\
+< %F{$orange}↓%f<incoming>>" 2>/dev/null)
+    fi
+
+    echo $mq
+}
+
+function virtualenv_prompt {
+    if [ $VIRTUAL_ENV ]; then
+        echo ' ('`basename $VIRTUAL_ENV`')'
+    fi
+}
+
+function rvm_prompt {
+    if (( $+commands[rvm-prompt] )); then
+        rvm_version=$(rvm-prompt)
+        if [[ -n $rvm_version ]]; then
+            echo ' ('`rvm-prompt`')'
+        fi
+    fi
+}
+
+function +vi-git-untracked {
+    if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
+        git status --porcelain | grep '??' &> /dev/null ; then
+        hook_com[unstaged]+="%F{red}●%f"
+    fi
+}
+
+function +vi-git-st() {
+    local ahead behind ahead_and_behind
+    local -a gitstatus
+
+    ahead_and_behind=$(git rev-list --count --left-right HEAD...@{upstream} 2>/dev/null)
+    ahead=$ahead_and_behind[(w)1]
+    behind=$ahead_and_behind[(w)2]
+
+    (( $ahead )) && gitstatus+=( "%F{yellow}↑%f" )
+    (( $behind )) && gitstatus+=( "%F{$orange}↓%f" )
+
+    hook_com[misc]+=${(j:/:)gitstatus}
+}
+
+prompt_akhayyat_help(){
+  cat <<EOF
+akhayyat's prompt
+EOF
+}
+
+prompt_akhayyat_setup "$@"
diff --git a/zsh/zshrc b/zsh/zshrc
new file mode 100644
--- /dev/null
+++ b/zsh/zshrc
@@ -0,0 +1,14 @@
+ZSHROOT=$HOME/.dotfiles/zsh
+
+source $ZSHROOT/terminal.zsh
+source $ZSHROOT/history.zsh
+source $ZSHROOT/syntax-highlighting.zsh
+source $ZSHROOT/history-substring-search.zsh
+source $ZSHROOT/editor.zsh
+source $ZSHROOT/directory.zsh
+source $ZSHROOT/programs.zsh
+source $ZSHROOT/completion.zsh
+source $ZSHROOT/prompt.zsh
+source $ZSHROOT/agents.zsh
+
+unset ZSHROOT