Merge branch 'master' of github.com:samsonjs/config

This commit is contained in:
Sami Samhuri 2009-12-16 13:20:54 -08:00
commit 1e95d3b6a2
5 changed files with 334 additions and 569 deletions

21
emacs
View file

@ -140,6 +140,8 @@
(autoload 'js2-mode "js2-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode))
(add-hook 'js2-mode-hook '(lambda ()
(local-set-key "\C-m" 'newline)))
(autoload #'espresso-mode "espresso" "Start espresso-mode" t)
;;(add-to-list 'auto-mode-alist '("\\.js$" . espresso-mode))
@ -159,6 +161,22 @@
(mojo-setup-mode-hooks 'css-mode-hook 'js2-mode-hook 'espresso-mode-hook 'html-mode-hook)
;;;;;;;;;;;;;;;;;;;;;;;;;
;; inferior javascript ;;
;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'js-comint)
;(setq inferior-js-program-command "/usr/local/bin/v8")
(setq inferior-js-program-command "/opt/local/bin/js -v 1.8")
(add-hook 'js2-mode-hook '(lambda ()
(local-set-key "\C-x\C-e" 'js-send-last-sexp)
(local-set-key "\C-\M-x" 'js-send-last-sexp-and-go)
(local-set-key "\C-cb" 'js-send-buffer)
(local-set-key "\C-c\C-b" 'js-send-buffer-and-go)
(local-set-key "\C-cl" 'js-load-file-and-go)
))
;;;;;;;;;;;;
;; markup ;;
;;;;;;;;;;;;
@ -242,6 +260,7 @@
(global-set-key "\C-zr" 'query-replace-regexp)
(global-set-key "\C-z\C-r" 'reload-dot-emacs)
(global-set-key "\C-zc" 'comment-line)
(global-set-key "\C-zj" 'run-js)
(global-set-key "\C-zs" 'run-scheme)
(global-set-key "\C-z\C-t" 'totd)
(global-set-key [f5] 'compile)
@ -381,6 +400,8 @@
'(icicle-reminder-prompt-flag 5)
'(js2-bounce-indent-p t)
'(js2-highlight-level 3)
'(js2-mode-escape-quotes nil)
'(js2-strict-inconsistent-return-warning nil)
'(mojo-build-directory "~/Projects/brighthouse/webOS/build")
'(mojo-debug t)
'(mojo-project-directory "~/Projects/brighthouse/webOS")

209
emacs.d/js-comint.el Normal file
View file

@ -0,0 +1,209 @@
;;; js-comint.el --- Run javascript in an inferior process window.
;;; Copyright (C) 2008 Paul Huff
;;; Author: Paul Huff <paul.huff@gmail.com>
;;; Maintainer: Paul Huff <paul.huff@gmail.com>
;;; Created: 26 May 2008
;;; Version: 0.0.1
;;; Package-Requires: ()
;;; Keywords: javascript, inferior-mode, convenience
;; js-comint.el 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, or
;; {at your option} any later version.
;; js-comint.el 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 GNU Emacs; see the file COPYING, or type `C-h C-c'. If
;; not, write to the Free Software Foundation at this address:
;; Free Software Foundation
;; 51 Franklin Street, Fifth Floor
;; Boston, MA 02110-1301
;; USA
;;; Commentary:
;;; js-comint.el let's you run an inferior javascript process in emacs,
;;; and defines a few functions for sending javascript input to it quickly.
;; Usage:
;; Put js-comint.el in your load path
;; Add (require 'js-comint) to your .emacs
;; Set inferior-js-program-command to the execution command for running your javascript REPL
;; (setq inferior-js-program-command "/path/to/executable <args>")
;; Do: M-x run-js
;; Away you go.
;; I've added the following couple of lines to my .emacs to take advantage of
;; cool keybindings for sending things to the javascript interpreter inside
;; of Steve Yegge's most excellent js2-mode.
;; (add-hook 'js2-mode-hook '(lambda ()
;; (local-set-key "\C-x\C-e" 'js-send-last-sexp)
;; (local-set-key "\C-\M-x" 'js-send-last-sexp-and-go)
;; (local-set-key "\C-cb" 'js-send-buffer)
;; (local-set-key "\C-c\C-b" 'js-send-buffer-and-go)
;; (local-set-key "\C-cl" 'js-load-file-and-go)
;; ))
;; This is version 0.0.1, so I've only tested it on my own version of emacs which is currently:
;; GNU Emacs 22.0.90.1 (i386-apple-darwin8.8.1, Carbon Version 1.6.0) of 2006-10-28
;; Not sure if it'll work anywhere else, but it doesn't require anything apple-ish, just emacs-ish.
;; Additionally, I've only tested this with rhino. I'm sure it'll probably work with spidermonkey,
;; though if it barfs let me know, and I'll update it.
;; I'm a newbie elisper, so please let me know if I'm a. doing things the wrong way, b.
;; making things work they way they shouldn't in the elisp world.
;;; History:
;;
;;; Code:
(require 'comint)
(provide 'js-comint)
(defcustom inferior-js-program-command "/usr/bin/java org.mozilla.javascript.tools.shell.Main" "Path to the javascript interpreter")
(defgroup inferior-js nil
"Run a javascript process in a buffer."
:group 'inferior-js)
(defcustom inferior-js-mode-hook nil
"*Hook for customizing inferior-js mode."
:type 'hook
:group 'inferior-js)
;;;###autoload
(defun run-js (cmd &optional dont-switch-p)
"Run an inferior Javascript process, input and output via buffer `*js*'.
If there is a process already running in `*js*', switch to that buffer.
With argument, allows you to edit the command line (default is value
of `inferior-js-program-command').
Runs the hook `inferior-js-mode-hook' \(after the `comint-mode-hook'
is run).
\(Type \\[describe-mode] in the process buffer for a list of commands.)"
(interactive (list (if current-prefix-arg
(read-string "Run js: " inferior-js-program-command)
inferior-js-program-command)))
(if (not (comint-check-proc "*js*"))
(save-excursion (let ((cmdlist (split-string cmd)))
(set-buffer (apply 'make-comint "js" (car cmdlist)
nil (cdr cmdlist)))
(inferior-js-mode))))
(setq inferior-js-program-command cmd)
(setq inferior-js-buffer "*js*")
(if (not dont-switch-p)
(pop-to-buffer "*js*")))
;;;###autoload
(defun js-send-region (start end)
"Send the current region to the inferior Javascript process."
(interactive "r")
(run-js inferior-js-program-command t)
(comint-send-region inferior-js-buffer start end)
(comint-send-string inferior-js-buffer "\n"))
;;;###autoload
(defun js-send-region-and-go (start end)
"Send the current region to the inferior Javascript process."
(interactive "r")
(run-js inferior-js-program-command t)
(comint-send-region inferior-js-buffer start end)
(comint-send-string inferior-js-buffer "\n")
(switch-to-js inferior-js-buffer))
;;;###autoload
(defun js-send-last-sexp-and-go ()
"Send the previous sexp to the inferior Js process."
(interactive)
(js-send-region-and-go (save-excursion (backward-sexp) (point)) (point)))
;;;###autoload
(defun js-send-last-sexp ()
"Send the previous sexp to the inferior Javascript process."
(interactive)
(js-send-region (save-excursion (backward-sexp) (point)) (point)))
;;;###autoload
(defun js-send-buffer ()
"Send the buffer to the inferior Javascript process."
(interactive)
(js-send-region (point-min) (point-max)))
;;;###autoload
(defun js-send-buffer-and-go ()
"Send the buffer to the inferior Javascript process."
(interactive)
(js-send-region-and-go (point-min) (point-max)))
;;;###autoload
(defun js-load-file (filename)
"Load a file in the javascript interpreter."
(interactive "f")
(let ((filename (expand-file-name filename)))
(run-js inferior-js-program-command t)
(comint-send-string inferior-js-buffer (concat "load(\"" filename "\")\n"))))
;;;###autoload
(defun js-load-file-and-go (filename)
"Load a file in the javascript interpreter."
(interactive "f")
(let ((filename (expand-file-name filename)))
(run-js inferior-js-program-command t)
(comint-send-string inferior-js-buffer (concat "load(\"" filename "\")\n"))
(switch-to-js inferior-js-buffer)))
;;;###autoload
(defun switch-to-js (eob-p)
"Switch to the javascript process buffer.
With argument, position cursor at end of buffer."
(interactive "P")
(if (or (and inferior-js-buffer (get-buffer inferior-js-buffer))
(js-interactively-start-process))
(pop-to-buffer inferior-js-buffer)
(error "No current process buffer. See variable `inferior-js-buffer'"))
(when eob-p
(push-mark)
(goto-char (point-max))))
(defvar inferior-js-buffer)
(defvar inferior-js-mode-map
(let ((m (make-sparse-keymap)))
(define-key m "\C-x\C-e" 'js-send-last-sexp)
(define-key m "\C-cl" 'js-load-file)
m))
;;;###autoload
(define-derived-mode inferior-js-mode comint-mode "Inferior Javascript"
"Major mode for interacting with an inferior javascript process.
The following commands are available:
\\{inferior-js-mode-map}
A javascript process can be fired up with M-x run-js.
Customization: Entry to this mode runs the hooks on comint-mode-hook and
inferior-js-mode-hook (in that order).
You can send text to the inferior Javascript process from othber buffers containing
Javascript source.
switch-to-js switches the current buffer to the Javascript process buffer.
js-send-region sends the current region to the Javascript process.
"
(use-local-map inferior-js-mode-map)
)

View file

@ -1,6 +1,6 @@
;;; mojo.el --- Interactive functions for webOS development
;; 2009-12-07 14:28:52
(defconst mojo-version "0.9.10")
;; 2009-12-08 22:12:37
(defconst mojo-version "1.0.0b")
(require 'json)
@ -84,7 +84,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
;; * C-c C-c n -- mojo-switch-to-next-view
;; * C-c C-c s -- mojo-switch-to-sources
;; * C-c C-c S -- mojo-switch-to-stylesheet
;; * C-c C-c v -- mojo-switch-to-view
;; * C-c C-c v -- mojo-switch-to-last-view
;; * C-c C-c SPC -- mojo-switch-file-dwim
;; * C-c C-c C-d -- mojo-target-device
;; * C-c C-c C-e -- mojo-emulate
@ -163,13 +163,17 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
;; mojo-switch-to-assistant
;; Switch to the corresponding assistant from any view file.
;;
;; mojo-switch-to-view
;; mojo-switch-to-main-view
;; Switch to the main view from an assistant.
;;
;; mojo-switch-to-next-view
;; Switch to the next view file, alphabetically. Wraps around at the
;; end.
;;
;; mojo-switch-to-last-view
;; Switch to the last visited view buffer (excluding the current
;; buffer).
;;
;; mojo-switch-to-appinfo
;; Switch to the appinfo.json file.
;;
@ -182,6 +186,10 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
;; mojo-switch-to-stylesheet
;; Switch to the main stylesheet.
;;
;; mojo-switch-file-dwim
;; Switch to the next view from a view, and to the main view from an
;; assistant. From any other file switch to appinfo.json.
;;
;;
;; Manage framework_config.json
;; ----------------------------
@ -201,12 +209,15 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
;; mojo-log-level
;; See the log level.
;;
;; mojo-html-escaped-in-templates-p
;; mojo-escape-html-in-templates-p
;; See if HTML is escaped in templates.
;;
;; mojo-set-debugging-enabled
;; Enable or disable debugging.
;;
;; mojo-toggle-debugging
;; Toggle debugging in framework_config.json.
;;
;; mojo-set-log-events
;; Enable or disable event logging.
;;
@ -374,7 +385,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
* C-c C-c n -- \\[mojo-switch-to-next-view]
* C-c C-c s -- \\[mojo-switch-to-sources]
* C-c C-c S -- \\[mojo-switch-to-stylesheet]
* C-c C-c v -- \\[mojo-switch-to-view]
* C-c C-c v -- \\[mojo-switch-to-last-view]
* C-c C-c SPC -- \\[mojo-switch-file-dwim]
* C-c C-c C-d -- \\[mojo-target-device]
* C-c C-c C-e -- \\[mojo-emulate]
@ -397,7 +408,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.")
("\C-c\C-cn" . mojo-switch-to-next-view)
("\C-c\C-cs" . mojo-switch-to-sources)
("\C-c\C-cS" . mojo-switch-to-stylesheet)
("\C-c\C-cv" . mojo-switch-to-view)
("\C-c\C-cv" . mojo-switch-to-last-view)
("\C-c\C-c " . mojo-switch-file-dwim)
("\C-c\C-c\C-d" . mojo-target-device)
("\C-c\C-c\C-e" . mojo-emulate)
@ -512,10 +523,8 @@ NAME is the name of the scene."
(mojo-cmd-with-target "palm-install" (list "-r" (mojo-read-app-id)))
(mojo-invalidate-app-cache))
;;* interactive
(defun mojo-ensure-emulator-is-running ()
"Launch the current application, and the emulator if necessary."
(interactive)
"Launch the emulator unless it is already running."
(if (string= "tcp" *mojo-target*)
(progn
(when (not (mojo-emulator-running-p))
@ -540,14 +549,15 @@ NAME is the name of the scene."
(mojo-ensure-emulator-is-running)
(mojo-cmd-with-target "palm-launch" (list "-c" (mojo-read-app-id))))
;;* launch interactive
;;* interactive
(defun mojo-inspect ()
"Run the DOM inspector on the current application."
(interactive)
(mojo-ensure-emulator-is-running)
(mojo-set-log-level-for-debugging)
(mojo-cmd-with-target "palm-launch" (list "-i" (mojo-read-app-id))))
;;* emulator interactive
;;* interactive
(defun mojo-hard-reset ()
"Perform a hard reset, clearing all data."
(interactive)
@ -966,11 +976,13 @@ If the cache file does not exist then it is considered stale."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defvar *mojo-switch-suffixes*
'(("-assistant.js" . mojo-switch-to-view)
("-scene.html" . mojo-switch-to-assistant)
'(("-assistant.js" . mojo-switch-to-last-view)
(".html" . mojo-switch-to-next-view)
("" . mojo-switch-to-appinfo))
"Suffixes of files that we can guess where to switch.")
"Suffixes of files that we can switch from and where to switch, with catch-all to appinfo.json by default.")
(defvar *mojo-last-visited-view* nil
"Path of the last visited view file.")
;;* interactive
(defun mojo-switch-to-appinfo ()
@ -1009,17 +1021,37 @@ If the cache file does not exist then it is considered stale."
"The parent directory's basename."
(mojo-filename (mojo-parent-directory path)))
(defun mojo-current-filename ()
"Return the filename part of the current buffer's path."
(mojo-filename (buffer-file-name)))
(defun mojo-buffer-is-assistant-p ()
"Determine if the current buffer is a scene assistant."
(string= "assistants" (mojo-parent-directory-name (buffer-file-name))))
(defun mojo-scene-name-from-assistant ()
"The scene name of the assistant being edited."
(let ((path (buffer-file-name)))
(and (string= "assistants" (mojo-parent-directory-name path))
(substring (mojo-filename path) 0 (- 0 (length "-assistant.js"))))))
(and (mojo-buffer-is-assistant-p)
(substring (mojo-current-filename) 0 (- 0 (length "-assistant.js")))))
(defun mojo-path-is-view-p (path)
"Determine if the given path is a Mojo view."
(string= "views" (mojo-parent-directory-name (mojo-parent-directory path))))
(defun mojo-buffer-is-view-p ()
"Determine if the current buffer is a view."
(mojo-path-is-view-p (buffer-file-name)))
(defun mojo-buffer-is-main-view-p ()
"Determine if the current buffer is the main view of a scene."
(and (mojo-buffer-is-view-p)
(string= (concat (mojo-scene-name-from-view) "-scene.html")
(mojo-current-filename))))
(defun mojo-scene-name-from-view ()
"The scene name of the view being edited."
(let ((path (buffer-file-name)))
(and (string= "views" (mojo-parent-directory-name (mojo-parent-directory path)))
(mojo-parent-directory-name path))))
(and (mojo-buffer-is-view-p)
(mojo-parent-directory-name (buffer-file-name))))
;;* interactive
(defun mojo-switch-file-dwim ()
@ -1040,28 +1072,56 @@ if you want different behaviour."
(when switch-function
(call-interactively switch-function))))
;;* interactive
(defun mojo-switch-to-view ()
"Switch to the corresponding main view from an assistant."
(interactive)
(when (mojo-project-p)
(let ((scene-name (mojo-scene-name-from-assistant)))
(find-file (concat (mojo-root)
"/app/views/" scene-name "/"
scene-name "-scene.html")))))
(defun mojo-buffer-is-scene-file-p ()
"Determine if the current buffer belongs to a Mojo scene."
(or (mojo-buffer-is-view-p)
(mojo-buffer-is-assistant-p)))
(defun mojo-ignored-path (path)
;;* interactive
(defun mojo-switch-to-main-view ()
"Switch to the corresponding main view from an assistant or any other view in the scene."
(interactive)
(when (and (mojo-project-p) (mojo-buffer-is-scene-file-p))
(let* ((scene-name (mojo-scene-name)))
(setq *mojo-last-visited-view* (concat (mojo-root)
"/app/views/" scene-name "/"
scene-name "-scene.html")))
(find-file *mojo-last-visited-view*)))
(defun mojo-visited-view-paths ()
"Return a list of all visited view paths, most recently visited first."
(mojo-filter-paths (mapcar (function buffer-file-name) (buffer-list))
(lambda (path) (or (null path) (not (mojo-path-is-view-p path))))))
;;* interactive
(defun mojo-switch-to-last-view ()
"Switch to the last visited view from another view or assistant.
If there no view can be found then the action depends on the
current buffer. From an assistant you are taken to the main
view, from the main view you go to the next view, and from any
other view you go to the main view. Any other file is a no op."
(interactive)
(let* ((view-paths (mojo-visited-view-paths))
(last-view-path (if (string= (buffer-file-name) (car view-paths))
(cadr view-paths)
(car view-paths))))
(when last-view-path (find-file last-view-path))))
(defun mojo-ignored-path-p (path)
"Paths that we don't want to look at when walking directories."
(let ((filename (mojo-filename path)))
(or (string= (substring filename 0 1) ".") ;; "." and ".." and hidden files
(or (null filename)
(string= (substring filename 0 1) ".") ;; "." and ".." and hidden files
(and (string= (substring filename 0 1) "#") ;; emacs recovery files
(string= (substring filename -1) "#")))))
(string= (substring filename -1) "#")))))
(defun mojo-filter-paths (all-paths)
(defun mojo-filter-paths (all-paths &optional filter)
"Filter out unimportant paths from a list of paths."
(let ((wanted-paths (list)))
(let ((wanted-paths (list))
(filter (or filter 'mojo-ignored-path-p)))
(dolist (path all-paths wanted-paths)
(unless (mojo-ignored-path path)
(unless (funcall filter path)
(setq wanted-paths (cons path wanted-paths))))
(reverse wanted-paths)))
@ -1074,15 +1134,20 @@ if you want different behaviour."
(when (string= path elem)
(throw 'break index))))))
(defun mojo-scene-name ()
"Get the name of the current Mojo scene, or nil if not a scene file."
(or (mojo-scene-name-from-view)
(mojo-scene-name-from-assistant)))
;;* interactive
(defun mojo-switch-to-next-view ()
"Switch to the next view in this scene, alphabetically. Wrap around at the end."
(interactive)
(when (mojo-project-p)
(let* ((scene-name (mojo-scene-name-from-view))
(when (and (mojo-project-p) (mojo-buffer-is-scene-file-p))
(let* ((scene-name (mojo-scene-name))
(view-dir (concat (mojo-root) "/app/views/" scene-name))
(view-files (mojo-filter-paths (directory-files view-dir t)))
(mojo-filter-paths (directory-files (concat (mojo-root) "/app/views/" (mojo-scene-name-from-view)) t))
(mojo-filter-paths (directory-files (concat (mojo-root) "/app/views/" scene-name) t))
(index (mojo-index (buffer-file-name) view-files))
(filename (nth (mod index (length view-files)) view-files)))
(find-file filename))))

View file

@ -1 +0,0 @@
zshrc

View file

@ -1,529 +0,0 @@
# contents: zsh(1) user RC file.
# this file is sourced by all interactive shells
# 1. Environment Vars {{{1
# ====================
# (sh|c)ould be set in .zshenv but /etc/zprofile blows $PATH away on Gentoo
export LC_ALL="en_CA.UTF-8"
export LANG="en_CA.UTF-8"
# include my script directory in the path
path=($HOME/bin /usr/local/bin /usr/local/sbin $path)
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
cdpath=(~)
HOSTNAME=`hostname -s`
source /sw/bin/init.sh
KEYCHAIN_HOST=`hostname`
# make Esc-h show individual zshbuiltins entries
#HELPDIR=~/.zsh/help
#unalias run-help
#autoload -U run-help
if [[ `uname` = "Linux" ]]; then
export JAVA="/opt/blackdown-jdk-1.4.2/bin/java"
export JAVA_HOME="/opt/blackdown-jdk-1.4.2"
fi
export PAGER="/usr/bin/less"
# most has great colours for man pages
if which most >/dev/null 2>&1; then
export MANPAGER="/usr/bin/most"
fi
# default editors
export EDITOR="mate -w"
export VISUAL=$EDITOR
# Dynamically build the $PATH variable
#for dircomponent in /bin /sbin \
# /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin \
# /usr/games/bin /usr/X11R6/bin /usr/X11R6/sbin
# do
# if [[ -e $dircomponent ]]; then
# path=($path $dircomponent)
# fi
#done
typeset -U path # remove dups
#unset dircomponent
# 1}}}
# 2. Limits {{{1
# =========
#limit coredumpsize 30m # limit core dumps to 30mb
#limit stacksize 8m # limit stack to 8mb
# 1}}}
# 3. Shell Settings {{{1
# =================
# 3.1. Shell Directories {{{2
# ----------------------
hash -d mail=~/.maildir/
# 2}}}
# 1}}}
# 4. Shell Options {{{1
# ================
# 4.1. Parameters and Shell Functionality {{{2
# ---------------------------------------
#setopt no_globalexport # don't be backwards compatible
#setopt ignoreeof # ignore EOF ('^D') (i.e. don't log out on it)
setopt braceccl # {a-d} expands to a b c d
# 2}}}
# 4.2. Changing Directories {{{2
# -------------------------
setopt autocd # automatically cd to a directory if not cmd
setopt autopushd # automatically pushd directories on dirstack
#setopt pushdignoredups # don't push dups on stack
#setopt pushdsilent # be quiet about pushds and popds
# 2}}}
# 4.3. Shell Completion {{{2
# ---------------------
#setopt automenu # use menu completion after 2 tabs
#setopt completeinword # complete inside words
setopt correct # try to correct spelling...
setopt no_correctall # ...only for commands, not filenames
#setopt no_listambiguous # only list matches if ambiguous
setopt no_listbeep # don't beep on ambiguous listings
setopt listpacked # diff col widths = less space
# 2}}}
# 4.4. Shell Expansion and Globbing {{{2
# ---------------------------------
#setopt no_nomatch # don't generate 'no matches' error
setopt extendedglob # use extended globbing (#, ~, ^)
#setopt cshnullglob # overrides nomatch
#setopt equals # expand =cmd (on by default)
#setopt markdirs # append / to dir names generated by globbing
# 2}}}
# 4.5. History and History Expansion {{{2
# ----------------------------------
setopt extendedhistory # save timestamps in history
setopt no_histbeep # don't beep for erroneous history expansions
setopt no_histignorealldups # don't ignore dups in history
setopt histignoredups # ignore consecutive dups in history
setopt histsavenodups # don't save duplicates
setopt histnostore # don't store history related functions
#setopt incappendhistory # incrementally add items to hist.
#setopt histverify
#setopt sharehistory # imports from history file and exports (like incappendhistory)
# 2}}}
# 4.6. Job Control {{{2
# ----------------
setopt longlistjobs # list jobs in long format
#setopt no_notify # report job status only before prompt printing
# 2}}}
# 4.7. Shell Prompt {{{2
# -----------------
#setopt promptsubst # allow paramater, command, so on in prompt
# 2}}}
# 4.8. ZLE {{{2
# --------
setopt no_beep # don't beep on errors (in ZLE)
# 2}}}
# 4.9. Input and Output {{{2
# ---------------------
setopt no_flowcontrol # don't use flow control (^S/^Q)
#setopt printeightbit # allow eight bit output for completion lists
# 2}}}
# 1}}}
# 5. Terminal Settings {{{1
# ====================
# 5.1. Terminal Input {{{2
# -------------------
#stty -ixon # don't use flow control
#stty pass8 # but do send 8-bit characters to terminal
#unset TERMCAP
# 2}}}
# 5.2. Terminal Output {{{2
# --------------------
#case $TERM in
# *screen*|rxvt|*xterm|aterm) echo -e -n "\033[10;0]\033[11;0]" ;;
#esac
# 2}}}
# 5.3. Screen Title Updating {{{2
# --------------------------
function title {
if [[ $TERM == "screen" ]]; then
# Use these two for GNU Screen:
print -nR $'\033k'$1$'\033'\\\
print -nR $'\033]0;'$2$'\a'
elif [[ $TERM == "xterm" || $TERM == "rxvt" ]]; then
# Use this one instead for XTerms:
print -nR $'\033]0;'$*$'\a'
fi
}
function precmd {
title zsh "$PWD"
print -n '\017'
}
function preexec {
emulate -L zsh
local -a cmd; cmd=(${(z)1})
title $cmd[1]:t "$cmd[2,-1]"
}
# 2}}}
# 1}}}
# 6. Modules {{{1
# ==========
# 6.1. Default ZSH Modules {{{2
# ------------------------
# 2}}}
# 6.2. ZFTP {{{2
# ---------
# 2}}}
# 1}}}
# 7. Command-line Completion {{{1
# ==========================
# 7.1. Startup {{{2
# ------------
autoload -U colors # we need the colors for some formats below
colors
# 2}}}
# 7.2. Completion Styles {{{2
# ----------------------
# 7.2.1. Caching {{{3
# 3}}}
# 7.2.2. Completers {{{3
# 3}}}
# 7.2.3. Completer Options {{{3
# 3}}}
# 7.2.4. Selection Display {{{3
# 3}}}
# 7.2.5. Specific Commands {{{3
# 3}}}
# 2}}}
# 7.3. Completion Formats and Messages {{{2
# ------------------------------------
# 2}}}
# 7.4. Completion Groups {{{2
# ----------------------
# 2}}}
# 7.5. Completion Function Usage {{{2
# ------------------------------
# 2}}}
# 7.6. History Completion {{{2
# -----------------------
# 2}}}
# 1}}}
# 8. ZLE Keybindings {{{1
# ==================
# 8.1. Searching {{{2
bindkey '\ep' history-beginning-search-backward
# 2}}}
# 1}}}
# 9. Function (Auto)loading {{{1
# =========================
# 9.1. Prompt Subsystem {{{2
# ---------------------
# PROMPT SUBTITUTION
# ------------------
# %l - tty %M - full machine hostname
# %m - hostname %n - USERNAME
# %y - tty w/ prefix %# - # or $
# %? - last exit code %d,%/ - PWD
# %~ - ~ for home etc %h,%! - history event #
# %j - # of jobs
#
# %B - bold %E - clear to EOL
# %U - underline %S - standout
#
# %([n]x.true.false) '.' is arbitrary
# 'x' can be:
# ! - running with privs
# # - effective uid is 'n'
# ? exit status was 'n'
# C
# / - PWD has >= 'n' elements
# c
# .
# ~ - PWD with prefix replacements has >= 'n' elements
# D - month = 'n' (jan = 0)
# d - day of month = 'n'
# g - gid is 'n'
# j - # jobs >= 'n'
# l - 'n' chars already printed on line
# T - hours = 'n'
# t - minutes = 'n'
# w - day of week = 'n' (sun = 0)
#export PROMPT=$'%B%?%b %{\e[01;32m%}%n %{\e[01;34m%}%~ %# %{\e[0m%}'
case $HOSTNAME in
tuono)
export PROMPT=$'%(?..%{\e[41;38m%}%B-%?-%b%{\e[0m%} )%(1j.%{\e[01;33m%}[%j] .)%{\e[01;44m%}%n@%m%{\e[0m%} %{\e[01;32m%}%3~%{\e[0m%} %B%#%b '
;;
mac-mini)
export PROMPT=$'%(?..%{\e[41;38m%}%B-%?-%b%{\e[0m%} )%(1j.%{\e[01;33m%}[%j] .)%{\e[01;34m%}%n@%m%{\e[0m%} %{\e[01;32m%}%3~%{\e[0m%} %B%#%b '
;;
slick)
export PROMPT=$'%(?..%{\e[41;38m%}%B-%?-%b%{\e[0m%} )%(1j.%{\e[01;33m%}[%j] .)%{\e[01;31m%}%n@%m%{\e[0m%} %{\e[01;32m%}%3~%{\e[0m%} %B%#%b '
;;
*)
export PROMPT=$'%(?..%{\e[41;38m%}%B-%?-%b%{\e[0m%} )%(1j.%{\e[01;33m%}[%j] .)%{\e[01;32m%}%n@%m%{\e[0m%} %{\e[01;32m%}%3~%{\e[0m%} %B%#%b '
;;
esac
#export RPROMPT=$'%{\e[01;31m%}[%!]%{\e[0m%}' # time & history # on right
# 2}}}
# 1}}}
# 10. Aliases {{{1
# ===========
# 10.1. Convenience Aliases/Macros {{{2
# --------------------------------
#alias burn='cdrecord -dao -driveropts=burnfree -dev=ATA:1,1,0 -v'
alias cp='nocorrect cp' # don't correct spelling for 'cp'
alias cron='crontab -e'
#alias dispatch-conf='sudo dispatch-conf'
#alias emerge='sudo emerge' # should've thought of this
alias mkdir='nocorrect mkdir' # don't correct spelling for 'mkdir'
alias mv='nocorrect mv' # don't correct spelling for 'mv'
#alias ns='newscript'
#alias perldoc='LC_ALL=en_US perldoc'
#alias reboot='sudo shutdown -r now'
#alias shutdown='sudo shutdown -h now'
#alias ssh='ssh -X'
#alias u='cd ..'
#alias u2='cd ../..'
#alias u3='cd ../../..'
#alias u4='cd ../../../..'
# ruby
alias irb='irb --readline -r irb/completion'
alias rii='ri -Tf ansi'
# rails
alias ss='./script/server'
alias sc='./script/console'
alias mig='rake migrate'
alias gcon='./script/generate controller'
alias gmod='./script/generate model'
alias gmig='./script/generate migration'
alias gsca='./script/generate scaffold'
# svn
alias sup='svn update'
alias sst='svn status -u'
alias scom='svn commit'
alias slog='svn log | less'
# textmate
alias e='mate'
alias et='mate .'
# global aliases - work anywhere on line
alias -g L='|less'
alias -g G='|grep'
alias -g SH='>/dev/null 2>&1'
# suffix aliases, 'alias -s ps=gv' makes '*.ps' expand to 'gv *.ps'
# (globbing done after alias expansion!)
#alias -s c=gvim
#alias -s h=gvim
#alias -s py=gvim
#alias -s html=gvim
#alias -s css=gvim
function cd () {
if [[ -f $1 ]]; then
builtin cd $1:h
else
builtin cd $1
fi
}
function cl () {
cd $1
ls
}
# 2}}}
# 10.2. ls Aliases {{{2
# ----------------
alias ls='ls -BF'
alias la='/bin/ls -AF'
alias ll='ls -l'
alias lsd='ls -d'
# 2}}}
# 10.5. Miscellaneous Aliases {{{2
# ---------------------------
# 2}}}
# 1}}}
# 11. Unsorted (new) stuff {{{1
# ========================
export HISTFILE="$ZDOTDIR/zhistory" # save history
export HISTSIZE=100000
export SAVEHIST=100000 # huge history buffer
# if commands takes more than 60 seconds tell me how long it took
export REPORTTIME=60
# use less instead of the default more when no cmd is specified
export READNULLCMD=less
# use vim for info pages too
#info() { vim "+Info $1" +only; }
# set shell options
setopt autonamedirs # % export h=/home/sjs; cd ~h; pwd
# /home/sjs
setopt no_badpattern # supress err msgs
setopt cbases # 0xFF instead of 16#FF
setopt cdablevars # blah=~/media/movies; cd blah; pwd => ~/media/movies
#setopt globdots # match '.' implicitly
setopt globsubst # parameter expns eligible for filename expn & generation
setopt interactivecomments # comments allowed in interactive shells
setopt no_hup # leave bg tasks running (a la nohup)
#setopt multios # no more tee! (on by default)
#setopt magicequalsubst # performs filename expansion on 'arg' part of
# foo=arg parameters.
#bindkey -v # vi style key bindings
bindkey -e # emacs style key bindings
bindkey '^I' complete-word # complete on tab, leave expansion to _expand
# default in linux is backspace sends ^H, emacs no likey
#stty erase '^?'
TERMINFO=$HOME/.terminfo
# tell gentoo's mozilla-launcher script to open tabs
MOZILLA_NEWTYPE=tabs
function keep {
setopt localoptions nomarkdirs nonomatch nocshnullglob nullglob
kept=() # Erase old value in case of error on next line
kept=($~*)
if [[ ! -t 0 ]]; then
local line
while read line; do
kept+=( $line ) # += is a zsh 4.2+ feature
done
fi
print -Rc - ${^kept%/}(T)
}
alias keep='noglob keep '
# 1}}}
# more verbose completion prompt
zstyle ':completion:*' format '%SCompleting %U%d%u%s'
zstyle :completion::complete:cd:: tag-order \
local-directories path-directories
# The following lines were added by compinstall
zstyle ':completion:*' auto-description 'specify %d:'
zstyle ':completion:*' completer _expand _complete _files
zstyle ':completion:*' expand prefix
#zstyle ':completion:*' format 'Complete %d:'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'r:|[._-]=* r:|=*' 'r:|[._-]=* r:|=*' 'r:|[._-]=* r:|=*'
#zstyle ':completion:*' max-errors 2
zstyle ':completion:*' menu select=0
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' verbose true
zstyle :compinstall filename '/home/sjs/.zsh/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
#autoload -u promptinit
#promptinit
#prompt gentoo
if which keychain >/dev/null 2>&1; then
/usr/bin/keychain ~/.ssh/id_rsa
source ~/.keychain/${KEYCHAIN_HOST}-sh > /dev/null
fi
export LC_ALL="en_CA.UTF-8"
export LANG="en_CA.UTF-8"
# vim: set fdm=marker fdl=3 foldminlines=3 :