From 81c8016d1e296ed91af69f2d5bf435d7d657af04 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 12 Apr 2014 13:15:53 +0100 Subject: Restructure everything to use rcm https://github.com/thoughtbot/rcm --- atoprc | 2 - dwm/config.h | 106 -- emacs/Cask | 74 -- emacs/elisp/ap-functions.el | 47 - emacs/elisp/php-electric.el | 218 ---- emacs/elisp/shuffle-lines.el | 20 - emacs/elisp/xrdb-mode.el | 544 --------- emacs/init.el | 1170 -------------------- git-hooks/post-merge | 2 - gitconfig | 25 - gitignore | 29 - hgrc | 9 - host-prefect/Xresources | 4 + minttyrc | 33 - ssh/rc | 5 - tag-atop/atoprc | 2 + tag-dwm/dwm/config.h | 106 ++ tag-emacs/emacs.d/Cask | 74 ++ tag-emacs/emacs.d/elisp/ap-functions.el | 47 + tag-emacs/emacs.d/elisp/php-electric.el | 218 ++++ tag-emacs/emacs.d/elisp/shuffle-lines.el | 20 + tag-emacs/emacs.d/elisp/xrdb-mode.el | 544 +++++++++ tag-emacs/emacs.d/init.el | 1170 ++++++++++++++++++++ tag-git/config/git/config | 25 + tag-git/config/git/ignore | 29 + tag-hg/hgrc | 9 + tag-minttyrc/minttyrc | 33 + tag-ssh/ssh/rc | 5 + tag-tmux/tmux.conf | 19 + tag-xbindkeys/xbindkeysrc.scm | 57 + tag-xmobar/xmobarrc | 40 + tag-xresources/xresources/main | 33 + tag-xresources/xresources/solarized-light | 70 ++ tag-zsh/config/zsh/completion/_tmux_pane_words | 10 + tag-zsh/config/zsh/fasd.zsh | 85 ++ tag-zsh/config/zsh/freebsd.zsh | 8 + tag-zsh/config/zsh/functions/fasd/fasd | 624 +++++++++++ .../config/zsh/functions/pure/prompt_pure_setup | 118 ++ tag-zsh/config/zsh/functions/runit/_sv | 7 + tag-zsh/config/zsh/functions/runit/getservicedir | 2 + tag-zsh/config/zsh/functions/runit/linksv | 16 + tag-zsh/config/zsh/functions/runit/renamesv | 36 + tag-zsh/config/zsh/prefect.zsh | 10 + tag-zsh/config/zsh/server.zsh | 20 + tag-zsh/config/zsh/zlogin | 0 tag-zsh/config/zsh/zlogout | 0 tag-zsh/config/zsh/zshenv | 53 + tag-zsh/config/zsh/zshrc | 362 ++++++ tag-zsh/fasdrc | 8 + tag-zsh/zshenv | 3 + tmux.conf | 19 - xbindkeysrc.scm | 57 - xmobarrc | 40 - xresources/main | 33 - xresources/prefect | 4 - xresources/solarized-light | 70 -- zsh/completion/_tmux_pane_words | 10 - zsh/environment.zsh | 53 - zsh/fasd.zsh | 85 -- zsh/fasdrc | 8 - zsh/freebsd.zsh | 8 - zsh/functions/fasd/fasd | 624 ----------- zsh/functions/pure/prompt_pure_setup | 118 -- zsh/functions/runit/_sv | 7 - zsh/functions/runit/getservicedir | 2 - zsh/functions/runit/linksv | 16 - zsh/functions/runit/renamesv | 36 - zsh/interactive.zsh | 362 ------ zsh/login.zsh | 0 zsh/logout.zsh | 0 zsh/prefect.zsh | 10 - zsh/server.zsh | 20 - 72 files changed, 3867 insertions(+), 3866 deletions(-) delete mode 100644 atoprc delete mode 100644 dwm/config.h delete mode 100644 emacs/Cask delete mode 100644 emacs/elisp/ap-functions.el delete mode 100644 emacs/elisp/php-electric.el delete mode 100644 emacs/elisp/shuffle-lines.el delete mode 100644 emacs/elisp/xrdb-mode.el delete mode 100644 emacs/init.el delete mode 100755 git-hooks/post-merge delete mode 100644 gitconfig delete mode 100644 gitignore delete mode 100644 hgrc create mode 100644 host-prefect/Xresources delete mode 100644 minttyrc delete mode 100644 ssh/rc create mode 100644 tag-atop/atoprc create mode 100644 tag-dwm/dwm/config.h create mode 100644 tag-emacs/emacs.d/Cask create mode 100644 tag-emacs/emacs.d/elisp/ap-functions.el create mode 100644 tag-emacs/emacs.d/elisp/php-electric.el create mode 100644 tag-emacs/emacs.d/elisp/shuffle-lines.el create mode 100644 tag-emacs/emacs.d/elisp/xrdb-mode.el create mode 100644 tag-emacs/emacs.d/init.el create mode 100644 tag-git/config/git/config create mode 100644 tag-git/config/git/ignore create mode 100644 tag-hg/hgrc create mode 100644 tag-minttyrc/minttyrc create mode 100644 tag-ssh/ssh/rc create mode 100644 tag-tmux/tmux.conf create mode 100644 tag-xbindkeys/xbindkeysrc.scm create mode 100644 tag-xmobar/xmobarrc create mode 100644 tag-xresources/xresources/main create mode 100644 tag-xresources/xresources/solarized-light create mode 100644 tag-zsh/config/zsh/completion/_tmux_pane_words create mode 100644 tag-zsh/config/zsh/fasd.zsh create mode 100755 tag-zsh/config/zsh/freebsd.zsh create mode 100755 tag-zsh/config/zsh/functions/fasd/fasd create mode 100644 tag-zsh/config/zsh/functions/pure/prompt_pure_setup create mode 100644 tag-zsh/config/zsh/functions/runit/_sv create mode 100644 tag-zsh/config/zsh/functions/runit/getservicedir create mode 100644 tag-zsh/config/zsh/functions/runit/linksv create mode 100644 tag-zsh/config/zsh/functions/runit/renamesv create mode 100644 tag-zsh/config/zsh/prefect.zsh create mode 100644 tag-zsh/config/zsh/server.zsh create mode 100755 tag-zsh/config/zsh/zlogin create mode 100755 tag-zsh/config/zsh/zlogout create mode 100755 tag-zsh/config/zsh/zshenv create mode 100755 tag-zsh/config/zsh/zshrc create mode 100644 tag-zsh/fasdrc create mode 100644 tag-zsh/zshenv delete mode 100644 tmux.conf delete mode 100644 xbindkeysrc.scm delete mode 100644 xmobarrc delete mode 100644 xresources/main delete mode 100644 xresources/prefect delete mode 100644 xresources/solarized-light delete mode 100644 zsh/completion/_tmux_pane_words delete mode 100755 zsh/environment.zsh delete mode 100644 zsh/fasd.zsh delete mode 100644 zsh/fasdrc delete mode 100755 zsh/freebsd.zsh delete mode 100755 zsh/functions/fasd/fasd delete mode 100644 zsh/functions/pure/prompt_pure_setup delete mode 100644 zsh/functions/runit/_sv delete mode 100644 zsh/functions/runit/getservicedir delete mode 100644 zsh/functions/runit/linksv delete mode 100644 zsh/functions/runit/renamesv delete mode 100755 zsh/interactive.zsh delete mode 100755 zsh/login.zsh delete mode 100755 zsh/logout.zsh delete mode 100644 zsh/prefect.zsh delete mode 100644 zsh/server.zsh diff --git a/atoprc b/atoprc deleted file mode 100644 index d03319e..0000000 --- a/atoprc +++ /dev/null @@ -1,2 +0,0 @@ -flags Aa -maxlinecpu 0 \ No newline at end of file diff --git a/dwm/config.h b/dwm/config.h deleted file mode 100644 index ae1d8bb..0000000 --- a/dwm/config.h +++ /dev/null @@ -1,106 +0,0 @@ -/* See LICENSE file for copyright and license details. */ - -/* appearance */ -static const char font[] = "-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*"; -static const char normbordercolor[] = "#657b83"; -static const char normbgcolor[] = "#002b36"; -static const char normfgcolor[] = "#fdf6e3"; -static const char selbordercolor[] = "#859900"; -static const char selbgcolor[] = "#586e75"; -static const char selfgcolor[] = "#fdf6e3"; -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ -static const Bool showbar = True; /* False means no bar */ -static const Bool topbar = True; /* False means bottom bar */ - -/* tagging */ -static const char *tags[] = { "shell", "code", "web", "misc" }; - -static const Rule rules[] = { - /* class instance title tags mask isfloating monitor */ - { "Firefox", NULL, NULL, 1 << 2, False, -1 }, - { "URxvt", NULL, NULL, 1 << 0, False, -1 }, - { "Emacs", "emacs", NULL, 1 << 1, False, -1 }, - { "KeePass2", NULL, NULL, 1 << 3, False, -1 }, - { "deadbeef", NULL, NULL, 1 << 3, False, -1 }, - { "Emacs", "Ediff", NULL, 0, True, -1 }, -}; - -/* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ -static const int nmaster = 1; /* number of clients in master area */ -static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ - -static const Layout layouts[] = { - /* symbol arrange function */ - { "[]=", tile }, /* first entry is default */ - { "><>", NULL }, /* no layout function means floating behavior */ - { "[M]", monocle }, -}; - -/* key definitions */ -#define MODKEY Mod4Mask -#define TAGKEYS(KEY,TAG) \ - { MODKEY, KEY, toggleview, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask, KEY, view, {.ui = 1 << TAG} }, \ - { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, - -/* helper for spawning shell commands in the pre dwm-5.0 fashion */ -#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } - -/* commands */ -static const char *termcmd[] = { "urxvt", NULL }; - -static Key keys[] = { - /* modifier key function argument */ - { MODKEY|ShiftMask, XK_b, togglebar, {0} }, - { MODKEY, XK_e, focusstack, {.i = +1 } }, - { MODKEY, XK_i, focusstack, {.i = -1 } }, - { MODKEY, XK_s, incnmaster, {.i = +1 } }, - { MODKEY, XK_r, incnmaster, {.i = -1 } }, - { MODKEY, XK_n, setmfact, {.f = -0.05} }, - { MODKEY, XK_o, setmfact, {.f = +0.05} }, - { MODKEY, XK_Return, zoom, {0} }, - { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, - { MODKEY, XK_g, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, - { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, - { MODKEY, XK_comma, focusmon, {.i = -1 } }, - { MODKEY, XK_period, focusmon, {.i = +1 } }, - { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, - { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, - TAGKEYS( XK_1, 0) - TAGKEYS( XK_2, 1) - TAGKEYS( XK_3, 2) - TAGKEYS( XK_4, 3) - TAGKEYS( XK_5, 4) - TAGKEYS( XK_6, 5) - TAGKEYS( XK_7, 6) - TAGKEYS( XK_8, 7) - TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_q, quit, {0} }, - { MODKEY|ShiftMask, XK_r, quit, { .i = 5 } }, -}; - -/* button definitions */ -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ -static Button buttons[] = { - /* click event mask button function argument */ - { ClkLtSymbol, 0, Button1, setlayout, {0} }, - { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, - { ClkWinTitle, 0, Button2, zoom, {0} }, - { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, - { ClkClientWin, MODKEY, Button1, movemouse, {0} }, - { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, - { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, - { ClkTagBar, 0, Button1, toggleview, {0} }, - { ClkTagBar, 0, Button3, view, {0} }, - { ClkTagBar, MODKEY, Button1, tag, {0} }, - { ClkTagBar, MODKEY, Button3, toggletag, {0} }, -}; diff --git a/emacs/Cask b/emacs/Cask deleted file mode 100644 index 8742df0..0000000 --- a/emacs/Cask +++ /dev/null @@ -1,74 +0,0 @@ -(source org) -(source melpa) -(source marmalade) -(source gnu) - -(depends-on "ace-jump-mode") -(depends-on "ag") -(depends-on "auto-compile") -(depends-on "auto-indent-mode") -(depends-on "autopair") -(depends-on "bind-key") -(depends-on "cask") -(depends-on "cdnjs") -(depends-on "company") -(depends-on "confluence") -(depends-on "control-mode") -(depends-on "dash") -(depends-on "dash-at-point") -(depends-on "deferred") -(depends-on "diff-hl") -(depends-on "diminish") -(depends-on "dired+") -(depends-on "discover") -(depends-on "emmet-mode") -(depends-on "epl") -(depends-on "expand-region") -(depends-on "f") -(depends-on "flx") -(depends-on "flx-ido") -(depends-on "framemove") -(depends-on "geiser") -(depends-on "ggtags") -(depends-on "git-commit-mode") -(depends-on "git-rebase-mode") -(depends-on "god-mode") -(depends-on "haskell-mode") -(depends-on "helm") -(depends-on "ido-vertical-mode") -(depends-on "jinja2-mode") -(depends-on "js2-mode") -(depends-on "lua-mode") -(depends-on "magit") -(depends-on "makey") -(depends-on "multi-term") -(depends-on "multiple-cursors") -(depends-on "mustache-mode") -(depends-on "nginx-mode") -(depends-on "org-jira") -(depends-on "org-journal") -(depends-on "org-plus-contrib") -(depends-on "packed") -(depends-on "pallet") -(depends-on "paredit") -(depends-on "php-extras") -(depends-on "php-mode") -(depends-on "pkg-info") -(depends-on "project-persist") -(depends-on "projectile") -(depends-on "puppet-mode") -(depends-on "quickrun") -(depends-on "redshank") -(depends-on "s") -(depends-on "simple-httpd") -(depends-on "skewer-mode") -(depends-on "smart-tab") -(depends-on "smart-tabs-mode") -(depends-on "smex") -(depends-on "solarized-theme") -(depends-on "tup-mode") -(depends-on "undo-tree") -(depends-on "use-package") -(depends-on "web-mode") -(depends-on "xml-rpc") -(depends-on "yaml-mode") \ No newline at end of file diff --git a/emacs/elisp/ap-functions.el b/emacs/elisp/ap-functions.el deleted file mode 100644 index bdc7fae..0000000 --- a/emacs/elisp/ap-functions.el +++ /dev/null @@ -1,47 +0,0 @@ -;;;###autoload -(defun ap/remove-extra-cr () - "Remove extraneous CR codes from a file" - (interactive) - (save-excursion - (goto-char (point-min)) - (while (search-forward " -" nil t) - (replace-match "")))) - -;;;###autoload -(defun copy-rectangle (start end) - "Copy the region-rectangle." - (interactive "r") - (setq killed-rectangle (extract-rectangle start end))) - -;;;###autoload -(defun eval-and-replace () - "Replace the preceding sexp with its value." - (interactive) - (backward-kill-sexp) - (condition-case nil - (prin1 (eval (read (current-kill 0))) - (current-buffer)) - (error (message "Invalid expression") - (insert (current-kill 0))))) - -;;;###autoload -(defun shell-execute (to-current-buffer) - (interactive "P") - (let ((file-buffer (if (buffer-file-name) - (file-name-nondirectory (buffer-file-name)) - "")) - (command (read-shell-command "Shell command: " nil nil nil))) - (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer))) - -;;;###autoload -(defun narrow-to-region-indirect (start end) - "Restrict editing in this buffer to the current region, indirectly." - (interactive "r") - (deactivate-mark) - (let ((buf (clone-indirect-buffer nil nil))) - (with-current-buffer buf - (narrow-to-region start end)) - (switch-to-buffer buf))) - -(provide 'ap-functions) diff --git a/emacs/elisp/php-electric.el b/emacs/elisp/php-electric.el deleted file mode 100644 index 599b2b1..0000000 --- a/emacs/elisp/php-electric.el +++ /dev/null @@ -1,218 +0,0 @@ -;; -*- Emacs-Lisp -*- -;; -;; php-electric.el --- electric submode for the php-mode -;; -;; Version: 1.0 -;; Release-Date: Sunday 04 March 2007 -;; -;; Copyright (C) 2007 -;; by Nikolay V. Nemshilov aka St. -;; -;; -;; License -;; -;; 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. -;; -;; -;; Features: -;; * autocompletion of the language contructions -;; such as if, for, foreach, etc blocks, -;; -;; * autocompletion of classes, interfaces and functions -;; definitions -;; -;; * autocompletion of the paired symbols, like [], (), "",'' -;; -;; -;; Usage: -;; Nothing magical, just place the file in a directory where -;; Emacs can find it, and write -;; -;; (require 'php-electric) -;; -;; in your configuration files ~/.emacs or wherever you keep it. -;; Then you can switch on/off the mode by the following command -;; -;; M-x php-electric-mode -;; -;; If you like to have it switched on automatically, you should -;; put the command in your php-mode hook or create new one, -;; like that -;; -;; (add-hook 'php-mode-hook '(lambda () (php-electric-mode))) -;; -;; That's it. -;; -;; -;; Changelog: -;; Sunday 04 March 2007 -;; The first version 1.0 has been came out. -;; - -(defgroup php-electric nil - "Minor php-electric mode" - :group 'php) - -;; list of keywords which expandible by the {} pair -(defconst php-electric-expandible-simple-re - "\\(try\\|else\\|do\\)") - -;; list of keywords which expandible with the (){} construction -(defconst php-electric-expandible-as-struct-re - "\\(while\\|for\\|foreach\\|if\\|elseif\\|catch\\)") - -;; list of keywords which expandible with the name(){} construction -(defconst php-electric-expandible-as-func-re - "\\(function\\)") - -;; list of keywords which expandible with the name{} construction -(defconst php-electric-expandible-as-class-re - "\\(class\\|interface\\)") - -;; list of the paired chars -(defvar php-electric-matching-delimeter-alist - '((?\[ . ?\]) - (?\( . ?\)) - (?\" . ?\") - (?\' . ?\'))) - -;; the minor-mode definition -(define-minor-mode php-electric-mode - "Minor electric-mode for the php-mode" - nil - "-El" - php-mode-map - (php-electric-keymap)) - -;; list of accessible keys -(defun php-electric-keymap() - (define-key php-mode-map " " 'php-electric-space) - (define-key php-mode-map "{" 'php-electric-curlies) - (define-key php-mode-map "(" 'php-electric-brackets) - (define-key php-mode-map "[" 'php-electric-matching-char) - (define-key php-mode-map "\"" 'php-electric-matching-char) - (define-key php-mode-map "\'" 'php-electric-matching-char)) - -;; handler for the spaces insertions -(defun php-electric-space(arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (php-electric-is-code-at-point-p) - (if (php-electric-line-is-simple-expandible) - ;; inserting just a pair of curleis - (progn - (insert "{")(php-electric-insert-new-line-and-statement-end)) - (if (php-electric-line-is-expandible-as-struct) - ;; inserting a structure definition - (progn - (if (not (char-equal ?\( (preceding-char))) - ;; cmd () { - style construction - (progn - (insert "(")(set-register 98 (point-marker))(insert ") {")) - - ;; cmd( ){ - style construction - (progn - (insert " ")(set-register 98 (point-marker))(insert " ){"))) - (php-electric-insert-new-line-and-statement-end) - (jump-to-register 98)(set-register 98 nil)) - (if (php-electric-line-is-expandible-as-func) - ;; inserting the function expanding - (save-excursion - (insert "(){")(php-electric-insert-new-line-and-statement-end)) - (if (php-electric-line-is-expandible-as-class) - ;; inserting the class expanding - (save-excursion - (insert "{")(php-electric-insert-new-line-and-statement-end)))))))) - -;; handler for the { chars -(defun php-electric-curlies(arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (php-electric-is-code-at-point-p) - (progn - (php-electric-insert-new-line-and-statement-end)))) - -;; handler for the ( chars -(defun php-electric-brackets(arg) - (interactive "P") - - (if (php-electric-is-code-at-point-p) - ;; checking if it's a statement - (if (php-electric-line-is-expandible-as-struct) - (progn (php-electric-space arg)) - (progn (php-electric-matching-char arg))) - (self-insert-command (prefix-numeric-value arg)))) - -;; handler for the paired chars, [], (), "", '' -(defun php-electric-matching-char(arg) - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - (if (php-electric-is-code-at-point-p) - (save-excursion - (insert (cdr (assoc last-command-char - php-electric-matching-delimeter-alist)))))) - -;; checks if the current pointer situated in a piece of code -(defun php-electric-is-code-at-point-p() - (and php-electric-mode - (let* ((properties (text-properties-at (point)))) - (and (null (memq 'font-lock-string-face properties)) - (null (memq 'font-lock-comment-face properties)))))) - -;; checks if the current line expandible with a simple {} construction -(defun php-electric-line-is-simple-expandible() - (let* ((php-electric-expandible-simple-real-re - (concat php-electric-expandible-simple-re "\\s-$"))) - (save-excursion - (backward-word 1) - (looking-at php-electric-expandible-simple-real-re)))) - -;; checks if the current line expandible with the (){} construction -(defun php-electric-line-is-expandible-as-struct() - (let* ((php-electric-expandible-as-struct-real-re - (concat php-electric-expandible-as-struct-re "[ ]*$")) - (php-electric-expandible-as-struct-with-bracket-re - (concat php-electric-expandible-as-struct-re "($"))) - (save-excursion - (backward-word 1) - (or (looking-at php-electric-expandible-as-struct-real-re) - (looking-at php-electric-expandible-as-struct-with-bracket-re))))) - -;; checks if the current line expandible with the name(){} construction -(defun php-electric-line-is-expandible-as-func() - (let* ((php-electric-expandible-as-func-real-re - (concat php-electric-expandible-as-func-re "\\s-$"))) - (save-excursion - (backward-word 1) - (looking-at php-electric-expandible-as-func-real-re)))) - -;; checks if the current line expandible with the name{} construction -(defun php-electric-line-is-expandible-as-class() - (let* ((php-electric-expandible-as-class-real-re - (concat php-electric-expandible-as-class-re "\\s-$"))) - (save-excursion - (backward-word 1) - (looking-at php-electric-expandible-as-class-real-re)))) - -;; "shortcut" to insert \n} construction -(defun php-electric-insert-new-line-and-statement-end() - (newline-and-indent)(set-register 99 (point-marker)) - (insert "\n}")(indent-according-to-mode) - (jump-to-register 99)(set-register 99 nil)) - - -(provide 'php-electric) - -;; end of the file \ No newline at end of file diff --git a/emacs/elisp/shuffle-lines.el b/emacs/elisp/shuffle-lines.el deleted file mode 100644 index be0a98f..0000000 --- a/emacs/elisp/shuffle-lines.el +++ /dev/null @@ -1,20 +0,0 @@ -;;;###autoload -(defun move-line-down () - (interactive) - (let ((col (current-column))) - (save-excursion - (forward-line) - (transpose-lines 1)) - (forward-line) - (move-to-column col))) - -;;;###autoload -(defun move-line-up () - (interactive) - (let ((col (current-column))) - (save-excursion - (forward-line) - (transpose-lines -1)) - (move-to-column col))) - -(provide 'shuffle-lines) diff --git a/emacs/elisp/xrdb-mode.el b/emacs/elisp/xrdb-mode.el deleted file mode 100644 index 712f0cb..0000000 --- a/emacs/elisp/xrdb-mode.el +++ /dev/null @@ -1,544 +0,0 @@ -;;; xrdb-mode.el --- mode for editing X resource database files - -;; Copyright (C) 1998,1999,2000 Free Software Foundation, Inc. - -;; Author: 1994-2003 Barry A. Warsaw -;; Maintainer: barry@python.org -;; Created: May 1994 -;; Keywords: data languages - -(defconst xrdb-version "2.31" - "`xrdb-mode' version number.") - -;; 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. - -;;; Commentary: -;; -;; This file provides a major mode for editing X resource database -;; files. It includes font-lock definitions and commands for -;; controlling indentation, re-indenting by subdivisions, and loading -;; and merging into the the resource database. -;; -;; To use, put the following in your .emacs: -;; -;; (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t) -;; -;; You may also want something like: -;; -;; (setq auto-mode-alist -;; (append '(("\\.Xdefaults$" . xrdb-mode) -;; ("\\.Xenvironment$" . xrdb-mode) -;; ("\\.Xresources$" . xrdb-mode) -;; ("*.\\.ad$" . xrdb-mode) -;; ) -;; auto-mode-alist)) - -;;; Credits: -;; -;; The database merge feature was inspired by Joel N. Weber II. -;; -;; The canonical Web site for xrdb-mode is -;; - -;;; Code: -(require 'custom) - - - -(defgroup xrdb nil - "Support for editing X resource database files" - :group 'languages) - -(defcustom xrdb-mode-hook nil - "*Hook to be run when `xrdb-mode' is entered." - :type 'hook - :group 'xrdb) - -(defcustom xrdb-subdivide-by 'paragraph - "*Default alignment subdivision when re-indenting a region or buffer. -This variable controls how much of the buffer is searched to find a -goal column on which to align. Every non-comment line in the region -defined by this variable is scanned for the first `:' character on the -line, and this character's column is the line's goal column. The -rightmost line goal column in the region is taken as the region's goal -column. - -This variable can take one of the following symbol values: - - `buffer' - All lines in the buffer are scanned. This is the - slowest option. - - `paragraph' - All lines in the paragraph are scanned. Paragraphs - are delimited by blank lines, comment lines, and page - delimiters. - - `page' - All lines in the page are scanned. Pages are delimited - with `page-delimiter', usually ^L (control-L). - - `line' - Only the previous non-comment line is scanned. This is - the fastest method. - -This variable is used by the various indentation commands, and can be -overridden in those commands by using \\[universal-argument]." - :type '(radio (const :tag "Do not subdivide buffer" buffer) - (const :tag "Subdivide by paragraphs" paragraph) - (const :tag "Subdivide by pages" page) - (const :tag "Each line is independent" line)) - :group 'xrdb) - -(defcustom xrdb-compress-whitespace nil - "*Collapse all whitespace to a single space after insertion of `:'." - :type 'boolean - :group 'xrdb) - -(defcustom xrdb-program "xrdb" - "*Program to run to load or merge resources in the X resource database." - :type 'string - :group 'xrdb) - -(defcustom xrdb-program-args '("-merge") - "*List of string arguments to pass to `xrdb-program'." - :type '(repeat string) - :group 'xrdb) - -(defvar xrdb-master-file nil - "If non-nil, merge in the named file instead of the buffer's file. -The intent is to allow you to set this variable in the file's local -variable section, e.g.: - - ! Local Variables: - ! xrdb-master-file: \"Xdefaults\" - ! End: - -so that typing \\[xrdb-database-merge-buffer-or-region] in that buffer -merges the named master file instead of the buffer's file. Note that -if the file name has a relative path, the `default-directory' for the -buffer is prepended to come up with a file name. - -You may also want to set `xrdb-program-args' in the local variables -section as well.") -(make-variable-buffer-local 'xrdb-master-file) - - -;; Non-user customizable -(defconst xrdb-comment-re "^[ \t]*[!]" - "Regular expression describing the beginning of a comment line.") - - - -;; utilities -(defun xrdb-point (position) - ;; Returns the value of point at certain commonly referenced POSITIONs. - ;; POSITION can be one of the following symbols: - ;; - ;; bol -- beginning of line - ;; eol -- end of line - ;; bod -- beginning of defun - ;; boi -- back to indentation - ;; ionl -- indentation of next line - ;; iopl -- indentation of previous line - ;; bonl -- beginning of next line - ;; bopl -- beginning of previous line - ;; bop -- beginning of paragraph - ;; eop -- end of paragraph - ;; bopg -- beginning of page - ;; eopg -- end of page - ;; - ;; This function does not modify point or mark. - (let ((here (point))) - (cond - ((eq position 'bod) (beginning-of-defun)) - ((eq position 'bol) (beginning-of-line)) - ((eq position 'eol) (end-of-line)) - ((eq position 'boi) (back-to-indentation)) - ((eq position 'bonl) (forward-line 1)) - ((eq position 'bopl) (forward-line -1)) - ((eq position 'bop) (forward-paragraph -1)) - ((eq position 'eop) (forward-paragraph 1)) - ((eq position 'bopg) (forward-page -1)) - ((eq position 'eopg) (forward-page 1)) - (t - (error "unknown buffer position requested: %s" position))) - (prog1 - (point) - (goto-char here)) - )) - -(defmacro xrdb-safe (&rest body) - ;; safely execute BODY, return nil if an error occurred - `( (condition-case nil - (progn (,@ body)) - (error nil)))) - -(defsubst xrdb-skip-to-separator () - ;; skip forward from the beginning of the line to the separator - ;; character as given by xrdb-separator-char. Returns t if the - ;; char was found, otherwise, nil. - (beginning-of-line) - (skip-chars-forward "^:" (xrdb-point 'eol)) - (and (eq (char-after) ?:) - (current-column))) - -(defsubst xrdb-in-comment-p (&optional lim) - (let* ((lim (or lim (xrdb-point 'bod))) - (state (parse-partial-sexp lim (point)))) - (nth 4 state))) - -(defsubst xrdb-boi-col () - (let ((here (point))) - (goto-char (xrdb-point 'boi)) - (prog1 - (current-column) - (goto-char here)))) - -(defvar xrdb-prompt-history nil) - -(defun xrdb-prompt-for-subdivision () - (let ((options '(("buffer" . buffer) - ("paragraphs" . paragraph) - ("pages" . page) - ("lines" . line))) - (completion-ignore-case t)) - (cdr (assoc - (completing-read "Subdivide alignment by? " options nil t - (cons (format "%s" xrdb-subdivide-by) 0) - 'xrdb-prompt-history) - options)))) - - -;; commands -(defun xrdb-electric-separator (arg) - "Insert a colon, and possibly indent line. -Numeric argument inserts that many separators. If the numeric -argument is not given, or is 1, and the separator is not inserted in a -comment, then the line is indented according to `xrdb-subdivide-by'." - (interactive "P") - (self-insert-command (prefix-numeric-value arg)) - ;; only do electric behavior if arg is not given - (or arg - (xrdb-in-comment-p) - (xrdb-indent-line)) - ;; compress whitespace - (and xrdb-compress-whitespace - (just-one-space))) - -(defun xrdb-electric-bang (arg) - "Insert an exclamation point to start a comment. -Numeric argument inserts that many exclamation characters. If the -numeric argument is not given, or is 1, and the bang character is the -first character on a line, the line is indented to column zero." - (interactive "P") - (let ((how-many (prefix-numeric-value arg))) - (self-insert-command how-many) - (save-excursion - (if (and (= how-many 1) - (xrdb-in-comment-p) - (memq (char-before (xrdb-point 'boi)) '(?\n nil))) - (indent-line-to 0))) - )) - - -(defun xrdb-indent-line (&optional arg) - "Align the current line according to `xrdb-subdivide-by'. -With optional \\[universal-argument], prompt for subdivision." - (interactive "P") - (xrdb-align-to-column - (xrdb-guess-goal-column (if arg - (xrdb-prompt-for-subdivision) - xrdb-subdivide-by)) - (xrdb-point 'bol) - (xrdb-point 'bonl))) - -(defun xrdb-indent-region (start end &optional arg) - "Indent all lines in the region according to `xrdb-subdivide-by'. -With optional \\[universal-argument], prompt for subdivision." - (interactive "r\nP") - (xrdb-align-to-column - (xrdb-guess-goal-column (if arg - (xrdb-prompt-for-subdivision) - xrdb-subdivide-by)) - start end)) - -(defun xrdb-indent-page (&optional arg) - "Indent all lines in the page according to `xrdb-subdivide-by'. -With optional \\[universal-argument], prompt for subdivision." - (interactive "P") - (xrdb-align-to-column - (xrdb-guess-goal-column (if arg - (xrdb-prompt-for-subdivision) - xrdb-subdivide-by)) - (xrdb-point 'bopg) - (xrdb-point 'eopg))) - -(defun xrdb-indent-paragraph (&optional arg) - "Indent all lines in the paragraph according to `xrdb-subdivide-by'. -With optional \\[universal-argument], prompt for subdivision." - (interactive "P") - (xrdb-align-to-column - (xrdb-guess-goal-column (if arg - (xrdb-prompt-for-subdivision) - xrdb-subdivide-by)) - (xrdb-point 'bop) - (xrdb-point 'eop))) - -(defun xrdb-indent-buffer (&optional arg) - "Indent all lines in the buffer according to `xrdb-subdivide-by'. -With optional \\[universal-argument], prompt for subdivision." - (interactive "P") - (let ((subdivide-by (if arg - (xrdb-prompt-for-subdivision) - xrdb-subdivide-by))) - (save-excursion - (beginning-of-buffer) - (if (eq subdivide-by 'buffer) - (xrdb-align-to-column (xrdb-guess-goal-column 'buffer) - (point-min) (point-max)) - (let (mvfwdfunc indentfunc) - (cond - ((eq subdivide-by 'paragraph) - (setq mvfwdfunc 'forward-paragraph - indentfunc 'xrdb-indent-paragraph)) - ((eq subdivide-by 'page) - (setq mvfwdfunc 'forward-page - indentfunc 'xrdb-indent-page)) - ((eq subdivide-by 'line) - (setq mvfwdfunc 'forward-line - indentfunc 'xrdb-indent-page)) - (t (error "Illegal alignment subdivision: %s" subdivide-by)) - ) - (while (< (point) (point-max)) - (funcall indentfunc) - (funcall mvfwdfunc 1)) - ))))) - - -;; internal alignment functions -(defun xrdb-align-to-column (goalcol &optional start end) - (let ((start (or start (xrdb-point 'bol))) - (end (or end (xrdb-point 'bonl)))) - (save-excursion - (save-restriction - (narrow-to-region start end) - (beginning-of-buffer) - (while (< (point) (point-max)) - (if (and (not (looking-at xrdb-comment-re)) - (xrdb-skip-to-separator)) - (indent-line-to (max 0 (+ goalcol - (- (current-column)) - (xrdb-boi-col)) - ))) - (forward-line 1)) - )))) - -(defun xrdb-guess-goal-column (subdivide-by) - ;; Returns the goal column of the current line based on SUBDIVIDE-BY, - ;; which can be any value allowed by `xrdb-subdivide-by'. - (let ((here (point)) - (goalcol 0)) - (save-restriction - (cond - ((eq subdivide-by 'line) - (while (and (zerop (forward-line -1)) - (or (looking-at xrdb-comment-re) - (not (xrdb-skip-to-separator))))) - ;; maybe we didn't find one - (if (not (xrdb-skip-to-separator)) - (goto-char here)) - (narrow-to-region (xrdb-point 'bol) (xrdb-point 'bonl))) - ((eq subdivide-by 'page) - (narrow-to-page)) - ((eq subdivide-by 'paragraph) - (narrow-to-region (xrdb-point 'bop) (xrdb-point 'eop))) - ((eq subdivide-by 'buffer)) - (t (error "Illegal alignment subdivision: %s" subdivide-by))) - (goto-char (point-min)) - (while (< (point) (point-max)) - (if (and (not (looking-at xrdb-comment-re)) - (xrdb-skip-to-separator)) - (setq goalcol (max goalcol (- (current-column) (xrdb-boi-col))))) - (forward-line 1))) - (goto-char here) - goalcol)) - - - -;; major-mode stuff -(defvar xrdb-mode-abbrev-table nil - "Abbreviation table used in `xrdb-mode' buffers.") -(define-abbrev-table 'xrdb-mode-abbrev-table ()) - - -(defvar xrdb-mode-syntax-table nil - "Syntax table used in `xrdb-mode' buffers.") -(if xrdb-mode-syntax-table - nil - (setq xrdb-mode-syntax-table (make-syntax-table)) - (modify-syntax-entry ?! "<" xrdb-mode-syntax-table) - (modify-syntax-entry ?\\ "\\" xrdb-mode-syntax-table) - (modify-syntax-entry ?\n ">" xrdb-mode-syntax-table) - (modify-syntax-entry ?/ ". 14" xrdb-mode-syntax-table) - (modify-syntax-entry ?* "_ 23" xrdb-mode-syntax-table) - (modify-syntax-entry ?. "_" xrdb-mode-syntax-table) - (modify-syntax-entry ?# "_" xrdb-mode-syntax-table) - (modify-syntax-entry ?? "_" xrdb-mode-syntax-table) - (modify-syntax-entry ?< "(" xrdb-mode-syntax-table) - (modify-syntax-entry ?> ")" xrdb-mode-syntax-table) - ) - - -(defvar xrdb-mode-map () - "Keymap used in `xrdb-mode' buffers.") -(if xrdb-mode-map - () - (setq xrdb-mode-map (make-sparse-keymap)) - ;; make the separator key electric - (define-key xrdb-mode-map ":" 'xrdb-electric-separator) - (define-key xrdb-mode-map "!" 'xrdb-electric-bang) - (define-key xrdb-mode-map "\t" 'xrdb-indent-line) - (define-key xrdb-mode-map "\C-c\C-a" 'xrdb-indent-buffer) - (define-key xrdb-mode-map "\C-c\C-b" 'xrdb-submit-bug-report) - (define-key xrdb-mode-map "\C-c\C-c" 'xrdb-database-merge-buffer-or-region) - (define-key xrdb-mode-map "\C-c\C-p" 'xrdb-indent-paragraph) - (define-key xrdb-mode-map "\C-c\[" 'xrdb-indent-page) - (define-key xrdb-mode-map "\C-c\C-r" 'xrdb-indent-region) - ) - -;;;###autoload -(defun xrdb-mode () - "Major mode for editing xrdb config files" - (interactive) - (kill-all-local-variables) - (set-syntax-table xrdb-mode-syntax-table) - (setq major-mode 'xrdb-mode - mode-name "xrdb" - local-abbrev-table xrdb-mode-abbrev-table) - (use-local-map xrdb-mode-map) - (setq font-lock-defaults '(xrdb-font-lock-keywords)) - ;; local variables - (make-local-variable 'parse-sexp-ignore-comments) - (make-local-variable 'comment-start-skip) - (make-local-variable 'comment-start) - (make-local-variable 'comment-end) - (make-local-variable 'paragraph-start) - (make-local-variable 'paragraph-separate) - (make-local-variable 'paragraph-ignore-fill-prefix) - (make-local-variable 'indent-region-function) - ;; now set their values - (setq parse-sexp-ignore-comments t - comment-start-skip "![ \t]*" - comment-start "! " - comment-end "") - (setq indent-region-function 'xrdb-indent-region - paragraph-ignore-fill-prefix t - paragraph-start (concat "^[ \t]*$\\|^[ \t]*[!]\\|" page-delimiter) - paragraph-separate paragraph-start) - (run-hooks 'xrdb-mode-hook)) - - - -;; faces and font-locking -(defvar xrdb-option-name-face 'xrdb-option-name-face - "Face for option name on a line in an X resource db file") - -(defvar xrdb-option-value-face 'xrdb-option-value-face - "Face for option value on a line in an X resource db file") - -(make-face 'xrdb-option-name-face) -(make-face 'xrdb-option-value-face) - -(defun xrdb-font-lock-mode-hook () - (or (face-differs-from-default-p 'xrdb-option-name-face) - (copy-face 'font-lock-keyword-face 'xrdb-option-name-face)) - (or (face-differs-from-default-p 'xrdb-option-value-face) - (copy-face 'font-lock-string-face 'xrdb-option-value-face)) - (remove-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook)) -(add-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook) - -(defvar xrdb-font-lock-keywords - (list '("^[ \t]*\\([^\n:]*:\\)[ \t]*\\(.*\\)$" - (1 xrdb-option-name-face) - (2 xrdb-option-value-face))) - "Additional expressions to highlight in X resource db mode.") -(put 'xrdb-mode 'font-lock-defaults '(xrdb-font-lock-keywords)) - - - -;; merging and manipulating the X resource database -(defun xrdb-database-merge-buffer-or-region (start end) - "Merge the current buffer's resources into the X resource database. - -`xrdb-program' is the program to actually call, with the arguments -specified in `xrdb-program-args'. This latter can be set to do either -a merge or a load, etc. Also, if the file local variable -`xrdb-master-file' is non-nil, then it is merged instead of the -buffer's file. - -If the current region is active, it is merged instead of the buffer, -and this overrides any use of `xrdb-master-file'." - (interactive - ;; the idea here is that if the region is inactive, start and end - ;; will be nil, if not passed in programmatically - (list (xrdb-safe (and (mark) (region-beginning))) - (xrdb-safe (and (mark) (region-end))))) - (message "Merging with args: %s..." xrdb-program-args) - (let ((outbuf (get-buffer-create "*Shell Command Output*"))) - ;; I prefer the XEmacs way of doing this, but this is the easiest - ;; way to work in both XEmacs and Emacs. - (with-current-buffer outbuf (erase-buffer)) - (cond - ((and start end) - (apply 'call-process-region start end xrdb-program nil outbuf t - xrdb-program-args)) - (xrdb-master-file - (apply 'call-process xrdb-program xrdb-master-file outbuf t - xrdb-program-args)) - (t - (apply 'call-process-region (point-min) (point-max) xrdb-program - nil outbuf t xrdb-program-args))) - (if (not (zerop (with-current-buffer outbuf (buffer-size)))) - (pop-to-buffer outbuf))) - (message "Merging... done")) - - - -;; submitting bug reports - -(defconst xrdb-mode-help-address "tools-help@python.org" - "Address for xrdb-mode bug reports.") - -(defun xrdb-submit-bug-report () - "Submit via mail a bug report on xrdb-mode." - (interactive) - ;; load in reporter - (require 'reporter) - (let ((reporter-prompt-for-summary-p t) - (varlist '(xrdb-subdivide-by - xrdb-mode-hook - xrdb-compress-whitespace - ))) - (and (if (y-or-n-p "Do you want to submit a report on xrdb-mode? ") - t - (message "") - nil) - (require 'reporter) - (reporter-submit-bug-report - xrdb-mode-help-address - (format "xrdb-mode %s" xrdb-version) - varlist nil nil "Dear Barry,") - ))) - - -(provide 'xrdb-mode) -;;; xrdb-mode.el ends here diff --git a/emacs/init.el b/emacs/init.el deleted file mode 100644 index 76505ad..0000000 --- a/emacs/init.el +++ /dev/null @@ -1,1170 +0,0 @@ -;; -*- lexical-binding: t; -*- -;;;; Startup -;; Do not merge echo-area-message sexp -(setq inhibit-startup-echo-area-message "alan") -(setq inhibit-startup-screen t - initial-scratch-message "" - initial-major-mode 'text-mode - user-mail-address "alan@alanpearce.co.uk" - user-full-name "Alan Pearce" - custom-file "~/.emacs.d/custom.el") - -(load custom-file :noerror) - -;;; Allow lisps to use a common setup. I don't know why they don't have some lispy mode as their parent, but this is close enough -(defcustom lisp-common-mode-hook nil - "Hook run when entering any Lisp mode." - :type 'hook - :group 'lisp) - -;;;; Environment & Location - -(defun env/get-location () - "Return the physical location of the system, or `nil' if unknown" - (if (executable-find "netctl") - (catch 'found - (mapc (lambda (line) - (cond - ((string-prefix-p "* home" line) (throw 'found 'home)) - ((string-prefix-p "* work" line) (throw 'found 'work)))) - (process-lines "netctl" "list")) - nil))) - -(defun env/get-system-type () - "Return the type of computer that is running" - (cond - ((string-prefix-p "prefect" system-name) 'desktop) - ((string-prefix-p "server" system-name) 'server) - ((string-prefix-p "sheldon" system-name) 'laptop))) - -(defvar env/location (env/get-location) - "The type of location the system is located in -Values: `work', `home'") - -(defvar env/system-type (env/get-system-type) - "The type of computer Emacs is running on -Values: `desktop', `server', `laptop'") - -(defun env/recheck-location () - (interactive) - (setq env/location (env/get-location))) - -(defvar *init-file* - (when user-init-file - (expand-file-name "init.el" - (file-name-directory (file-truename user-init-file)))) - "Where the emacs init file really is, passing through symlinks.") - -;;;; Package Management -(add-to-list 'load-path (expand-file-name "elisp/" user-emacs-directory)) - -(let ((cask-dir (expand-file-name "~/.cask"))) - (if (file-exists-p cask-dir) - (progn - (add-to-list 'load-path cask-dir) - (require 'cask) - (cask-initialize)) - (eval-and-compile - (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") - ("marmalade" . "http://marmalade-repo.org/packages/") - ("melpa" . "http://melpa.milkbox.net/packages/") - ("org" . "http://orgmode.org/elpa/"))) - (package-initialize)) - - (when (not package-archive-contents) - (package-refresh-contents)) - - (mapc (lambda (package-name) - (unless (package-installed-p package-name) - (package-install package-name))) - '(bind-key - diminish - use-package)))) - -(require 'use-package) - -;;;; Style - -(use-package linum - :config (setq linum-format " %4d ")) - -(use-package highlight-symbol - :disabled t - :config (setq highlight-symbol-idle-delay 0.2)) - -(use-package whitespace - :config (setq whitespace-style - '(face - space - tabs - trailing - newline - empty - space-after-tab - tab-mark - space-before-tab - indentation - indentation::space - indentation::tabs))) - -(global-font-lock-mode t) -;; Allow font-lock-mode to do background parsing -(setq jit-lock-stealth-time 1 - jit-lock-stealth-load 100 - jit-lock-chunk-size 1000 - jit-lock-defer-time 0.01) - -(use-package solarized-theme - :config (load-theme 'solarized-light t)) - -(when (or (display-graphic-p) - (daemonp)) - - (defun use-variable-fonts () - (interactive) - (variable-pitch-mode) - (setq cursor-type 'bar)) - - (cond - ((eq window-system 'w32) - (let* ((font-size 10) - (font-list (font-family-list)) - (mono-face (cond - ((member "Liberation Mono" font-list) - "Liberation Mono") - ((member "Liberation Sans Mono" font-list) - "Liberation Sans Mono") - ((member "Consolas" font-list) - "Consolas"))) - (variable-face "Segoe UI") - (default-font (concat mono-face "-" (number-to-string font-size)))) - (when mono-face - (add-to-list 'default-frame-alist `(font . ,default-font)) - (set-face-font 'fixed-pitch default-font)) - (when variable-face - (set-face-font 'variable-pitch (concat variable-face "-" - (number-to-string (1+ font-size))))))) - ((eq system-type 'darwin) - (let* ((font-size 14) - (mono-face "Droid Sans Mono") - (variable-face "Helvetica_Neue") - (default-font (concat mono-face "-" (number-to-string font-size)))) - (when mono-face - (add-to-list 'default-frame-alist `(font . ,default-font))) - (when (and variable-face (display-graphic-p)) - (set-face-font 'variable-pitch (concat variable-face "-" - (number-to-string (1+ font-size))))))))) - -(let* ((font-height (face-attribute 'default :height)) - (small-font-height (max 1 (floor (* .917 font-height))))) - (mapc (lambda (item) - (put (car item) 'customized-face (cadr item)) - (face-spec-set (car item) (cadr item))) - `((linum - ((t (:height ,small-font-height - :foreground unspecified - :inherit fringe - :overline nil - :slant normal)))) - (vertical-border - ((t (:foreground unspecified - :background unspecified - :inherit file-name-shadow)))) - (font-lock-comment-face - ((t (:slant normal)))) - (font-lock-doc-face - ((t (:slant normal)))) - (popup-face - ((t (:background unspecified - :foreground unspecified - :inherit linum - :height ,font-height)))) - (popup-scroll-bar-foreground-face - ((t (:background unspecified - :inherit region)))) - (popup-scroll-bar-background-face - ((t (:background unspecified - :inherit popup-face)))) - (ac-completion-face - ((t (:background unspecified - :foreground unspecified - :inherit popup-face)))) - (ac-candidate-face - ((t (:background unspecified - :foreground unspecified - :inherit linum - :height ,font-height)))) - (ac-selection-face - ((t (:background unspecified - :foreground unspecified - :inherit font-lock-variable-name-face - :inverse-video t)))) - (ac-candidate-mouse-face - ((t (:background unspecified - :foreground unspecified - :inherit region)))) - (ac-dabbrev-menu-face - ((t (:background unspecified - :foreground unspecified - :inherit popup-face)))) - (ac-dabbrev-selection-face - ((t (:background unspecified - :foreground unspecified - :inherit ac-selection-face)))) - (flymake-warnline - ((t (:background unspecified - :foreground unspecified - :inherit font-lock-preprocessor-face)))) - (org-table ((t (:inherit 'fixed-pitch)))) - (org-formula ((t (:foreground "Firebrick" - :inherit 'fixed-pitch)))) - (org-done ((t (:weight normal - :strike-through t)))) - (org-headline-done ((t (:strike-through t))))))) - -;;;; Autosaves & Backups -(let ((backup-dir (expand-file-name "~/.emacs.d/backups/"))) - (unless (file-directory-p backup-dir) - (make-directory backup-dir)) - (setq backup-directory-alist `((".*" . ,backup-dir)) - auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) - backup-by-copying-when-linked t - backup-by-copying-when-mismatch t)) - -;;;; Buffers - -(use-package ibuffer - :bind (("C-x C-b" . ibuffer)) - :config (progn - (setq ibuffer-saved-filter-groups - (quote (("default" - ("org" (mode . org-mode)) - ("emacs" (mode . emacs-lisp-mode)) - ("zsh" (filename . "/zsh")) - ("server" (filename . "/su:root@server")))))) - - ;; Human-readable base-2 size column - (define-ibuffer-column size-h - (:name "Size" :inline t) - (cond - ((> (buffer-size) 1024) - (format "%7.2fK" (/ (buffer-size) 1024.0))) - ((> (buffer-size) 1048576) - (format "%7.2fM" (/ (buffer-size) 1048576.0))) - (t - (format "%8d" (buffer-size))))) - - (setq ibuffer-formats - '((mark modified read-only " " - (name 18 18 :left :elide) - " " - (size-h 9 -1 :right) - " " - (mode 16 16 :left :elide) - " " - filename-and-process))))) - -(use-package uniquify - :config (progn - (setq uniquify-buffer-name-style 'reverse - uniquify-separator "/" - uniquify-after-kill-buffer-p t - uniquify-ignore-buffers-re "^\\*"))) - -(use-package fancy-narrow - :config (fancy-narrow-mode 1)) - -;;;; Communication - -(use-package erc - :config (progn - (setq erc-user-full-name "Alan Pearce" - erc-email-userid "alan@alanpearce.co.uk" - erc-echo-notice-in-minibuffer t - erc-keywords '("alanpearce" "lethalrocks") - erc-autojoin-channels-alist - '(("freenode.net" "#emacs" "##freebsd" "#bufferbloat" "#openwrt" "#lojban" "#zfs" "#introverts") - ("what.cd" "#what.cd") - ("beusergroup.co.uk" "#be"))) - (add-to-list 'erc-modules 'scrolltobottom) - (add-to-list 'erc-modules 'autojoin) - (add-to-list 'erc-modules 'match))) - -(setq message-send-mail-function 'smtpmail-send-it) -(setq smtpmail-smtp-server "external.home" - smtpmail-smtp-service 587) - -(use-package mu4e - :if (and (eq env/location 'home) - (eq env/system-type 'desktop)) - :load-path "/usr/share/emacs/site-lisp/mu4e" - :commands (mu4e) - :config (progn - (setq mu4e-get-mail-command "true" - mu4e-update-interval 300 - mu4e-sent-folder "/alanpearce/Sent" - mu4e-drafts-folder "/alanpearce/Drafts" - mu4e-refile-folder "/alanpearce/Archive") - (bind-key "q" #'bury-buffer mu4e-main-mode-map) - (bind-key "d" #'mu4e-headers-mark-for-delete mu4e-headers-mode-map))) - -;;;; Completion - -(setq completion-styles '(basic initials partial-completion substring) - completion-ignore-case t) - -(use-package smart-tab - :init (global-smart-tab-mode) - :config (progn - (nconc smart-tab-completion-functions-alist '((php-mode . php-complete-function))) - (diminish 'smart-tab-mode ""))) - -(use-package company - :commands (company-mode) - :bind (("C-" . company-complete)) - :init (progn - (add-hook 'prog-mode-hook #'company-mode) - (setq company-idle-delay .3 - company-begin-commands '(self-insert-command)))) - -;;;; Dates & Times - -(use-package calendar - :config (progn - (setq calendar-week-start-day 1) - (calendar-set-date-style 'iso))) - -(defun insert-date (prefix) - "Insert the current date. With prefix-argument, use British format. With - two prefix arguments, write out the day and month name." - (interactive "P") - (let ((format (cond - ((not prefix) "%Y-%m-%d") - ((equal prefix '(4)) "%d/%m/%Y") - ((equal prefix '(16)) "%A, %d %B %Y")))) - (insert (format-time-string format)))) - -;;;; Directory browsing -(use-package dired - :config (progn - (bind-key "" #'dired-find-file dired-mode-map) - (bind-key "^" (lambda () (interactive) (find-alternate-file "..")) dired-mode-map) - (setq dired-dwim-target t - dired-recursive-copies 'top - dired-recursive-deletes 'top - dired-bind-jump nil) - (when (eq system-type 'darwin) - (setq insert-directory-program "/usr/local/bin/gls")) - (put 'dired-find-alternate-file 'disabled nil))) - -(use-package dired+ - :config (progn - (diredp-toggle-find-file-reuse-dir 1) - (dired-omit-mode 1) - (setq dired-omit-files "#\\|\\.$"))) - -;;;; Documentation - -(add-to-list 'Info-default-directory-list - (concat user-emacs-directory - "info")) - -(use-package which-func - :init (which-function-mode) - :config (setq which-func-modes t)) - -;;;; Files - -(prefer-coding-system 'utf-8-auto-unix) -(set-default-coding-systems 'utf-8-auto-unix) -(setq-default buffer-file-coding-system 'utf-8-auto-unix) -(global-auto-revert-mode 1) - -(add-hook 'before-save-hook #'delete-trailing-whitespace) - -(defun rename-current-buffer-file () - "Renames current buffer and file it is visiting." - (interactive) - (let ((name (buffer-name)) - (filename (buffer-file-name))) - (if (not (and filename (file-exists-p filename))) - (error "Buffer '%s' is not visiting a file!" name) - (let ((new-name (read-file-name "New name: " filename))) - (if (get-buffer new-name) - (error "A buffer named '%s' already exists!" new-name) - (cond - ((vc-backend filename) (vc-rename-file filename new-name)) - (t (rename-file filename new-name t) - (rename-buffer new-name) - (set-visited-file-name new-name) - (set-buffer-modified-p nil) - (message "File '%s' successfully renamed to '%s'" - name (file-name-nondirectory new-name))))))))) - -(defun delete-current-buffer-file () - "Removes file connected to current buffer and kills buffer." - (interactive) - (let ((filename (buffer-file-name)) - (buffer (current-buffer))) - (if (not (and filename (file-exists-p filename))) - (ido-kill-buffer) - (when (yes-or-no-p "Are you sure you want to remove this file? ") - (if (vc-backend filename) - (vc-delete-file filename) - (delete-file filename) - (kill-buffer buffer) - (message "File '%s' successfully removed" filename)))))) - -(use-package recentf - :init (progn (setq recentf-auto-cleanup 'never - recentf-save-file (expand-file-name "recentf" user-emacs-directory)) - (recentf-mode 1))) - -(use-package saveplace - :config (progn (setq-default save-place t) - (setq save-place-file (expand-file-name ".saveplace" user-emacs-directory)))) - -(use-package tramp - :config (progn - (setq tramp-default-method (if (eq system-type 'windows-nt) "plinkx" "ssh") - tramp-default-user-alist '(("\\`su\\(do\\)?\\'" nil "root") (nil nil "alan")) - tramp-backup-directory-alist backup-directory-alist - backup-enable-predicate (lambda (name) - (and (normal-backup-enable-predicate name) - (not (let ((method (file-remote-p name 'method))) - (when (stringp method) - (member method '("su" "sudo"))))))) - tramp-shell-prompt-pattern "\\(?:^\\| \\)[^#$%>\n]*#?[#$%>›] *\\(\\[[0-9;]*[a-zA-Z] *\\)*") - (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" (concat "/" tramp-default-method ":%h:"))) - (add-to-list 'tramp-default-proxies-alist '((regexp-quote (system-name)) nil nil)) - (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) - (add-to-list 'tramp-default-proxies-alist '("router" nil nil)))) - -(use-package tramp-sh - :config (progn - (add-to-list 'tramp-remote-path "/usr/local/sbin") - (add-to-list 'tramp-remote-path "~/bin"))) - -(use-package ediff - :config (progn - (setq ediff-split-window-function 'split-window-horizontally - ediff-window-setup-function 'ediff-setup-windows-plain))) - -;;;; Indentation - -(setq-default tab-width 4 - indent-tabs-mode t) -(setq tab-stop-list - ;; (mapcar (lambda (x) - ;; (* 4 x)) - ;; (number-sequence 1 (/ 120 4))) - '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120) - tab-always-indent 'complete) - -(use-package auto-indent-mode - :commands (auto-indent-minor-mode - auto-indent-mode) - :config (progn - (setq auto-indent-key-for-end-of-line-then-newline "" - auto-indent-key-for-end-of-line-insert-char-then-newline "" - auto-indent-blank-lines-on-move nil - auto-indent-assign-indent-level 4 - auto-indent-backward-delete-char-behavior nil - auto-indent-delete-trailing-whitespace-on-save-file t - auto-indent-mode-untabify-on-yank-or-paste nil) - (auto-indent-global-mode) - (defun lisp-auto-indent-mode () - (set (make-local-variable 'auto-indent-assign-indent-level) 2)) - (add-hook 'lisp-common-mode-hook #'lisp-auto-indent-mode))) - -(use-package smart-tabs-mode - :commands (smart-tabs-mode - smart-tabs-mode-enable - smart-tabs-advice) - :config (progn - (smart-tabs-insinuate 'c 'javascript 'cperl 'python) - (add-hook 'php-mode-hook #'smart-tabs-mode-enable))) - -;;;; Keybindings - -(when (eq system-type 'darwin) - (set-keyboard-coding-system nil) - (setq mac-option-modifier 'meta - mac-right-option-modifier 'left - mac-control-modifier 'control - mac-right-control-modifier 'left - mac-command-modifier 'super - mac-right-command-modifier 'left - mac-function-modifier 'hyper)) - -(unbind-key "") -(bind-key "" #'compile) -(bind-key "" #'kmacro-start-macro-or-insert-counter) -(bind-key "" #'kmacro-end-or-call-macro) - -(bind-key "" #'execute-extended-command) - -(unbind-key "C-z") -(bind-key "C-" #'other-window) - -(bind-key "C-x C-r" #'revert-buffer) -(bind-key "C-x C-j" #'delete-indentation) -(unbind-key "C-x C-c") - -(bind-key "C-c i" #'ucs-insert) -(bind-key "M-/" #'hippie-expand) - -(unbind-key "s-h") -(unbind-key "s-n") -(unbind-key "s-p") -(unbind-key "s-w") - -(bind-key "s-x" (define-prefix-command 'super-x-map)) - -(bind-key "s-," (lambda () - (interactive) - (jump-to-register ?e))) -(set-register ?e `(file . ,*init-file*)) -(set-register ?z `(file . ,(expand-file-name ".zshrc" "~"))) - -;; Enable narrowing functions C-x n -(put 'narrow-to-defun 'disabled nil) -(put 'narrow-to-page 'disabled nil) -(put 'narrow-to-region 'disabled nil) - -;;;; Minibuffer - -(setq enable-recursive-minibuffers t) -(minibuffer-depth-indicate-mode t) - -(if (daemonp) - (defalias 'exit-emacs #'delete-frame) - (defalias 'exit-emacs #'save-buffers-kill-emacs)) - -(use-package lacarte - :bind (("M-`" . lacarte-execute-menu-command))) - -(use-package helm-config - :bind (("C-x i" . helm-imenu)) - :config (setq helm-idle-delay .1 - helm-input-idle-delay .1)) - -(use-package ido - :bind (("C-x b" . ido-switch-buffer)) - :init (progn - (setq ido-save-directory-list-file (expand-file-name "ido-state" user-emacs-directory)) - (bind-key* "C-x C-f" #'ido-find-file) - (ido-mode 1)) - :config (progn - (setq ido-auto-merge-delay-time 99999 - ido-enable-flex-matching t) - - (ido-init-completion-maps) - (defun ido-manual-merge () - (interactive) - (ido-initiate-auto-merge (current-buffer))) - (bind-key "C-c C-s" #'ido-manual-merge ido-file-dir-completion-map))) - -(defun ap/ido-projectile-switch-buffer-dwim (force-ido) - (interactive "p") - (if (and (projectile-project-p) (eq force-ido 1)) - (call-interactively #'projectile-switch-to-buffer) - (call-interactively #'ido-switch-buffer))) - -(bind-key "s-x b" #'ap/ido-projectile-switch-buffer-dwim) -(bind-key "s-x s-b" #'ap/ido-projectile-switch-buffer-dwim) - -(use-package ido-vertical-mode - :config (ido-vertical-mode 1)) - -(use-package flx-ido - :init (progn - (flx-ido-mode 1))) - -(use-package smex - :bind (("M-x" . smex) - ("" . smex) - ("" . smex) - ("M-X" . smex-major-mode-commands) - ("C-c M-x" . execute-extended-command)) - :config (progn - (setq smex-key-advice-ignore-menu-bar t - smex-auto-update nil) - (defun smex-update-after-load (_unused) - (if (boundp 'smex-cache) - (smex-update))) - (add-hook 'after-load-functions 'smex-update-after-load)) - :init (progn - (setq smex-history-length 100 - smex-save-file (concat user-emacs-directory - "smex-items")) - (smex-initialize))) - -;;;; Modeline - -(column-number-mode t) -(size-indication-mode t) - -;;;; Modes - -;;;; systemd files -(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-mode)) -(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-mode)) -(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-mode)) - -(use-package xrdb-mode - :mode (("\\.Xdefaults\\'" . xrdb-mode) - ("\\.Xresources\\'" . xrdb-mode))) - -(use-package haskell-mode - :mode (("\\.hs\\'" . haskell-mode) - ("xmobarrc\\'" . haskell-mode))) - -(use-package nginx-mode - :mode (("nginx.conf" . nginx-mode))) - -(use-package lua-mode - :mode (("\\.lua\\'" . lua-mode))) - -(use-package puppet-mode - :mode (("\\.pp\\'" . puppet-mode)) - :config (progn - (add-hook 'puppet-mode-hook #'autopair-mode))) - -(use-package ruby-mode - :mode (("\\.rb\\'" . ruby-mode) - ("\\.cap\\'" . ruby-mode))) - -(use-package yaml-mode - :mode (("/group_vars/.*" . yaml-mode) - ("/host_vars/.*" . yaml-mode)) - :config (progn - (add-hook 'yaml-mode-hook #'autopair-mode))) - -;;;; Planning - -(use-package org - :bind (("C-c C-a" . org-agenda-list) - ("C-c a" . org-agenda) - ("C-c l" . org-store-link) - ("C-c r" . org-remember)) - :config (progn - (setq org-directory "~/org" - org-agenda-files `(,org-directory) - - org-default-notes-file (concat org-directory "/notes") - - ;; Fewer asterisks, doesn't change indentation - org-hide-leading-stars t - - org-startup-indented t - - ;; ‘Remember’: new items at top - org-reverse-note-order t - - org-modules '(org-habit - org-checklist) - - ;; Add time done to ‘done’ tasks - org-log-done 'time - - ;; Allow refiling into any org file - org-refile-targets '((org-agenda-files :maxlevel . 3)) - - org-list-allow-alphabetical t - - org-pretty-entities t - - org-table-duration-custom-format 'seconds - - org-export-have-math t - - org-blank-before-new-entry '((heading . t) - (plain-list-item . auto)) - org-fontify-done-headline t - - org-replace-disputed-keys t - org-todo-keywords '((sequence "TODO" "STARTED" "|" "DONE") - (sequence "TOLEARN" "LEARNING" "LEARNED" "|" "MASTERED") - (sequence "|" "CANCELLED"))) - (set-register ?o `(file . ,(expand-file-name "organiser.org" org-directory))) - (defadvice org-clock-in (after wicked activate) - "Mark STARTED when clocked in" - (save-excursion - (catch 'exit - (org-back-to-heading t) - (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) - (if (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) - (org-todo "STARTED"))))))) - -(use-package org-journal - :config (progn - (setq org-journal-date-format "%A, %d %B %Y"))) - -;;;; Programming - -(use-package cedet - :disabled t - :config (progn - (semantic-load-enable-code-helpers) - (global-semantic-idle-completions-mode t) - (global-semantic-highlight-func-mode t) - (global-semantic-show-unmatched-syntax-mode t) - (global-semantic-decoration-mode t))) - -;;;; Projects - -(use-package projectile - :bind (("C-c C-f" . projectile-find-file) - ("s-x s-f" . projectile-find-file)) - :commands (projectile-global-mode)) - -(use-package project-persist - :commands (project-persist-mode) - :bind (("C-c P d" . project-persist-delete) - ("C-c P f" . project-persist-find) - ("C-c P k" . project-persist-close) - ("C-c P n" . project-persist-create) - ("C-c P s" . project-persist-save)) - :init (eval-when-compile - (autoload #'pp/settings-get "project-persist")) - :config (progn - (project-persist-mode t) - - (setq project-persist-auto-save-global t) - - (add-hook 'project-persist-before-load-hook #'kill-all-buffers) - - (defun emacs-process-p (pid) - "If pid is the process ID of an emacs process, return t, else nil. -Also returns nil if pid is nil." - (when pid - (let ((attributes (process-attributes pid)) (cmd)) - (dolist (attr attributes) - (if (string= "comm" (car attr)) - (setq cmd (cdr attr)))) - (if (and cmd (or (string= "emacs" cmd) (string= "emacs.exe" cmd))) t)))) - - (defadvice desktop-owner (after pry-from-cold-dead-hands activate) - "Don't allow dead emacsen to own the desktop file." - (when (not (emacs-process-p ad-return-value)) - (setq ad-return-value nil))) - - (defun load-project-desktop () - "Load the project's desktop if available" - (ignore-errors - (let ((default-directory project-persist-current-project-settings-dir)) - (desktop-read)))) - - (defun kill-all-buffers () - "Kill all file-based buffers." - (interactive) - (mapc (lambda (buf) - (when (buffer-file-name buf) - (when (and (buffer-modified-p buf) - (y-or-n-p (format "Buffer %s is modified - save it?" (buffer-name buf)))) - (save-some-buffers nil buf)) - (set-buffer-modified-p nil) - (kill-buffer buf))) - (buffer-list))) - - (add-hook 'project-persist-after-close-hook - (lambda () - (kill-all-buffers) - (projectile-global-mode -1))) - - (add-hook 'project-persist-after-load-hook - (lambda () - (setq default-directory (pp/settings-get 'root-dir)) - (load-project-desktop) - (projectile-global-mode 1))) - - (add-hook 'project-persist-after-save-hook - (lambda () - (message (format "Saving project desktop (%s)" project-persist-current-project-settings-dir)) - (desktop-save project-persist-current-project-settings-dir))) -)) - -(use-package vc - :config (progn - (setq vc-follow-symlinks t))) - -(use-package diff-hl - :init (progn - (global-diff-hl-mode) - (add-hook 'magit-refresh-file-buffer-hook #'diff-hl-update))) - -(use-package magit - :commands (magit-status) - :bind (("C-x g" . magit-status) - ("s-G" . magit-status)) - :init (add-hook 'magit-mode-hook #'magit-load-config-extensions)) - -;;;; Spelling -(setq ispell-program-name "aspell" - ispell-dictionary "british") -;; (setq ispell-process-directory (expand-file-name "~/")) -;; If aspell is too slow -;; If it is still too slow, use ‘ultra’ instead of ‘fast’ -;; (setq ispell-extra-args '(" --sug-mode=fast")) -(use-package ispell - :bind (("" . ispell-word))) - -;;;; Scripting - -(add-hook 'after-save-hook - #'executable-make-buffer-file-executable-if-script-p) - -(use-package sh-script - :mode (("\\.zsh\\'" . shell-script-mode)) - :config (setq sh-shell-file "/usr/bin/env zsh")) - -(use-package ntcmd - :mode (("\\`.cmd\\'" . ntcmd-mode) - ("\\`.bat\\'" . ntcmd-mode))) - -;;;; Shells & REPLs - -(use-package eshell - :bind ("C-c s" . eshell) - :config (progn - (setq eshell-directory-name "~/.emacs.d/eshell") - (use-package em-smart - :init (progn - (setq eshell-where-to-jump 'begin - eshell-review-quick-commands nil - eshell-smart-space-goes-to-end t) - (eshell-smart-initialize))))) - -(autoload #'eshell/cd "em-dirs") -(defun eshell-goto-current-dir (&optional arg) - (interactive "P") - (let ((dir default-directory)) - (eshell arg) - (eshell/cd dir))) -(bind-key "C-c S" #'eshell-goto-current-dir) - -(use-package shell - :config (define-key shell-mode-map - (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer)) - -(use-package multi-term - :if (not (eq system-type 'windows-nt)) - :bind ("C-`" . multi-term-dedicated-toggle)) - -(defun comint-delchar-or-eof-or-kill-buffer (arg) - (interactive "p") - (if (null (get-buffer-process (current-buffer))) - (kill-buffer) - (comint-delchar-or-maybe-eof arg))) - -;;;; Text editing - -;; Enable upcase and downcase-region -(put 'upcase-region 'disabled nil) -(put 'downcase-region 'disabled nil) -(setq sentence-end-double-space nil - line-move-visual nil) - -(setq x-select-enable-clipboard t) -(if (functionp 'x-cut-buffer-or-selection-value) - (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)) - -;; replace highlighted text rather than just inserting at point -(delete-selection-mode t) - -(show-paren-mode t) - -(bind-key "S-SPC" #'set-mark-command) - -(use-package subword - :init (global-subword-mode t)) - -(use-package misc - :bind (("M-z" . zap-up-to-char) - ("M-Z" . zap-to-char))) - -(use-package ap-functions - :commands (ap/remove-extra-cr) - :bind (("C-x r M-w" . copy-rectangle) - ("M-!" . shell-execute))) - -(when (boundp 'x-select-request-type) - (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) - -(use-package ace-jump-mode - :bind (("C-c SPC" . ace-jump-mode)) - :config (progn - (ace-jump-mode-enable-mark-sync) - (setq ace-jump-word-mode-use-query-char nil - ace-jump-mode-scope 'window))) - -(use-package autopair - :commands (autopair-mode - autopair-on) - :init (progn - (add-hook 'prog-mode-hook #'autopair-on) - (defun autopair-off () - (autopair-mode -1)) - (add-hook 'lisp-common-mode-hook #'autopair-off) - (setq autopair-blink nil - autopair-skip-whitespace nil))) - -(use-package expand-region - :bind ("C-M-SPC" . er/expand-region)) - -(use-package goto-chg - :bind ("C-x SPC" . goto-last-change)) - -(use-package multiple-cursors - :config (progn - (bind-key "C-." #'mc/mark-next-like-this) - (bind-key "C-," #'mc/mark-previous-like-this) - (bind-key "M-" #'mc/mark-all-like-this-dwim) - (bind-key "C-" #'mc/mark-more-like-this-extended) - (bind-key "C-S-L" #'mc/edit-lines))) - -(use-package eldoc - :config (progn - (eldoc-add-command 'paredit-backward-delete 'paredit-close-round))) - -(use-package paredit - :commands (paredit-mode) - :init (progn - (add-hook 'lisp-common-mode-hook #'enable-paredit-mode) - (put #'paredit-forward-delete 'delete-selection 'supersede) - (put #'paredit-backward-delete 'delete-selection 'supersede) - (add-hook 'minibuffer-setup-hook #'conditionally-enable-paredit-mode) - (defun conditionally-enable-paredit-mode () - "enable paredit-mode during eval-expression" - (if (eq this-command 'eval-expression) - (paredit-mode 1))))) - -(use-package shuffle-lines - :bind (("C-S-" . move-line-up) - ("C-S-" . move-line-down))) - -(use-package smart-forward - :bind (("C-M-u" . smart-up) - ("C-M-d" . smart-down) - ("C-M-p" . smart-backward) - ("C-M-n" . smart-forward))) - -(use-package undo-tree - :config (progn - (global-undo-tree-mode) - ;; Keep region when undoing in region - (defadvice undo-tree-undo (around keep-region activate) - (if (use-region-p) - (let ((m (set-marker (make-marker) (mark))) - (p (set-marker (make-marker) (point)))) - ad-do-it - (goto-char p) - (set-mark m) - (set-marker p nil) - (set-marker m nil)) - ad-do-it))) - :diminish undo-tree-mode) - -;;;; Lisps - -(defun ap/lisp-setup () - (run-hooks 'lisp-common-mode-hook) - (setq indent-tabs-mode nil) - (local-set-key (kbd "RET") #'paredit-newline)) - -(defun set-common-lisp-indentation () - (set (make-local-variable 'lisp-indent-function) - #'common-lisp-indent-function)) - -(add-hook 'emacs-lisp-mode-hook #'ap/lisp-setup) -(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode) - -(add-hook 'scheme-mode-hook #'ap/lisp-setup) -(add-hook 'lisp-mode-hook #'ap/lisp-setup) -(add-hook 'lisp-mode-hook #'set-common-lisp-indentation) - -(use-package elisp-slime-nav - :commands elisp-slime-nav-mode - :diminish elisp-slime-nav-mode) - -(use-package geiser - :commands (geiser-mode - geiser - run-geiser - run-racket) - :config (use-package quack)) - -(use-package redshank - :init (progn - (add-hook 'lisp-common-mode-hook #'turn-on-redshank-mode))) - -(use-package slime - :commands (slime) - :config (progn - (let ((ql-slime-helper (expand-file-name "~/quicklisp/slime-helper.el"))) - (if (file-exists-p ql-slime-helper) - (load ql-slime-helper)) - (slime-setup)) - (setq inferior-lisp-program (executable-find "sbcl")))) - -(defun imenu-elisp-sections () - (setq imenu-prev-index-position-function nil) - (add-to-list 'imenu-generic-expression '("Sections" "^;;;; \\(.+\\)$" 1) t) - (add-to-list 'imenu-generic-expression '("Packages" "^(use-package\\s-+\\(\\(\\sw\\|\\s_\\)+\\)$" 1) t)) - -(defun init-narrow-to-section () - (interactive) - (save-excursion - (beginning-of-line) - (unless (looking-at "^;;;;") - (re-search-backward "^;;;;" nil t)) - (push-mark) - (forward-line) - (re-search-forward "^;;;;" nil t) - (forward-line -1) - (narrow-to-region (region-beginning) (region-end)))) - -(defun init-imenu (p) - (interactive "P") - (find-file-existing *init-file*) - (widen) - (helm-imenu) - (if p (init-narrow-to-section))) - -(add-hook 'emacs-lisp-mode-hook 'imenu-elisp-sections) - -(defun eval-and-replace () - "Replace the preceding sexp with its value." - (interactive) - (backward-kill-sexp) - (condition-case nil - (prin1 (eval (read (current-kill 0))) - (current-buffer)) - (error (message "Invalid expression") - (insert (current-kill 0))))) - -(bind-key "C-c e" #'eval-and-replace) - -;;;; Programming - -(use-package auto-compile - :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) - -(use-package cc-mode - :init (progn - (add-hook 'c-mode-common-hook #'electric-indent-mode)) - :config (progn - (setq c-default-style '((java-mode . "java") - (awk-mode . "awk") - (other . "k&r")) - c-basic-offset 4) - (c-set-offset 'case-label '+))) - -(use-package quickrun) - -;;;; Web Development - -(use-package skewer-mode - :init (progn - (add-hook 'js2-mode-hook #'skewer-mode) - (add-hook 'html-mode-hook #'skewer-html-mode) - (add-hook 'css-mode-hook #'skewer-css-mode))) - -(use-package js2-mode - :mode ("\\.js\\'" . js2-mode) - :config (progn - (defun ap/javascript-setup () - (autopair-mode -1) - (auto-indent-mode -1)) - (add-hook 'js2-mode-hook #'ap/javascript-setup) - (setq js2-basic-offset 4 - js2-global-externs '("$")))) - -(use-package mustache-mode - :mode (("\\.mustache" . mustache-mode) - ("\\.mt\\'" . mustache-mode) - ("\\.template\\'" . mustache-mode))) - -(use-package jinja2-mode - :mode (("\\.j2\\'" . jinja2-mode))) - -(use-package php-mode - :mode ("\\.php\\'" . php-mode) - :config (progn - (bind-key "C-h C-f" #'php-search-documentation php-mode-map) - (unbind-key "C-c C-f" php-mode-map) - (unbind-key "C-." php-mode-map) - (c-add-style "ap" - '((c-basic-offset . 4) - (c-offsets-alist . ((arglist-cont . php-lineup-arglist) - (arglist-intro . php-lineup-arglist-intro) - (arglist-close . php-lineup-arglist-close) - (topmost-intro-cont . (first c-lineup-cascaded-calls - php-lineup-arglist-intro)) - (brace-list-intro . +) - (brace-list-entry . c-lineup-cascaded-calls) - (case-label . 4) - (statement-case-intro . 4) - (defun-close . 0) - (defun-block-intro . +) - (knr-argdecl . [0]) - (arglist-cont-nonempty . c-lineup-cascaded-calls) - (statement-cont . php-lineup-hanging-semicolon))))) - (defun ap/php-style () - (setq indent-tabs-mode t - c-indent-comments-syntactically-p t) - (c-set-style "ap")) - (add-hook 'php-mode-hook #'ap/php-style) - (add-hook 'php-mode-hook #'turn-on-eldoc-mode))) - -(use-package sgml-mode - :config (setq sgml-basic-offset 4)) - -(use-package emmet-mode - :config (progn - (if (functionp 'web-mode) - (add-hook 'web-mode-hook #'emmet-mode)))) - -(use-package web-mode - :mode (("/views/.*\\.php\\'" . web-mode) - ("/templates/.*\\.php\\'" . web-mode)) - :config (setq web-mode-code-indent-offset 4 - web-mode-css-indent-offset 4 - web-mode-markup-indent-offset 4 - web-mode-style-padding 0 - web-mode-script-padding 0 - web-mode-comment-style 2 - web-mode-disable-auto-pairing t)) - -;;;; Windows & Frames - -(setq frame-title-format - '("" - (:eval (capitalize invocation-name)) ": " - (:eval (if (buffer-file-name) - (abbreviate-file-name (buffer-file-name)) - "%b")))) - -(setq scroll-conservatively 100 ; Keep the cursor position when scrolling - scroll-margin 1 - scroll-preserve-screen-position nil - mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control)))) - -(when menu-bar-mode - (menu-bar-mode -1)) -(when scroll-bar-mode - (scroll-bar-mode -1) - (tooltip-mode -1) - (tool-bar-mode -1)) - -(winner-mode 1) - -(use-package windmove - :bind (("S-" . windmove-left) - ("S-" . windmove-right) - ("S-" . windmove-up) - ("S-" . windmove-down))) - -(if (eq system-type 'darwin) - (setq ns-pop-up-frames nil)) diff --git a/git-hooks/post-merge b/git-hooks/post-merge deleted file mode 100755 index 96f2200..0000000 --- a/git-hooks/post-merge +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env zsh -exec "$GIT_DIR/../install" diff --git a/gitconfig b/gitconfig deleted file mode 100644 index 7c21d74..0000000 --- a/gitconfig +++ /dev/null @@ -1,25 +0,0 @@ -[user] - email = alan@alanpearce.co.uk - name = Alan Pearce -[color] - branch = auto - diff = auto - status = auto - ui = true -[push] - default = current -[alias] - st = status -sb - ci = commit - br = branch - co = checkout - ready = rebase -i @{u} - lg = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' - standup = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --since yesterday --author alan - ignored = ls-files --others -i --exclude-standard -[github] - user = alan@alanpearce.co.uk -[diff] - algorithm = patience -[core] - excludesfile = ~/.gitignore diff --git a/gitignore b/gitignore deleted file mode 100644 index 7e23dca..0000000 --- a/gitignore +++ /dev/null @@ -1,29 +0,0 @@ -.DS_Store -.AppleDouble -.LSOverride -Icon -Desktop.ini - -# Thumbnails -._* -Thumbs.db - -# Emacs -*~ -\#*\# -/.emacs.desktop -/.emacs.desktop.lock -.elc -auto-save-list -tramp -.\#* - -.envrc - -# Org-mode -.org-id-locations -*_archive - -GPATH -GRTAGS -GTAGS \ No newline at end of file diff --git a/hgrc b/hgrc deleted file mode 100644 index 2f16f27..0000000 --- a/hgrc +++ /dev/null @@ -1,9 +0,0 @@ -[ui] -username = Alan Pearce - -[extensions] -purge = -progress = -color = -eol = -record = \ No newline at end of file diff --git a/host-prefect/Xresources b/host-prefect/Xresources new file mode 100644 index 0000000..eb45787 --- /dev/null +++ b/host-prefect/Xresources @@ -0,0 +1,4 @@ +#include ".xresources/main" + +Emacs.Font: -*-Droid Sans Mono-medium-*-*-*-*-120-*-*-*-*-*-* +Emacs.fixed-pitch.attributeFont: -*-Droid Sans Mono-medium-*-*-*-*-120-*-*-*-*-*-* diff --git a/minttyrc b/minttyrc deleted file mode 100644 index 2e7f2d8..0000000 --- a/minttyrc +++ /dev/null @@ -1,33 +0,0 @@ -BoldAsFont=no -Font=Cousine -FontHeight=12 -FontSmoothing=default -Locale=en_GB -Charset=UTF-8 -Columns=100 -Rows=36 -Scrollbar=none -Transparency=off -OpaqueWhenFocused=no -CursorType=block -CursorBlinks=no -RightClickAction=extend -BoldBlack=0,43,54 -Black=7,54,66 -BoldGreen=88,110,117 -BoldYellow=101,123,131 -BoldBlue=131,148,150 -BoldCyan=147,161,161 -White=238,232,213 -BoldWhite=253,246,227 -Yellow=181,137,0 -BoldRed=203,75,22 -Red=220,50,47 -Magenta=211,54,130 -BoldMagenta=108,113,196 -Blue=38,139,210 -Cyan=42,161,152 -Green=133,153,0 -ForegroundColour=101,123,117 -BackgroundColour=253,246,227 -CursorColour=112,129,131 diff --git a/ssh/rc b/ssh/rc deleted file mode 100644 index 7b6da3a..0000000 --- a/ssh/rc +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -if [ "$SSH_AUTH_SOCK" ] -then - ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock -fi diff --git a/tag-atop/atoprc b/tag-atop/atoprc new file mode 100644 index 0000000..d03319e --- /dev/null +++ b/tag-atop/atoprc @@ -0,0 +1,2 @@ +flags Aa +maxlinecpu 0 \ No newline at end of file diff --git a/tag-dwm/dwm/config.h b/tag-dwm/dwm/config.h new file mode 100644 index 0000000..ae1d8bb --- /dev/null +++ b/tag-dwm/dwm/config.h @@ -0,0 +1,106 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const char font[] = "-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*"; +static const char normbordercolor[] = "#657b83"; +static const char normbgcolor[] = "#002b36"; +static const char normfgcolor[] = "#fdf6e3"; +static const char selbordercolor[] = "#859900"; +static const char selbgcolor[] = "#586e75"; +static const char selfgcolor[] = "#fdf6e3"; +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const Bool showbar = True; /* False means no bar */ +static const Bool topbar = True; /* False means bottom bar */ + +/* tagging */ +static const char *tags[] = { "shell", "code", "web", "misc" }; + +static const Rule rules[] = { + /* class instance title tags mask isfloating monitor */ + { "Firefox", NULL, NULL, 1 << 2, False, -1 }, + { "URxvt", NULL, NULL, 1 << 0, False, -1 }, + { "Emacs", "emacs", NULL, 1 << 1, False, -1 }, + { "KeePass2", NULL, NULL, 1 << 3, False, -1 }, + { "deadbeef", NULL, NULL, 1 << 3, False, -1 }, + { "Emacs", "Ediff", NULL, 0, True, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const int nmaster = 1; /* number of clients in master area */ +static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, +}; + +/* key definitions */ +#define MODKEY Mod4Mask +#define TAGKEYS(KEY,TAG) \ + { MODKEY, KEY, toggleview, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask, KEY, view, {.ui = 1 << TAG} }, \ + { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + +/* commands */ +static const char *termcmd[] = { "urxvt", NULL }; + +static Key keys[] = { + /* modifier key function argument */ + { MODKEY|ShiftMask, XK_b, togglebar, {0} }, + { MODKEY, XK_e, focusstack, {.i = +1 } }, + { MODKEY, XK_i, focusstack, {.i = -1 } }, + { MODKEY, XK_s, incnmaster, {.i = +1 } }, + { MODKEY, XK_r, incnmaster, {.i = -1 } }, + { MODKEY, XK_n, setmfact, {.f = -0.05} }, + { MODKEY, XK_o, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY, XK_g, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + { MODKEY, XK_comma, focusmon, {.i = -1 } }, + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) + TAGKEYS( XK_4, 3) + TAGKEYS( XK_5, 4) + TAGKEYS( XK_6, 5) + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_q, quit, {0} }, + { MODKEY|ShiftMask, XK_r, quit, { .i = 5 } }, +}; + +/* button definitions */ +/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static Button buttons[] = { + /* click event mask button function argument */ + { ClkLtSymbol, 0, Button1, setlayout, {0} }, + { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, + { ClkWinTitle, 0, Button2, zoom, {0} }, + { ClkStatusText, 0, Button2, spawn, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, toggleview, {0} }, + { ClkTagBar, 0, Button3, view, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; diff --git a/tag-emacs/emacs.d/Cask b/tag-emacs/emacs.d/Cask new file mode 100644 index 0000000..8742df0 --- /dev/null +++ b/tag-emacs/emacs.d/Cask @@ -0,0 +1,74 @@ +(source org) +(source melpa) +(source marmalade) +(source gnu) + +(depends-on "ace-jump-mode") +(depends-on "ag") +(depends-on "auto-compile") +(depends-on "auto-indent-mode") +(depends-on "autopair") +(depends-on "bind-key") +(depends-on "cask") +(depends-on "cdnjs") +(depends-on "company") +(depends-on "confluence") +(depends-on "control-mode") +(depends-on "dash") +(depends-on "dash-at-point") +(depends-on "deferred") +(depends-on "diff-hl") +(depends-on "diminish") +(depends-on "dired+") +(depends-on "discover") +(depends-on "emmet-mode") +(depends-on "epl") +(depends-on "expand-region") +(depends-on "f") +(depends-on "flx") +(depends-on "flx-ido") +(depends-on "framemove") +(depends-on "geiser") +(depends-on "ggtags") +(depends-on "git-commit-mode") +(depends-on "git-rebase-mode") +(depends-on "god-mode") +(depends-on "haskell-mode") +(depends-on "helm") +(depends-on "ido-vertical-mode") +(depends-on "jinja2-mode") +(depends-on "js2-mode") +(depends-on "lua-mode") +(depends-on "magit") +(depends-on "makey") +(depends-on "multi-term") +(depends-on "multiple-cursors") +(depends-on "mustache-mode") +(depends-on "nginx-mode") +(depends-on "org-jira") +(depends-on "org-journal") +(depends-on "org-plus-contrib") +(depends-on "packed") +(depends-on "pallet") +(depends-on "paredit") +(depends-on "php-extras") +(depends-on "php-mode") +(depends-on "pkg-info") +(depends-on "project-persist") +(depends-on "projectile") +(depends-on "puppet-mode") +(depends-on "quickrun") +(depends-on "redshank") +(depends-on "s") +(depends-on "simple-httpd") +(depends-on "skewer-mode") +(depends-on "smart-tab") +(depends-on "smart-tabs-mode") +(depends-on "smex") +(depends-on "solarized-theme") +(depends-on "tup-mode") +(depends-on "undo-tree") +(depends-on "use-package") +(depends-on "web-mode") +(depends-on "xml-rpc") +(depends-on "yaml-mode") \ No newline at end of file diff --git a/tag-emacs/emacs.d/elisp/ap-functions.el b/tag-emacs/emacs.d/elisp/ap-functions.el new file mode 100644 index 0000000..bdc7fae --- /dev/null +++ b/tag-emacs/emacs.d/elisp/ap-functions.el @@ -0,0 +1,47 @@ +;;;###autoload +(defun ap/remove-extra-cr () + "Remove extraneous CR codes from a file" + (interactive) + (save-excursion + (goto-char (point-min)) + (while (search-forward " +" nil t) + (replace-match "")))) + +;;;###autoload +(defun copy-rectangle (start end) + "Copy the region-rectangle." + (interactive "r") + (setq killed-rectangle (extract-rectangle start end))) + +;;;###autoload +(defun eval-and-replace () + "Replace the preceding sexp with its value." + (interactive) + (backward-kill-sexp) + (condition-case nil + (prin1 (eval (read (current-kill 0))) + (current-buffer)) + (error (message "Invalid expression") + (insert (current-kill 0))))) + +;;;###autoload +(defun shell-execute (to-current-buffer) + (interactive "P") + (let ((file-buffer (if (buffer-file-name) + (file-name-nondirectory (buffer-file-name)) + "")) + (command (read-shell-command "Shell command: " nil nil nil))) + (shell-command (replace-regexp-in-string "%" file-buffer command) to-current-buffer))) + +;;;###autoload +(defun narrow-to-region-indirect (start end) + "Restrict editing in this buffer to the current region, indirectly." + (interactive "r") + (deactivate-mark) + (let ((buf (clone-indirect-buffer nil nil))) + (with-current-buffer buf + (narrow-to-region start end)) + (switch-to-buffer buf))) + +(provide 'ap-functions) diff --git a/tag-emacs/emacs.d/elisp/php-electric.el b/tag-emacs/emacs.d/elisp/php-electric.el new file mode 100644 index 0000000..599b2b1 --- /dev/null +++ b/tag-emacs/emacs.d/elisp/php-electric.el @@ -0,0 +1,218 @@ +;; -*- Emacs-Lisp -*- +;; +;; php-electric.el --- electric submode for the php-mode +;; +;; Version: 1.0 +;; Release-Date: Sunday 04 March 2007 +;; +;; Copyright (C) 2007 +;; by Nikolay V. Nemshilov aka St. +;; +;; +;; License +;; +;; 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. +;; +;; +;; Features: +;; * autocompletion of the language contructions +;; such as if, for, foreach, etc blocks, +;; +;; * autocompletion of classes, interfaces and functions +;; definitions +;; +;; * autocompletion of the paired symbols, like [], (), "",'' +;; +;; +;; Usage: +;; Nothing magical, just place the file in a directory where +;; Emacs can find it, and write +;; +;; (require 'php-electric) +;; +;; in your configuration files ~/.emacs or wherever you keep it. +;; Then you can switch on/off the mode by the following command +;; +;; M-x php-electric-mode +;; +;; If you like to have it switched on automatically, you should +;; put the command in your php-mode hook or create new one, +;; like that +;; +;; (add-hook 'php-mode-hook '(lambda () (php-electric-mode))) +;; +;; That's it. +;; +;; +;; Changelog: +;; Sunday 04 March 2007 +;; The first version 1.0 has been came out. +;; + +(defgroup php-electric nil + "Minor php-electric mode" + :group 'php) + +;; list of keywords which expandible by the {} pair +(defconst php-electric-expandible-simple-re + "\\(try\\|else\\|do\\)") + +;; list of keywords which expandible with the (){} construction +(defconst php-electric-expandible-as-struct-re + "\\(while\\|for\\|foreach\\|if\\|elseif\\|catch\\)") + +;; list of keywords which expandible with the name(){} construction +(defconst php-electric-expandible-as-func-re + "\\(function\\)") + +;; list of keywords which expandible with the name{} construction +(defconst php-electric-expandible-as-class-re + "\\(class\\|interface\\)") + +;; list of the paired chars +(defvar php-electric-matching-delimeter-alist + '((?\[ . ?\]) + (?\( . ?\)) + (?\" . ?\") + (?\' . ?\'))) + +;; the minor-mode definition +(define-minor-mode php-electric-mode + "Minor electric-mode for the php-mode" + nil + "-El" + php-mode-map + (php-electric-keymap)) + +;; list of accessible keys +(defun php-electric-keymap() + (define-key php-mode-map " " 'php-electric-space) + (define-key php-mode-map "{" 'php-electric-curlies) + (define-key php-mode-map "(" 'php-electric-brackets) + (define-key php-mode-map "[" 'php-electric-matching-char) + (define-key php-mode-map "\"" 'php-electric-matching-char) + (define-key php-mode-map "\'" 'php-electric-matching-char)) + +;; handler for the spaces insertions +(defun php-electric-space(arg) + (interactive "P") + (self-insert-command (prefix-numeric-value arg)) + (if (php-electric-is-code-at-point-p) + (if (php-electric-line-is-simple-expandible) + ;; inserting just a pair of curleis + (progn + (insert "{")(php-electric-insert-new-line-and-statement-end)) + (if (php-electric-line-is-expandible-as-struct) + ;; inserting a structure definition + (progn + (if (not (char-equal ?\( (preceding-char))) + ;; cmd () { - style construction + (progn + (insert "(")(set-register 98 (point-marker))(insert ") {")) + + ;; cmd( ){ - style construction + (progn + (insert " ")(set-register 98 (point-marker))(insert " ){"))) + (php-electric-insert-new-line-and-statement-end) + (jump-to-register 98)(set-register 98 nil)) + (if (php-electric-line-is-expandible-as-func) + ;; inserting the function expanding + (save-excursion + (insert "(){")(php-electric-insert-new-line-and-statement-end)) + (if (php-electric-line-is-expandible-as-class) + ;; inserting the class expanding + (save-excursion + (insert "{")(php-electric-insert-new-line-and-statement-end)))))))) + +;; handler for the { chars +(defun php-electric-curlies(arg) + (interactive "P") + (self-insert-command (prefix-numeric-value arg)) + (if (php-electric-is-code-at-point-p) + (progn + (php-electric-insert-new-line-and-statement-end)))) + +;; handler for the ( chars +(defun php-electric-brackets(arg) + (interactive "P") + + (if (php-electric-is-code-at-point-p) + ;; checking if it's a statement + (if (php-electric-line-is-expandible-as-struct) + (progn (php-electric-space arg)) + (progn (php-electric-matching-char arg))) + (self-insert-command (prefix-numeric-value arg)))) + +;; handler for the paired chars, [], (), "", '' +(defun php-electric-matching-char(arg) + (interactive "P") + (self-insert-command (prefix-numeric-value arg)) + (if (php-electric-is-code-at-point-p) + (save-excursion + (insert (cdr (assoc last-command-char + php-electric-matching-delimeter-alist)))))) + +;; checks if the current pointer situated in a piece of code +(defun php-electric-is-code-at-point-p() + (and php-electric-mode + (let* ((properties (text-properties-at (point)))) + (and (null (memq 'font-lock-string-face properties)) + (null (memq 'font-lock-comment-face properties)))))) + +;; checks if the current line expandible with a simple {} construction +(defun php-electric-line-is-simple-expandible() + (let* ((php-electric-expandible-simple-real-re + (concat php-electric-expandible-simple-re "\\s-$"))) + (save-excursion + (backward-word 1) + (looking-at php-electric-expandible-simple-real-re)))) + +;; checks if the current line expandible with the (){} construction +(defun php-electric-line-is-expandible-as-struct() + (let* ((php-electric-expandible-as-struct-real-re + (concat php-electric-expandible-as-struct-re "[ ]*$")) + (php-electric-expandible-as-struct-with-bracket-re + (concat php-electric-expandible-as-struct-re "($"))) + (save-excursion + (backward-word 1) + (or (looking-at php-electric-expandible-as-struct-real-re) + (looking-at php-electric-expandible-as-struct-with-bracket-re))))) + +;; checks if the current line expandible with the name(){} construction +(defun php-electric-line-is-expandible-as-func() + (let* ((php-electric-expandible-as-func-real-re + (concat php-electric-expandible-as-func-re "\\s-$"))) + (save-excursion + (backward-word 1) + (looking-at php-electric-expandible-as-func-real-re)))) + +;; checks if the current line expandible with the name{} construction +(defun php-electric-line-is-expandible-as-class() + (let* ((php-electric-expandible-as-class-real-re + (concat php-electric-expandible-as-class-re "\\s-$"))) + (save-excursion + (backward-word 1) + (looking-at php-electric-expandible-as-class-real-re)))) + +;; "shortcut" to insert \n} construction +(defun php-electric-insert-new-line-and-statement-end() + (newline-and-indent)(set-register 99 (point-marker)) + (insert "\n}")(indent-according-to-mode) + (jump-to-register 99)(set-register 99 nil)) + + +(provide 'php-electric) + +;; end of the file \ No newline at end of file diff --git a/tag-emacs/emacs.d/elisp/shuffle-lines.el b/tag-emacs/emacs.d/elisp/shuffle-lines.el new file mode 100644 index 0000000..be0a98f --- /dev/null +++ b/tag-emacs/emacs.d/elisp/shuffle-lines.el @@ -0,0 +1,20 @@ +;;;###autoload +(defun move-line-down () + (interactive) + (let ((col (current-column))) + (save-excursion + (forward-line) + (transpose-lines 1)) + (forward-line) + (move-to-column col))) + +;;;###autoload +(defun move-line-up () + (interactive) + (let ((col (current-column))) + (save-excursion + (forward-line) + (transpose-lines -1)) + (move-to-column col))) + +(provide 'shuffle-lines) diff --git a/tag-emacs/emacs.d/elisp/xrdb-mode.el b/tag-emacs/emacs.d/elisp/xrdb-mode.el new file mode 100644 index 0000000..712f0cb --- /dev/null +++ b/tag-emacs/emacs.d/elisp/xrdb-mode.el @@ -0,0 +1,544 @@ +;;; xrdb-mode.el --- mode for editing X resource database files + +;; Copyright (C) 1998,1999,2000 Free Software Foundation, Inc. + +;; Author: 1994-2003 Barry A. Warsaw +;; Maintainer: barry@python.org +;; Created: May 1994 +;; Keywords: data languages + +(defconst xrdb-version "2.31" + "`xrdb-mode' version number.") + +;; 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. + +;;; Commentary: +;; +;; This file provides a major mode for editing X resource database +;; files. It includes font-lock definitions and commands for +;; controlling indentation, re-indenting by subdivisions, and loading +;; and merging into the the resource database. +;; +;; To use, put the following in your .emacs: +;; +;; (autoload 'xrdb-mode "xrdb-mode" "Mode for editing X resource files" t) +;; +;; You may also want something like: +;; +;; (setq auto-mode-alist +;; (append '(("\\.Xdefaults$" . xrdb-mode) +;; ("\\.Xenvironment$" . xrdb-mode) +;; ("\\.Xresources$" . xrdb-mode) +;; ("*.\\.ad$" . xrdb-mode) +;; ) +;; auto-mode-alist)) + +;;; Credits: +;; +;; The database merge feature was inspired by Joel N. Weber II. +;; +;; The canonical Web site for xrdb-mode is +;; + +;;; Code: +(require 'custom) + + + +(defgroup xrdb nil + "Support for editing X resource database files" + :group 'languages) + +(defcustom xrdb-mode-hook nil + "*Hook to be run when `xrdb-mode' is entered." + :type 'hook + :group 'xrdb) + +(defcustom xrdb-subdivide-by 'paragraph + "*Default alignment subdivision when re-indenting a region or buffer. +This variable controls how much of the buffer is searched to find a +goal column on which to align. Every non-comment line in the region +defined by this variable is scanned for the first `:' character on the +line, and this character's column is the line's goal column. The +rightmost line goal column in the region is taken as the region's goal +column. + +This variable can take one of the following symbol values: + + `buffer' - All lines in the buffer are scanned. This is the + slowest option. + + `paragraph' - All lines in the paragraph are scanned. Paragraphs + are delimited by blank lines, comment lines, and page + delimiters. + + `page' - All lines in the page are scanned. Pages are delimited + with `page-delimiter', usually ^L (control-L). + + `line' - Only the previous non-comment line is scanned. This is + the fastest method. + +This variable is used by the various indentation commands, and can be +overridden in those commands by using \\[universal-argument]." + :type '(radio (const :tag "Do not subdivide buffer" buffer) + (const :tag "Subdivide by paragraphs" paragraph) + (const :tag "Subdivide by pages" page) + (const :tag "Each line is independent" line)) + :group 'xrdb) + +(defcustom xrdb-compress-whitespace nil + "*Collapse all whitespace to a single space after insertion of `:'." + :type 'boolean + :group 'xrdb) + +(defcustom xrdb-program "xrdb" + "*Program to run to load or merge resources in the X resource database." + :type 'string + :group 'xrdb) + +(defcustom xrdb-program-args '("-merge") + "*List of string arguments to pass to `xrdb-program'." + :type '(repeat string) + :group 'xrdb) + +(defvar xrdb-master-file nil + "If non-nil, merge in the named file instead of the buffer's file. +The intent is to allow you to set this variable in the file's local +variable section, e.g.: + + ! Local Variables: + ! xrdb-master-file: \"Xdefaults\" + ! End: + +so that typing \\[xrdb-database-merge-buffer-or-region] in that buffer +merges the named master file instead of the buffer's file. Note that +if the file name has a relative path, the `default-directory' for the +buffer is prepended to come up with a file name. + +You may also want to set `xrdb-program-args' in the local variables +section as well.") +(make-variable-buffer-local 'xrdb-master-file) + + +;; Non-user customizable +(defconst xrdb-comment-re "^[ \t]*[!]" + "Regular expression describing the beginning of a comment line.") + + + +;; utilities +(defun xrdb-point (position) + ;; Returns the value of point at certain commonly referenced POSITIONs. + ;; POSITION can be one of the following symbols: + ;; + ;; bol -- beginning of line + ;; eol -- end of line + ;; bod -- beginning of defun + ;; boi -- back to indentation + ;; ionl -- indentation of next line + ;; iopl -- indentation of previous line + ;; bonl -- beginning of next line + ;; bopl -- beginning of previous line + ;; bop -- beginning of paragraph + ;; eop -- end of paragraph + ;; bopg -- beginning of page + ;; eopg -- end of page + ;; + ;; This function does not modify point or mark. + (let ((here (point))) + (cond + ((eq position 'bod) (beginning-of-defun)) + ((eq position 'bol) (beginning-of-line)) + ((eq position 'eol) (end-of-line)) + ((eq position 'boi) (back-to-indentation)) + ((eq position 'bonl) (forward-line 1)) + ((eq position 'bopl) (forward-line -1)) + ((eq position 'bop) (forward-paragraph -1)) + ((eq position 'eop) (forward-paragraph 1)) + ((eq position 'bopg) (forward-page -1)) + ((eq position 'eopg) (forward-page 1)) + (t + (error "unknown buffer position requested: %s" position))) + (prog1 + (point) + (goto-char here)) + )) + +(defmacro xrdb-safe (&rest body) + ;; safely execute BODY, return nil if an error occurred + `( (condition-case nil + (progn (,@ body)) + (error nil)))) + +(defsubst xrdb-skip-to-separator () + ;; skip forward from the beginning of the line to the separator + ;; character as given by xrdb-separator-char. Returns t if the + ;; char was found, otherwise, nil. + (beginning-of-line) + (skip-chars-forward "^:" (xrdb-point 'eol)) + (and (eq (char-after) ?:) + (current-column))) + +(defsubst xrdb-in-comment-p (&optional lim) + (let* ((lim (or lim (xrdb-point 'bod))) + (state (parse-partial-sexp lim (point)))) + (nth 4 state))) + +(defsubst xrdb-boi-col () + (let ((here (point))) + (goto-char (xrdb-point 'boi)) + (prog1 + (current-column) + (goto-char here)))) + +(defvar xrdb-prompt-history nil) + +(defun xrdb-prompt-for-subdivision () + (let ((options '(("buffer" . buffer) + ("paragraphs" . paragraph) + ("pages" . page) + ("lines" . line))) + (completion-ignore-case t)) + (cdr (assoc + (completing-read "Subdivide alignment by? " options nil t + (cons (format "%s" xrdb-subdivide-by) 0) + 'xrdb-prompt-history) + options)))) + + +;; commands +(defun xrdb-electric-separator (arg) + "Insert a colon, and possibly indent line. +Numeric argument inserts that many separators. If the numeric +argument is not given, or is 1, and the separator is not inserted in a +comment, then the line is indented according to `xrdb-subdivide-by'." + (interactive "P") + (self-insert-command (prefix-numeric-value arg)) + ;; only do electric behavior if arg is not given + (or arg + (xrdb-in-comment-p) + (xrdb-indent-line)) + ;; compress whitespace + (and xrdb-compress-whitespace + (just-one-space))) + +(defun xrdb-electric-bang (arg) + "Insert an exclamation point to start a comment. +Numeric argument inserts that many exclamation characters. If the +numeric argument is not given, or is 1, and the bang character is the +first character on a line, the line is indented to column zero." + (interactive "P") + (let ((how-many (prefix-numeric-value arg))) + (self-insert-command how-many) + (save-excursion + (if (and (= how-many 1) + (xrdb-in-comment-p) + (memq (char-before (xrdb-point 'boi)) '(?\n nil))) + (indent-line-to 0))) + )) + + +(defun xrdb-indent-line (&optional arg) + "Align the current line according to `xrdb-subdivide-by'. +With optional \\[universal-argument], prompt for subdivision." + (interactive "P") + (xrdb-align-to-column + (xrdb-guess-goal-column (if arg + (xrdb-prompt-for-subdivision) + xrdb-subdivide-by)) + (xrdb-point 'bol) + (xrdb-point 'bonl))) + +(defun xrdb-indent-region (start end &optional arg) + "Indent all lines in the region according to `xrdb-subdivide-by'. +With optional \\[universal-argument], prompt for subdivision." + (interactive "r\nP") + (xrdb-align-to-column + (xrdb-guess-goal-column (if arg + (xrdb-prompt-for-subdivision) + xrdb-subdivide-by)) + start end)) + +(defun xrdb-indent-page (&optional arg) + "Indent all lines in the page according to `xrdb-subdivide-by'. +With optional \\[universal-argument], prompt for subdivision." + (interactive "P") + (xrdb-align-to-column + (xrdb-guess-goal-column (if arg + (xrdb-prompt-for-subdivision) + xrdb-subdivide-by)) + (xrdb-point 'bopg) + (xrdb-point 'eopg))) + +(defun xrdb-indent-paragraph (&optional arg) + "Indent all lines in the paragraph according to `xrdb-subdivide-by'. +With optional \\[universal-argument], prompt for subdivision." + (interactive "P") + (xrdb-align-to-column + (xrdb-guess-goal-column (if arg + (xrdb-prompt-for-subdivision) + xrdb-subdivide-by)) + (xrdb-point 'bop) + (xrdb-point 'eop))) + +(defun xrdb-indent-buffer (&optional arg) + "Indent all lines in the buffer according to `xrdb-subdivide-by'. +With optional \\[universal-argument], prompt for subdivision." + (interactive "P") + (let ((subdivide-by (if arg + (xrdb-prompt-for-subdivision) + xrdb-subdivide-by))) + (save-excursion + (beginning-of-buffer) + (if (eq subdivide-by 'buffer) + (xrdb-align-to-column (xrdb-guess-goal-column 'buffer) + (point-min) (point-max)) + (let (mvfwdfunc indentfunc) + (cond + ((eq subdivide-by 'paragraph) + (setq mvfwdfunc 'forward-paragraph + indentfunc 'xrdb-indent-paragraph)) + ((eq subdivide-by 'page) + (setq mvfwdfunc 'forward-page + indentfunc 'xrdb-indent-page)) + ((eq subdivide-by 'line) + (setq mvfwdfunc 'forward-line + indentfunc 'xrdb-indent-page)) + (t (error "Illegal alignment subdivision: %s" subdivide-by)) + ) + (while (< (point) (point-max)) + (funcall indentfunc) + (funcall mvfwdfunc 1)) + ))))) + + +;; internal alignment functions +(defun xrdb-align-to-column (goalcol &optional start end) + (let ((start (or start (xrdb-point 'bol))) + (end (or end (xrdb-point 'bonl)))) + (save-excursion + (save-restriction + (narrow-to-region start end) + (beginning-of-buffer) + (while (< (point) (point-max)) + (if (and (not (looking-at xrdb-comment-re)) + (xrdb-skip-to-separator)) + (indent-line-to (max 0 (+ goalcol + (- (current-column)) + (xrdb-boi-col)) + ))) + (forward-line 1)) + )))) + +(defun xrdb-guess-goal-column (subdivide-by) + ;; Returns the goal column of the current line based on SUBDIVIDE-BY, + ;; which can be any value allowed by `xrdb-subdivide-by'. + (let ((here (point)) + (goalcol 0)) + (save-restriction + (cond + ((eq subdivide-by 'line) + (while (and (zerop (forward-line -1)) + (or (looking-at xrdb-comment-re) + (not (xrdb-skip-to-separator))))) + ;; maybe we didn't find one + (if (not (xrdb-skip-to-separator)) + (goto-char here)) + (narrow-to-region (xrdb-point 'bol) (xrdb-point 'bonl))) + ((eq subdivide-by 'page) + (narrow-to-page)) + ((eq subdivide-by 'paragraph) + (narrow-to-region (xrdb-point 'bop) (xrdb-point 'eop))) + ((eq subdivide-by 'buffer)) + (t (error "Illegal alignment subdivision: %s" subdivide-by))) + (goto-char (point-min)) + (while (< (point) (point-max)) + (if (and (not (looking-at xrdb-comment-re)) + (xrdb-skip-to-separator)) + (setq goalcol (max goalcol (- (current-column) (xrdb-boi-col))))) + (forward-line 1))) + (goto-char here) + goalcol)) + + + +;; major-mode stuff +(defvar xrdb-mode-abbrev-table nil + "Abbreviation table used in `xrdb-mode' buffers.") +(define-abbrev-table 'xrdb-mode-abbrev-table ()) + + +(defvar xrdb-mode-syntax-table nil + "Syntax table used in `xrdb-mode' buffers.") +(if xrdb-mode-syntax-table + nil + (setq xrdb-mode-syntax-table (make-syntax-table)) + (modify-syntax-entry ?! "<" xrdb-mode-syntax-table) + (modify-syntax-entry ?\\ "\\" xrdb-mode-syntax-table) + (modify-syntax-entry ?\n ">" xrdb-mode-syntax-table) + (modify-syntax-entry ?/ ". 14" xrdb-mode-syntax-table) + (modify-syntax-entry ?* "_ 23" xrdb-mode-syntax-table) + (modify-syntax-entry ?. "_" xrdb-mode-syntax-table) + (modify-syntax-entry ?# "_" xrdb-mode-syntax-table) + (modify-syntax-entry ?? "_" xrdb-mode-syntax-table) + (modify-syntax-entry ?< "(" xrdb-mode-syntax-table) + (modify-syntax-entry ?> ")" xrdb-mode-syntax-table) + ) + + +(defvar xrdb-mode-map () + "Keymap used in `xrdb-mode' buffers.") +(if xrdb-mode-map + () + (setq xrdb-mode-map (make-sparse-keymap)) + ;; make the separator key electric + (define-key xrdb-mode-map ":" 'xrdb-electric-separator) + (define-key xrdb-mode-map "!" 'xrdb-electric-bang) + (define-key xrdb-mode-map "\t" 'xrdb-indent-line) + (define-key xrdb-mode-map "\C-c\C-a" 'xrdb-indent-buffer) + (define-key xrdb-mode-map "\C-c\C-b" 'xrdb-submit-bug-report) + (define-key xrdb-mode-map "\C-c\C-c" 'xrdb-database-merge-buffer-or-region) + (define-key xrdb-mode-map "\C-c\C-p" 'xrdb-indent-paragraph) + (define-key xrdb-mode-map "\C-c\[" 'xrdb-indent-page) + (define-key xrdb-mode-map "\C-c\C-r" 'xrdb-indent-region) + ) + +;;;###autoload +(defun xrdb-mode () + "Major mode for editing xrdb config files" + (interactive) + (kill-all-local-variables) + (set-syntax-table xrdb-mode-syntax-table) + (setq major-mode 'xrdb-mode + mode-name "xrdb" + local-abbrev-table xrdb-mode-abbrev-table) + (use-local-map xrdb-mode-map) + (setq font-lock-defaults '(xrdb-font-lock-keywords)) + ;; local variables + (make-local-variable 'parse-sexp-ignore-comments) + (make-local-variable 'comment-start-skip) + (make-local-variable 'comment-start) + (make-local-variable 'comment-end) + (make-local-variable 'paragraph-start) + (make-local-variable 'paragraph-separate) + (make-local-variable 'paragraph-ignore-fill-prefix) + (make-local-variable 'indent-region-function) + ;; now set their values + (setq parse-sexp-ignore-comments t + comment-start-skip "![ \t]*" + comment-start "! " + comment-end "") + (setq indent-region-function 'xrdb-indent-region + paragraph-ignore-fill-prefix t + paragraph-start (concat "^[ \t]*$\\|^[ \t]*[!]\\|" page-delimiter) + paragraph-separate paragraph-start) + (run-hooks 'xrdb-mode-hook)) + + + +;; faces and font-locking +(defvar xrdb-option-name-face 'xrdb-option-name-face + "Face for option name on a line in an X resource db file") + +(defvar xrdb-option-value-face 'xrdb-option-value-face + "Face for option value on a line in an X resource db file") + +(make-face 'xrdb-option-name-face) +(make-face 'xrdb-option-value-face) + +(defun xrdb-font-lock-mode-hook () + (or (face-differs-from-default-p 'xrdb-option-name-face) + (copy-face 'font-lock-keyword-face 'xrdb-option-name-face)) + (or (face-differs-from-default-p 'xrdb-option-value-face) + (copy-face 'font-lock-string-face 'xrdb-option-value-face)) + (remove-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook)) +(add-hook 'font-lock-mode-hook 'xrdb-font-lock-mode-hook) + +(defvar xrdb-font-lock-keywords + (list '("^[ \t]*\\([^\n:]*:\\)[ \t]*\\(.*\\)$" + (1 xrdb-option-name-face) + (2 xrdb-option-value-face))) + "Additional expressions to highlight in X resource db mode.") +(put 'xrdb-mode 'font-lock-defaults '(xrdb-font-lock-keywords)) + + + +;; merging and manipulating the X resource database +(defun xrdb-database-merge-buffer-or-region (start end) + "Merge the current buffer's resources into the X resource database. + +`xrdb-program' is the program to actually call, with the arguments +specified in `xrdb-program-args'. This latter can be set to do either +a merge or a load, etc. Also, if the file local variable +`xrdb-master-file' is non-nil, then it is merged instead of the +buffer's file. + +If the current region is active, it is merged instead of the buffer, +and this overrides any use of `xrdb-master-file'." + (interactive + ;; the idea here is that if the region is inactive, start and end + ;; will be nil, if not passed in programmatically + (list (xrdb-safe (and (mark) (region-beginning))) + (xrdb-safe (and (mark) (region-end))))) + (message "Merging with args: %s..." xrdb-program-args) + (let ((outbuf (get-buffer-create "*Shell Command Output*"))) + ;; I prefer the XEmacs way of doing this, but this is the easiest + ;; way to work in both XEmacs and Emacs. + (with-current-buffer outbuf (erase-buffer)) + (cond + ((and start end) + (apply 'call-process-region start end xrdb-program nil outbuf t + xrdb-program-args)) + (xrdb-master-file + (apply 'call-process xrdb-program xrdb-master-file outbuf t + xrdb-program-args)) + (t + (apply 'call-process-region (point-min) (point-max) xrdb-program + nil outbuf t xrdb-program-args))) + (if (not (zerop (with-current-buffer outbuf (buffer-size)))) + (pop-to-buffer outbuf))) + (message "Merging... done")) + + + +;; submitting bug reports + +(defconst xrdb-mode-help-address "tools-help@python.org" + "Address for xrdb-mode bug reports.") + +(defun xrdb-submit-bug-report () + "Submit via mail a bug report on xrdb-mode." + (interactive) + ;; load in reporter + (require 'reporter) + (let ((reporter-prompt-for-summary-p t) + (varlist '(xrdb-subdivide-by + xrdb-mode-hook + xrdb-compress-whitespace + ))) + (and (if (y-or-n-p "Do you want to submit a report on xrdb-mode? ") + t + (message "") + nil) + (require 'reporter) + (reporter-submit-bug-report + xrdb-mode-help-address + (format "xrdb-mode %s" xrdb-version) + varlist nil nil "Dear Barry,") + ))) + + +(provide 'xrdb-mode) +;;; xrdb-mode.el ends here diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el new file mode 100644 index 0000000..76505ad --- /dev/null +++ b/tag-emacs/emacs.d/init.el @@ -0,0 +1,1170 @@ +;; -*- lexical-binding: t; -*- +;;;; Startup +;; Do not merge echo-area-message sexp +(setq inhibit-startup-echo-area-message "alan") +(setq inhibit-startup-screen t + initial-scratch-message "" + initial-major-mode 'text-mode + user-mail-address "alan@alanpearce.co.uk" + user-full-name "Alan Pearce" + custom-file "~/.emacs.d/custom.el") + +(load custom-file :noerror) + +;;; Allow lisps to use a common setup. I don't know why they don't have some lispy mode as their parent, but this is close enough +(defcustom lisp-common-mode-hook nil + "Hook run when entering any Lisp mode." + :type 'hook + :group 'lisp) + +;;;; Environment & Location + +(defun env/get-location () + "Return the physical location of the system, or `nil' if unknown" + (if (executable-find "netctl") + (catch 'found + (mapc (lambda (line) + (cond + ((string-prefix-p "* home" line) (throw 'found 'home)) + ((string-prefix-p "* work" line) (throw 'found 'work)))) + (process-lines "netctl" "list")) + nil))) + +(defun env/get-system-type () + "Return the type of computer that is running" + (cond + ((string-prefix-p "prefect" system-name) 'desktop) + ((string-prefix-p "server" system-name) 'server) + ((string-prefix-p "sheldon" system-name) 'laptop))) + +(defvar env/location (env/get-location) + "The type of location the system is located in +Values: `work', `home'") + +(defvar env/system-type (env/get-system-type) + "The type of computer Emacs is running on +Values: `desktop', `server', `laptop'") + +(defun env/recheck-location () + (interactive) + (setq env/location (env/get-location))) + +(defvar *init-file* + (when user-init-file + (expand-file-name "init.el" + (file-name-directory (file-truename user-init-file)))) + "Where the emacs init file really is, passing through symlinks.") + +;;;; Package Management +(add-to-list 'load-path (expand-file-name "elisp/" user-emacs-directory)) + +(let ((cask-dir (expand-file-name "~/.cask"))) + (if (file-exists-p cask-dir) + (progn + (add-to-list 'load-path cask-dir) + (require 'cask) + (cask-initialize)) + (eval-and-compile + (setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/") + ("marmalade" . "http://marmalade-repo.org/packages/") + ("melpa" . "http://melpa.milkbox.net/packages/") + ("org" . "http://orgmode.org/elpa/"))) + (package-initialize)) + + (when (not package-archive-contents) + (package-refresh-contents)) + + (mapc (lambda (package-name) + (unless (package-installed-p package-name) + (package-install package-name))) + '(bind-key + diminish + use-package)))) + +(require 'use-package) + +;;;; Style + +(use-package linum + :config (setq linum-format " %4d ")) + +(use-package highlight-symbol + :disabled t + :config (setq highlight-symbol-idle-delay 0.2)) + +(use-package whitespace + :config (setq whitespace-style + '(face + space + tabs + trailing + newline + empty + space-after-tab + tab-mark + space-before-tab + indentation + indentation::space + indentation::tabs))) + +(global-font-lock-mode t) +;; Allow font-lock-mode to do background parsing +(setq jit-lock-stealth-time 1 + jit-lock-stealth-load 100 + jit-lock-chunk-size 1000 + jit-lock-defer-time 0.01) + +(use-package solarized-theme + :config (load-theme 'solarized-light t)) + +(when (or (display-graphic-p) + (daemonp)) + + (defun use-variable-fonts () + (interactive) + (variable-pitch-mode) + (setq cursor-type 'bar)) + + (cond + ((eq window-system 'w32) + (let* ((font-size 10) + (font-list (font-family-list)) + (mono-face (cond + ((member "Liberation Mono" font-list) + "Liberation Mono") + ((member "Liberation Sans Mono" font-list) + "Liberation Sans Mono") + ((member "Consolas" font-list) + "Consolas"))) + (variable-face "Segoe UI") + (default-font (concat mono-face "-" (number-to-string font-size)))) + (when mono-face + (add-to-list 'default-frame-alist `(font . ,default-font)) + (set-face-font 'fixed-pitch default-font)) + (when variable-face + (set-face-font 'variable-pitch (concat variable-face "-" + (number-to-string (1+ font-size))))))) + ((eq system-type 'darwin) + (let* ((font-size 14) + (mono-face "Droid Sans Mono") + (variable-face "Helvetica_Neue") + (default-font (concat mono-face "-" (number-to-string font-size)))) + (when mono-face + (add-to-list 'default-frame-alist `(font . ,default-font))) + (when (and variable-face (display-graphic-p)) + (set-face-font 'variable-pitch (concat variable-face "-" + (number-to-string (1+ font-size))))))))) + +(let* ((font-height (face-attribute 'default :height)) + (small-font-height (max 1 (floor (* .917 font-height))))) + (mapc (lambda (item) + (put (car item) 'customized-face (cadr item)) + (face-spec-set (car item) (cadr item))) + `((linum + ((t (:height ,small-font-height + :foreground unspecified + :inherit fringe + :overline nil + :slant normal)))) + (vertical-border + ((t (:foreground unspecified + :background unspecified + :inherit file-name-shadow)))) + (font-lock-comment-face + ((t (:slant normal)))) + (font-lock-doc-face + ((t (:slant normal)))) + (popup-face + ((t (:background unspecified + :foreground unspecified + :inherit linum + :height ,font-height)))) + (popup-scroll-bar-foreground-face + ((t (:background unspecified + :inherit region)))) + (popup-scroll-bar-background-face + ((t (:background unspecified + :inherit popup-face)))) + (ac-completion-face + ((t (:background unspecified + :foreground unspecified + :inherit popup-face)))) + (ac-candidate-face + ((t (:background unspecified + :foreground unspecified + :inherit linum + :height ,font-height)))) + (ac-selection-face + ((t (:background unspecified + :foreground unspecified + :inherit font-lock-variable-name-face + :inverse-video t)))) + (ac-candidate-mouse-face + ((t (:background unspecified + :foreground unspecified + :inherit region)))) + (ac-dabbrev-menu-face + ((t (:background unspecified + :foreground unspecified + :inherit popup-face)))) + (ac-dabbrev-selection-face + ((t (:background unspecified + :foreground unspecified + :inherit ac-selection-face)))) + (flymake-warnline + ((t (:background unspecified + :foreground unspecified + :inherit font-lock-preprocessor-face)))) + (org-table ((t (:inherit 'fixed-pitch)))) + (org-formula ((t (:foreground "Firebrick" + :inherit 'fixed-pitch)))) + (org-done ((t (:weight normal + :strike-through t)))) + (org-headline-done ((t (:strike-through t))))))) + +;;;; Autosaves & Backups +(let ((backup-dir (expand-file-name "~/.emacs.d/backups/"))) + (unless (file-directory-p backup-dir) + (make-directory backup-dir)) + (setq backup-directory-alist `((".*" . ,backup-dir)) + auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) + backup-by-copying-when-linked t + backup-by-copying-when-mismatch t)) + +;;;; Buffers + +(use-package ibuffer + :bind (("C-x C-b" . ibuffer)) + :config (progn + (setq ibuffer-saved-filter-groups + (quote (("default" + ("org" (mode . org-mode)) + ("emacs" (mode . emacs-lisp-mode)) + ("zsh" (filename . "/zsh")) + ("server" (filename . "/su:root@server")))))) + + ;; Human-readable base-2 size column + (define-ibuffer-column size-h + (:name "Size" :inline t) + (cond + ((> (buffer-size) 1024) + (format "%7.2fK" (/ (buffer-size) 1024.0))) + ((> (buffer-size) 1048576) + (format "%7.2fM" (/ (buffer-size) 1048576.0))) + (t + (format "%8d" (buffer-size))))) + + (setq ibuffer-formats + '((mark modified read-only " " + (name 18 18 :left :elide) + " " + (size-h 9 -1 :right) + " " + (mode 16 16 :left :elide) + " " + filename-and-process))))) + +(use-package uniquify + :config (progn + (setq uniquify-buffer-name-style 'reverse + uniquify-separator "/" + uniquify-after-kill-buffer-p t + uniquify-ignore-buffers-re "^\\*"))) + +(use-package fancy-narrow + :config (fancy-narrow-mode 1)) + +;;;; Communication + +(use-package erc + :config (progn + (setq erc-user-full-name "Alan Pearce" + erc-email-userid "alan@alanpearce.co.uk" + erc-echo-notice-in-minibuffer t + erc-keywords '("alanpearce" "lethalrocks") + erc-autojoin-channels-alist + '(("freenode.net" "#emacs" "##freebsd" "#bufferbloat" "#openwrt" "#lojban" "#zfs" "#introverts") + ("what.cd" "#what.cd") + ("beusergroup.co.uk" "#be"))) + (add-to-list 'erc-modules 'scrolltobottom) + (add-to-list 'erc-modules 'autojoin) + (add-to-list 'erc-modules 'match))) + +(setq message-send-mail-function 'smtpmail-send-it) +(setq smtpmail-smtp-server "external.home" + smtpmail-smtp-service 587) + +(use-package mu4e + :if (and (eq env/location 'home) + (eq env/system-type 'desktop)) + :load-path "/usr/share/emacs/site-lisp/mu4e" + :commands (mu4e) + :config (progn + (setq mu4e-get-mail-command "true" + mu4e-update-interval 300 + mu4e-sent-folder "/alanpearce/Sent" + mu4e-drafts-folder "/alanpearce/Drafts" + mu4e-refile-folder "/alanpearce/Archive") + (bind-key "q" #'bury-buffer mu4e-main-mode-map) + (bind-key "d" #'mu4e-headers-mark-for-delete mu4e-headers-mode-map))) + +;;;; Completion + +(setq completion-styles '(basic initials partial-completion substring) + completion-ignore-case t) + +(use-package smart-tab + :init (global-smart-tab-mode) + :config (progn + (nconc smart-tab-completion-functions-alist '((php-mode . php-complete-function))) + (diminish 'smart-tab-mode ""))) + +(use-package company + :commands (company-mode) + :bind (("C-" . company-complete)) + :init (progn + (add-hook 'prog-mode-hook #'company-mode) + (setq company-idle-delay .3 + company-begin-commands '(self-insert-command)))) + +;;;; Dates & Times + +(use-package calendar + :config (progn + (setq calendar-week-start-day 1) + (calendar-set-date-style 'iso))) + +(defun insert-date (prefix) + "Insert the current date. With prefix-argument, use British format. With + two prefix arguments, write out the day and month name." + (interactive "P") + (let ((format (cond + ((not prefix) "%Y-%m-%d") + ((equal prefix '(4)) "%d/%m/%Y") + ((equal prefix '(16)) "%A, %d %B %Y")))) + (insert (format-time-string format)))) + +;;;; Directory browsing +(use-package dired + :config (progn + (bind-key "" #'dired-find-file dired-mode-map) + (bind-key "^" (lambda () (interactive) (find-alternate-file "..")) dired-mode-map) + (setq dired-dwim-target t + dired-recursive-copies 'top + dired-recursive-deletes 'top + dired-bind-jump nil) + (when (eq system-type 'darwin) + (setq insert-directory-program "/usr/local/bin/gls")) + (put 'dired-find-alternate-file 'disabled nil))) + +(use-package dired+ + :config (progn + (diredp-toggle-find-file-reuse-dir 1) + (dired-omit-mode 1) + (setq dired-omit-files "#\\|\\.$"))) + +;;;; Documentation + +(add-to-list 'Info-default-directory-list + (concat user-emacs-directory + "info")) + +(use-package which-func + :init (which-function-mode) + :config (setq which-func-modes t)) + +;;;; Files + +(prefer-coding-system 'utf-8-auto-unix) +(set-default-coding-systems 'utf-8-auto-unix) +(setq-default buffer-file-coding-system 'utf-8-auto-unix) +(global-auto-revert-mode 1) + +(add-hook 'before-save-hook #'delete-trailing-whitespace) + +(defun rename-current-buffer-file () + "Renames current buffer and file it is visiting." + (interactive) + (let ((name (buffer-name)) + (filename (buffer-file-name))) + (if (not (and filename (file-exists-p filename))) + (error "Buffer '%s' is not visiting a file!" name) + (let ((new-name (read-file-name "New name: " filename))) + (if (get-buffer new-name) + (error "A buffer named '%s' already exists!" new-name) + (cond + ((vc-backend filename) (vc-rename-file filename new-name)) + (t (rename-file filename new-name t) + (rename-buffer new-name) + (set-visited-file-name new-name) + (set-buffer-modified-p nil) + (message "File '%s' successfully renamed to '%s'" + name (file-name-nondirectory new-name))))))))) + +(defun delete-current-buffer-file () + "Removes file connected to current buffer and kills buffer." + (interactive) + (let ((filename (buffer-file-name)) + (buffer (current-buffer))) + (if (not (and filename (file-exists-p filename))) + (ido-kill-buffer) + (when (yes-or-no-p "Are you sure you want to remove this file? ") + (if (vc-backend filename) + (vc-delete-file filename) + (delete-file filename) + (kill-buffer buffer) + (message "File '%s' successfully removed" filename)))))) + +(use-package recentf + :init (progn (setq recentf-auto-cleanup 'never + recentf-save-file (expand-file-name "recentf" user-emacs-directory)) + (recentf-mode 1))) + +(use-package saveplace + :config (progn (setq-default save-place t) + (setq save-place-file (expand-file-name ".saveplace" user-emacs-directory)))) + +(use-package tramp + :config (progn + (setq tramp-default-method (if (eq system-type 'windows-nt) "plinkx" "ssh") + tramp-default-user-alist '(("\\`su\\(do\\)?\\'" nil "root") (nil nil "alan")) + tramp-backup-directory-alist backup-directory-alist + backup-enable-predicate (lambda (name) + (and (normal-backup-enable-predicate name) + (not (let ((method (file-remote-p name 'method))) + (when (stringp method) + (member method '("su" "sudo"))))))) + tramp-shell-prompt-pattern "\\(?:^\\| \\)[^#$%>\n]*#?[#$%>›] *\\(\\[[0-9;]*[a-zA-Z] *\\)*") + (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" (concat "/" tramp-default-method ":%h:"))) + (add-to-list 'tramp-default-proxies-alist '((regexp-quote (system-name)) nil nil)) + (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil)) + (add-to-list 'tramp-default-proxies-alist '("router" nil nil)))) + +(use-package tramp-sh + :config (progn + (add-to-list 'tramp-remote-path "/usr/local/sbin") + (add-to-list 'tramp-remote-path "~/bin"))) + +(use-package ediff + :config (progn + (setq ediff-split-window-function 'split-window-horizontally + ediff-window-setup-function 'ediff-setup-windows-plain))) + +;;;; Indentation + +(setq-default tab-width 4 + indent-tabs-mode t) +(setq tab-stop-list + ;; (mapcar (lambda (x) + ;; (* 4 x)) + ;; (number-sequence 1 (/ 120 4))) + '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60 64 68 72 76 80 84 88 92 96 100 104 108 112 116 120) + tab-always-indent 'complete) + +(use-package auto-indent-mode + :commands (auto-indent-minor-mode + auto-indent-mode) + :config (progn + (setq auto-indent-key-for-end-of-line-then-newline "" + auto-indent-key-for-end-of-line-insert-char-then-newline "" + auto-indent-blank-lines-on-move nil + auto-indent-assign-indent-level 4 + auto-indent-backward-delete-char-behavior nil + auto-indent-delete-trailing-whitespace-on-save-file t + auto-indent-mode-untabify-on-yank-or-paste nil) + (auto-indent-global-mode) + (defun lisp-auto-indent-mode () + (set (make-local-variable 'auto-indent-assign-indent-level) 2)) + (add-hook 'lisp-common-mode-hook #'lisp-auto-indent-mode))) + +(use-package smart-tabs-mode + :commands (smart-tabs-mode + smart-tabs-mode-enable + smart-tabs-advice) + :config (progn + (smart-tabs-insinuate 'c 'javascript 'cperl 'python) + (add-hook 'php-mode-hook #'smart-tabs-mode-enable))) + +;;;; Keybindings + +(when (eq system-type 'darwin) + (set-keyboard-coding-system nil) + (setq mac-option-modifier 'meta + mac-right-option-modifier 'left + mac-control-modifier 'control + mac-right-control-modifier 'left + mac-command-modifier 'super + mac-right-command-modifier 'left + mac-function-modifier 'hyper)) + +(unbind-key "") +(bind-key "" #'compile) +(bind-key "" #'kmacro-start-macro-or-insert-counter) +(bind-key "" #'kmacro-end-or-call-macro) + +(bind-key "" #'execute-extended-command) + +(unbind-key "C-z") +(bind-key "C-" #'other-window) + +(bind-key "C-x C-r" #'revert-buffer) +(bind-key "C-x C-j" #'delete-indentation) +(unbind-key "C-x C-c") + +(bind-key "C-c i" #'ucs-insert) +(bind-key "M-/" #'hippie-expand) + +(unbind-key "s-h") +(unbind-key "s-n") +(unbind-key "s-p") +(unbind-key "s-w") + +(bind-key "s-x" (define-prefix-command 'super-x-map)) + +(bind-key "s-," (lambda () + (interactive) + (jump-to-register ?e))) +(set-register ?e `(file . ,*init-file*)) +(set-register ?z `(file . ,(expand-file-name ".zshrc" "~"))) + +;; Enable narrowing functions C-x n +(put 'narrow-to-defun 'disabled nil) +(put 'narrow-to-page 'disabled nil) +(put 'narrow-to-region 'disabled nil) + +;;;; Minibuffer + +(setq enable-recursive-minibuffers t) +(minibuffer-depth-indicate-mode t) + +(if (daemonp) + (defalias 'exit-emacs #'delete-frame) + (defalias 'exit-emacs #'save-buffers-kill-emacs)) + +(use-package lacarte + :bind (("M-`" . lacarte-execute-menu-command))) + +(use-package helm-config + :bind (("C-x i" . helm-imenu)) + :config (setq helm-idle-delay .1 + helm-input-idle-delay .1)) + +(use-package ido + :bind (("C-x b" . ido-switch-buffer)) + :init (progn + (setq ido-save-directory-list-file (expand-file-name "ido-state" user-emacs-directory)) + (bind-key* "C-x C-f" #'ido-find-file) + (ido-mode 1)) + :config (progn + (setq ido-auto-merge-delay-time 99999 + ido-enable-flex-matching t) + + (ido-init-completion-maps) + (defun ido-manual-merge () + (interactive) + (ido-initiate-auto-merge (current-buffer))) + (bind-key "C-c C-s" #'ido-manual-merge ido-file-dir-completion-map))) + +(defun ap/ido-projectile-switch-buffer-dwim (force-ido) + (interactive "p") + (if (and (projectile-project-p) (eq force-ido 1)) + (call-interactively #'projectile-switch-to-buffer) + (call-interactively #'ido-switch-buffer))) + +(bind-key "s-x b" #'ap/ido-projectile-switch-buffer-dwim) +(bind-key "s-x s-b" #'ap/ido-projectile-switch-buffer-dwim) + +(use-package ido-vertical-mode + :config (ido-vertical-mode 1)) + +(use-package flx-ido + :init (progn + (flx-ido-mode 1))) + +(use-package smex + :bind (("M-x" . smex) + ("" . smex) + ("" . smex) + ("M-X" . smex-major-mode-commands) + ("C-c M-x" . execute-extended-command)) + :config (progn + (setq smex-key-advice-ignore-menu-bar t + smex-auto-update nil) + (defun smex-update-after-load (_unused) + (if (boundp 'smex-cache) + (smex-update))) + (add-hook 'after-load-functions 'smex-update-after-load)) + :init (progn + (setq smex-history-length 100 + smex-save-file (concat user-emacs-directory + "smex-items")) + (smex-initialize))) + +;;;; Modeline + +(column-number-mode t) +(size-indication-mode t) + +;;;; Modes + +;;;; systemd files +(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-mode)) +(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-mode)) +(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-mode)) + +(use-package xrdb-mode + :mode (("\\.Xdefaults\\'" . xrdb-mode) + ("\\.Xresources\\'" . xrdb-mode))) + +(use-package haskell-mode + :mode (("\\.hs\\'" . haskell-mode) + ("xmobarrc\\'" . haskell-mode))) + +(use-package nginx-mode + :mode (("nginx.conf" . nginx-mode))) + +(use-package lua-mode + :mode (("\\.lua\\'" . lua-mode))) + +(use-package puppet-mode + :mode (("\\.pp\\'" . puppet-mode)) + :config (progn + (add-hook 'puppet-mode-hook #'autopair-mode))) + +(use-package ruby-mode + :mode (("\\.rb\\'" . ruby-mode) + ("\\.cap\\'" . ruby-mode))) + +(use-package yaml-mode + :mode (("/group_vars/.*" . yaml-mode) + ("/host_vars/.*" . yaml-mode)) + :config (progn + (add-hook 'yaml-mode-hook #'autopair-mode))) + +;;;; Planning + +(use-package org + :bind (("C-c C-a" . org-agenda-list) + ("C-c a" . org-agenda) + ("C-c l" . org-store-link) + ("C-c r" . org-remember)) + :config (progn + (setq org-directory "~/org" + org-agenda-files `(,org-directory) + + org-default-notes-file (concat org-directory "/notes") + + ;; Fewer asterisks, doesn't change indentation + org-hide-leading-stars t + + org-startup-indented t + + ;; ‘Remember’: new items at top + org-reverse-note-order t + + org-modules '(org-habit + org-checklist) + + ;; Add time done to ‘done’ tasks + org-log-done 'time + + ;; Allow refiling into any org file + org-refile-targets '((org-agenda-files :maxlevel . 3)) + + org-list-allow-alphabetical t + + org-pretty-entities t + + org-table-duration-custom-format 'seconds + + org-export-have-math t + + org-blank-before-new-entry '((heading . t) + (plain-list-item . auto)) + org-fontify-done-headline t + + org-replace-disputed-keys t + org-todo-keywords '((sequence "TODO" "STARTED" "|" "DONE") + (sequence "TOLEARN" "LEARNING" "LEARNED" "|" "MASTERED") + (sequence "|" "CANCELLED"))) + (set-register ?o `(file . ,(expand-file-name "organiser.org" org-directory))) + (defadvice org-clock-in (after wicked activate) + "Mark STARTED when clocked in" + (save-excursion + (catch 'exit + (org-back-to-heading t) + (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) + (if (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) + (org-todo "STARTED"))))))) + +(use-package org-journal + :config (progn + (setq org-journal-date-format "%A, %d %B %Y"))) + +;;;; Programming + +(use-package cedet + :disabled t + :config (progn + (semantic-load-enable-code-helpers) + (global-semantic-idle-completions-mode t) + (global-semantic-highlight-func-mode t) + (global-semantic-show-unmatched-syntax-mode t) + (global-semantic-decoration-mode t))) + +;;;; Projects + +(use-package projectile + :bind (("C-c C-f" . projectile-find-file) + ("s-x s-f" . projectile-find-file)) + :commands (projectile-global-mode)) + +(use-package project-persist + :commands (project-persist-mode) + :bind (("C-c P d" . project-persist-delete) + ("C-c P f" . project-persist-find) + ("C-c P k" . project-persist-close) + ("C-c P n" . project-persist-create) + ("C-c P s" . project-persist-save)) + :init (eval-when-compile + (autoload #'pp/settings-get "project-persist")) + :config (progn + (project-persist-mode t) + + (setq project-persist-auto-save-global t) + + (add-hook 'project-persist-before-load-hook #'kill-all-buffers) + + (defun emacs-process-p (pid) + "If pid is the process ID of an emacs process, return t, else nil. +Also returns nil if pid is nil." + (when pid + (let ((attributes (process-attributes pid)) (cmd)) + (dolist (attr attributes) + (if (string= "comm" (car attr)) + (setq cmd (cdr attr)))) + (if (and cmd (or (string= "emacs" cmd) (string= "emacs.exe" cmd))) t)))) + + (defadvice desktop-owner (after pry-from-cold-dead-hands activate) + "Don't allow dead emacsen to own the desktop file." + (when (not (emacs-process-p ad-return-value)) + (setq ad-return-value nil))) + + (defun load-project-desktop () + "Load the project's desktop if available" + (ignore-errors + (let ((default-directory project-persist-current-project-settings-dir)) + (desktop-read)))) + + (defun kill-all-buffers () + "Kill all file-based buffers." + (interactive) + (mapc (lambda (buf) + (when (buffer-file-name buf) + (when (and (buffer-modified-p buf) + (y-or-n-p (format "Buffer %s is modified - save it?" (buffer-name buf)))) + (save-some-buffers nil buf)) + (set-buffer-modified-p nil) + (kill-buffer buf))) + (buffer-list))) + + (add-hook 'project-persist-after-close-hook + (lambda () + (kill-all-buffers) + (projectile-global-mode -1))) + + (add-hook 'project-persist-after-load-hook + (lambda () + (setq default-directory (pp/settings-get 'root-dir)) + (load-project-desktop) + (projectile-global-mode 1))) + + (add-hook 'project-persist-after-save-hook + (lambda () + (message (format "Saving project desktop (%s)" project-persist-current-project-settings-dir)) + (desktop-save project-persist-current-project-settings-dir))) +)) + +(use-package vc + :config (progn + (setq vc-follow-symlinks t))) + +(use-package diff-hl + :init (progn + (global-diff-hl-mode) + (add-hook 'magit-refresh-file-buffer-hook #'diff-hl-update))) + +(use-package magit + :commands (magit-status) + :bind (("C-x g" . magit-status) + ("s-G" . magit-status)) + :init (add-hook 'magit-mode-hook #'magit-load-config-extensions)) + +;;;; Spelling +(setq ispell-program-name "aspell" + ispell-dictionary "british") +;; (setq ispell-process-directory (expand-file-name "~/")) +;; If aspell is too slow +;; If it is still too slow, use ‘ultra’ instead of ‘fast’ +;; (setq ispell-extra-args '(" --sug-mode=fast")) +(use-package ispell + :bind (("" . ispell-word))) + +;;;; Scripting + +(add-hook 'after-save-hook + #'executable-make-buffer-file-executable-if-script-p) + +(use-package sh-script + :mode (("\\.zsh\\'" . shell-script-mode)) + :config (setq sh-shell-file "/usr/bin/env zsh")) + +(use-package ntcmd + :mode (("\\`.cmd\\'" . ntcmd-mode) + ("\\`.bat\\'" . ntcmd-mode))) + +;;;; Shells & REPLs + +(use-package eshell + :bind ("C-c s" . eshell) + :config (progn + (setq eshell-directory-name "~/.emacs.d/eshell") + (use-package em-smart + :init (progn + (setq eshell-where-to-jump 'begin + eshell-review-quick-commands nil + eshell-smart-space-goes-to-end t) + (eshell-smart-initialize))))) + +(autoload #'eshell/cd "em-dirs") +(defun eshell-goto-current-dir (&optional arg) + (interactive "P") + (let ((dir default-directory)) + (eshell arg) + (eshell/cd dir))) +(bind-key "C-c S" #'eshell-goto-current-dir) + +(use-package shell + :config (define-key shell-mode-map + (kbd "C-d") 'comint-delchar-or-eof-or-kill-buffer)) + +(use-package multi-term + :if (not (eq system-type 'windows-nt)) + :bind ("C-`" . multi-term-dedicated-toggle)) + +(defun comint-delchar-or-eof-or-kill-buffer (arg) + (interactive "p") + (if (null (get-buffer-process (current-buffer))) + (kill-buffer) + (comint-delchar-or-maybe-eof arg))) + +;;;; Text editing + +;; Enable upcase and downcase-region +(put 'upcase-region 'disabled nil) +(put 'downcase-region 'disabled nil) +(setq sentence-end-double-space nil + line-move-visual nil) + +(setq x-select-enable-clipboard t) +(if (functionp 'x-cut-buffer-or-selection-value) + (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)) + +;; replace highlighted text rather than just inserting at point +(delete-selection-mode t) + +(show-paren-mode t) + +(bind-key "S-SPC" #'set-mark-command) + +(use-package subword + :init (global-subword-mode t)) + +(use-package misc + :bind (("M-z" . zap-up-to-char) + ("M-Z" . zap-to-char))) + +(use-package ap-functions + :commands (ap/remove-extra-cr) + :bind (("C-x r M-w" . copy-rectangle) + ("M-!" . shell-execute))) + +(when (boundp 'x-select-request-type) + (setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))) + +(use-package ace-jump-mode + :bind (("C-c SPC" . ace-jump-mode)) + :config (progn + (ace-jump-mode-enable-mark-sync) + (setq ace-jump-word-mode-use-query-char nil + ace-jump-mode-scope 'window))) + +(use-package autopair + :commands (autopair-mode + autopair-on) + :init (progn + (add-hook 'prog-mode-hook #'autopair-on) + (defun autopair-off () + (autopair-mode -1)) + (add-hook 'lisp-common-mode-hook #'autopair-off) + (setq autopair-blink nil + autopair-skip-whitespace nil))) + +(use-package expand-region + :bind ("C-M-SPC" . er/expand-region)) + +(use-package goto-chg + :bind ("C-x SPC" . goto-last-change)) + +(use-package multiple-cursors + :config (progn + (bind-key "C-." #'mc/mark-next-like-this) + (bind-key "C-," #'mc/mark-previous-like-this) + (bind-key "M-" #'mc/mark-all-like-this-dwim) + (bind-key "C-" #'mc/mark-more-like-this-extended) + (bind-key "C-S-L" #'mc/edit-lines))) + +(use-package eldoc + :config (progn + (eldoc-add-command 'paredit-backward-delete 'paredit-close-round))) + +(use-package paredit + :commands (paredit-mode) + :init (progn + (add-hook 'lisp-common-mode-hook #'enable-paredit-mode) + (put #'paredit-forward-delete 'delete-selection 'supersede) + (put #'paredit-backward-delete 'delete-selection 'supersede) + (add-hook 'minibuffer-setup-hook #'conditionally-enable-paredit-mode) + (defun conditionally-enable-paredit-mode () + "enable paredit-mode during eval-expression" + (if (eq this-command 'eval-expression) + (paredit-mode 1))))) + +(use-package shuffle-lines + :bind (("C-S-" . move-line-up) + ("C-S-" . move-line-down))) + +(use-package smart-forward + :bind (("C-M-u" . smart-up) + ("C-M-d" . smart-down) + ("C-M-p" . smart-backward) + ("C-M-n" . smart-forward))) + +(use-package undo-tree + :config (progn + (global-undo-tree-mode) + ;; Keep region when undoing in region + (defadvice undo-tree-undo (around keep-region activate) + (if (use-region-p) + (let ((m (set-marker (make-marker) (mark))) + (p (set-marker (make-marker) (point)))) + ad-do-it + (goto-char p) + (set-mark m) + (set-marker p nil) + (set-marker m nil)) + ad-do-it))) + :diminish undo-tree-mode) + +;;;; Lisps + +(defun ap/lisp-setup () + (run-hooks 'lisp-common-mode-hook) + (setq indent-tabs-mode nil) + (local-set-key (kbd "RET") #'paredit-newline)) + +(defun set-common-lisp-indentation () + (set (make-local-variable 'lisp-indent-function) + #'common-lisp-indent-function)) + +(add-hook 'emacs-lisp-mode-hook #'ap/lisp-setup) +(add-hook 'emacs-lisp-mode-hook #'turn-on-eldoc-mode) + +(add-hook 'scheme-mode-hook #'ap/lisp-setup) +(add-hook 'lisp-mode-hook #'ap/lisp-setup) +(add-hook 'lisp-mode-hook #'set-common-lisp-indentation) + +(use-package elisp-slime-nav + :commands elisp-slime-nav-mode + :diminish elisp-slime-nav-mode) + +(use-package geiser + :commands (geiser-mode + geiser + run-geiser + run-racket) + :config (use-package quack)) + +(use-package redshank + :init (progn + (add-hook 'lisp-common-mode-hook #'turn-on-redshank-mode))) + +(use-package slime + :commands (slime) + :config (progn + (let ((ql-slime-helper (expand-file-name "~/quicklisp/slime-helper.el"))) + (if (file-exists-p ql-slime-helper) + (load ql-slime-helper)) + (slime-setup)) + (setq inferior-lisp-program (executable-find "sbcl")))) + +(defun imenu-elisp-sections () + (setq imenu-prev-index-position-function nil) + (add-to-list 'imenu-generic-expression '("Sections" "^;;;; \\(.+\\)$" 1) t) + (add-to-list 'imenu-generic-expression '("Packages" "^(use-package\\s-+\\(\\(\\sw\\|\\s_\\)+\\)$" 1) t)) + +(defun init-narrow-to-section () + (interactive) + (save-excursion + (beginning-of-line) + (unless (looking-at "^;;;;") + (re-search-backward "^;;;;" nil t)) + (push-mark) + (forward-line) + (re-search-forward "^;;;;" nil t) + (forward-line -1) + (narrow-to-region (region-beginning) (region-end)))) + +(defun init-imenu (p) + (interactive "P") + (find-file-existing *init-file*) + (widen) + (helm-imenu) + (if p (init-narrow-to-section))) + +(add-hook 'emacs-lisp-mode-hook 'imenu-elisp-sections) + +(defun eval-and-replace () + "Replace the preceding sexp with its value." + (interactive) + (backward-kill-sexp) + (condition-case nil + (prin1 (eval (read (current-kill 0))) + (current-buffer)) + (error (message "Invalid expression") + (insert (current-kill 0))))) + +(bind-key "C-c e" #'eval-and-replace) + +;;;; Programming + +(use-package auto-compile + :init (add-hook 'emacs-lisp-mode-hook #'auto-compile-on-save-mode)) + +(use-package cc-mode + :init (progn + (add-hook 'c-mode-common-hook #'electric-indent-mode)) + :config (progn + (setq c-default-style '((java-mode . "java") + (awk-mode . "awk") + (other . "k&r")) + c-basic-offset 4) + (c-set-offset 'case-label '+))) + +(use-package quickrun) + +;;;; Web Development + +(use-package skewer-mode + :init (progn + (add-hook 'js2-mode-hook #'skewer-mode) + (add-hook 'html-mode-hook #'skewer-html-mode) + (add-hook 'css-mode-hook #'skewer-css-mode))) + +(use-package js2-mode + :mode ("\\.js\\'" . js2-mode) + :config (progn + (defun ap/javascript-setup () + (autopair-mode -1) + (auto-indent-mode -1)) + (add-hook 'js2-mode-hook #'ap/javascript-setup) + (setq js2-basic-offset 4 + js2-global-externs '("$")))) + +(use-package mustache-mode + :mode (("\\.mustache" . mustache-mode) + ("\\.mt\\'" . mustache-mode) + ("\\.template\\'" . mustache-mode))) + +(use-package jinja2-mode + :mode (("\\.j2\\'" . jinja2-mode))) + +(use-package php-mode + :mode ("\\.php\\'" . php-mode) + :config (progn + (bind-key "C-h C-f" #'php-search-documentation php-mode-map) + (unbind-key "C-c C-f" php-mode-map) + (unbind-key "C-." php-mode-map) + (c-add-style "ap" + '((c-basic-offset . 4) + (c-offsets-alist . ((arglist-cont . php-lineup-arglist) + (arglist-intro . php-lineup-arglist-intro) + (arglist-close . php-lineup-arglist-close) + (topmost-intro-cont . (first c-lineup-cascaded-calls + php-lineup-arglist-intro)) + (brace-list-intro . +) + (brace-list-entry . c-lineup-cascaded-calls) + (case-label . 4) + (statement-case-intro . 4) + (defun-close . 0) + (defun-block-intro . +) + (knr-argdecl . [0]) + (arglist-cont-nonempty . c-lineup-cascaded-calls) + (statement-cont . php-lineup-hanging-semicolon))))) + (defun ap/php-style () + (setq indent-tabs-mode t + c-indent-comments-syntactically-p t) + (c-set-style "ap")) + (add-hook 'php-mode-hook #'ap/php-style) + (add-hook 'php-mode-hook #'turn-on-eldoc-mode))) + +(use-package sgml-mode + :config (setq sgml-basic-offset 4)) + +(use-package emmet-mode + :config (progn + (if (functionp 'web-mode) + (add-hook 'web-mode-hook #'emmet-mode)))) + +(use-package web-mode + :mode (("/views/.*\\.php\\'" . web-mode) + ("/templates/.*\\.php\\'" . web-mode)) + :config (setq web-mode-code-indent-offset 4 + web-mode-css-indent-offset 4 + web-mode-markup-indent-offset 4 + web-mode-style-padding 0 + web-mode-script-padding 0 + web-mode-comment-style 2 + web-mode-disable-auto-pairing t)) + +;;;; Windows & Frames + +(setq frame-title-format + '("" + (:eval (capitalize invocation-name)) ": " + (:eval (if (buffer-file-name) + (abbreviate-file-name (buffer-file-name)) + "%b")))) + +(setq scroll-conservatively 100 ; Keep the cursor position when scrolling + scroll-margin 1 + scroll-preserve-screen-position nil + mouse-wheel-scroll-amount '(1 ((shift) . 1) ((control)))) + +(when menu-bar-mode + (menu-bar-mode -1)) +(when scroll-bar-mode + (scroll-bar-mode -1) + (tooltip-mode -1) + (tool-bar-mode -1)) + +(winner-mode 1) + +(use-package windmove + :bind (("S-" . windmove-left) + ("S-" . windmove-right) + ("S-" . windmove-up) + ("S-" . windmove-down))) + +(if (eq system-type 'darwin) + (setq ns-pop-up-frames nil)) diff --git a/tag-git/config/git/config b/tag-git/config/git/config new file mode 100644 index 0000000..fb728ff --- /dev/null +++ b/tag-git/config/git/config @@ -0,0 +1,25 @@ +[user] + email = alan@alanpearce.co.uk + name = Alan Pearce +[color] + branch = auto + diff = auto + status = auto + ui = true +[push] + default = current +[alias] + st = status -sb + ci = commit + br = branch + co = checkout + ready = rebase -i @{u} + lg = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' + standup = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --since yesterday --author alan + ignored = ls-files --others -i --exclude-standard +[github] + user = alan@alanpearce.co.uk +[diff] + algorithm = patience +[core] + excludesfile = ~/.config/git/global.gitignore diff --git a/tag-git/config/git/ignore b/tag-git/config/git/ignore new file mode 100644 index 0000000..7e23dca --- /dev/null +++ b/tag-git/config/git/ignore @@ -0,0 +1,29 @@ +.DS_Store +.AppleDouble +.LSOverride +Icon +Desktop.ini + +# Thumbnails +._* +Thumbs.db + +# Emacs +*~ +\#*\# +/.emacs.desktop +/.emacs.desktop.lock +.elc +auto-save-list +tramp +.\#* + +.envrc + +# Org-mode +.org-id-locations +*_archive + +GPATH +GRTAGS +GTAGS \ No newline at end of file diff --git a/tag-hg/hgrc b/tag-hg/hgrc new file mode 100644 index 0000000..2f16f27 --- /dev/null +++ b/tag-hg/hgrc @@ -0,0 +1,9 @@ +[ui] +username = Alan Pearce + +[extensions] +purge = +progress = +color = +eol = +record = \ No newline at end of file diff --git a/tag-minttyrc/minttyrc b/tag-minttyrc/minttyrc new file mode 100644 index 0000000..2e7f2d8 --- /dev/null +++ b/tag-minttyrc/minttyrc @@ -0,0 +1,33 @@ +BoldAsFont=no +Font=Cousine +FontHeight=12 +FontSmoothing=default +Locale=en_GB +Charset=UTF-8 +Columns=100 +Rows=36 +Scrollbar=none +Transparency=off +OpaqueWhenFocused=no +CursorType=block +CursorBlinks=no +RightClickAction=extend +BoldBlack=0,43,54 +Black=7,54,66 +BoldGreen=88,110,117 +BoldYellow=101,123,131 +BoldBlue=131,148,150 +BoldCyan=147,161,161 +White=238,232,213 +BoldWhite=253,246,227 +Yellow=181,137,0 +BoldRed=203,75,22 +Red=220,50,47 +Magenta=211,54,130 +BoldMagenta=108,113,196 +Blue=38,139,210 +Cyan=42,161,152 +Green=133,153,0 +ForegroundColour=101,123,117 +BackgroundColour=253,246,227 +CursorColour=112,129,131 diff --git a/tag-ssh/ssh/rc b/tag-ssh/ssh/rc new file mode 100644 index 0000000..7b6da3a --- /dev/null +++ b/tag-ssh/ssh/rc @@ -0,0 +1,5 @@ +#!/bin/sh +if [ "$SSH_AUTH_SOCK" ] +then + ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock +fi diff --git a/tag-tmux/tmux.conf b/tag-tmux/tmux.conf new file mode 100644 index 0000000..697e123 --- /dev/null +++ b/tag-tmux/tmux.conf @@ -0,0 +1,19 @@ +#setw -g xterm-keys on +#set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" + +set-window-option -g utf8 on +set-option -g status-utf8 on +set-option -g prefix C-z + +bind C-n send-prefix +unbind-key C-b + +set -g default-terminal "screen-256color" + +# Colemak style +bind-key C-i next-window + +set -g base-index 1 + +set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_GIT SSH_CONNECTION WINDOWID XAUTHORITY" +set-environment -g 'SSH_AUTH_SOCK' '/home/alan/.ssh/ssh_auth_sock' \ No newline at end of file diff --git a/tag-xbindkeys/xbindkeysrc.scm b/tag-xbindkeys/xbindkeysrc.scm new file mode 100644 index 0000000..7b00c38 --- /dev/null +++ b/tag-xbindkeys/xbindkeysrc.scm @@ -0,0 +1,57 @@ +;; To specify a key, you can use 'xbindkeys --key' or +;; 'xbindkeys --multikey' and put one of the two lines in this file. + +;; A list of keys is in /usr/include/X11/keysym.h and in +;; /usr/include/X11/keysymdef.h +;; The XK_ is not needed. + +;; List of modifier: +;; Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock), +;; Mod3 (CapsLock), Mod4, Mod5 (Scroll). + + +;; The release modifier is not a standard X modifier, but you can +;; use it if you want to catch release instead of press events + +;; By defaults, xbindkeys does not pay attention to modifiers +;; NumLock, CapsLock and ScrollLock. +;; Uncomment the lines below if you want to use them. +;; To dissable them, call the functions with #f + + +;;;;EXTRA FUNCTIONS: Enable numlock, scrolllock or capslock usage +;;(set-numlock! #t) +;;(set-scrolllock! #t) +;;(set-capslock! #t) + +;;;;; Scheme API reference +;;;; +;; Optional modifier state: +;; (set-numlock! #f or #t) +;; (set-scrolllock! #f or #t) +;; (set-capslock! #f or #t) +;; +;; Shell command key: +;; (xbindkey key "foo-bar-command [args]") +;; (xbindkey '(modifier* key) "foo-bar-command [args]") +;; +;; Scheme function key: +;; (xbindkey-function key function-name-or-lambda-function) +;; (xbindkey-function '(modifier* key) function-name-or-lambda-function) +;; +;; Other functions: +;; (remove-xbindkey key) +;; (run-command "foo-bar-command [args]") +;; (grab-all-keys) +;; (ungrab-all-keys) +;; (remove-all-keys) +;; (debug) + +(xbindkey '(mod4 F9) "mpc toggle") +(xbindkey '(mod4 F10) "mpc prev") +(xbindkey '(mod4 F11) "mpc next") +(xbindkey '(mod4 F12) "mpc stop") + +(xbindkey '(mod4 p) "dmenu_run -fn '-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*' -nb '#002b36' -nf '#fdf6e3' -sb '#586e75' -sf '#fdf6e3' -hist '/home/alan/.cache/dmenu_run_history'") +(xbindkey '(mod4 shift T) "urxvtc") +(xbindkey '(mod4 shift E) "emacsclient -c") diff --git a/tag-xmobar/xmobarrc b/tag-xmobar/xmobarrc new file mode 100644 index 0000000..7dfcef2 --- /dev/null +++ b/tag-xmobar/xmobarrc @@ -0,0 +1,40 @@ +Config { font = "-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*" + , borderColor = "#657b83" + , border = TopB + , bgColor = "#002b36" + , fgColor = "#fdf6e3" + , position = Bottom + , lowerOnStart = False + , hideOnStart = False + , persistent = True + , commands = [ Run Weather "EGNX" ["-t", "ºC" + ,"-L", "12" + ,"-H", "18" + ,"--low", "lightblue" + ,"--normal", "green" + ,"--high", "red" + ] 36000 + , Run DynNetwork ["-t", "Net: ¦KB" + ,"-L", "512" + ,"-H", "10240" + ,"--low", "green" + ,"--normal", "yellow" + ,"--high", "red" + ,"-m", "5" + ] 5 + , Run Cpu ["-p", "3" + ,"-L", "3" + ,"-H", "50" + ,"--normal", "green" + ,"--high", "red" + ] 5 + , Run Memory ["-p", "3" + ,"-t", "Mem: %" + ] 20 + , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 + , Run MPD ["-t", ": - "] 10 + ] + , sepChar = "%" + , alignSep = "}{" + , template = "%cpu% | %memory% | %dynnetwork% | %mpd% }{ %EGNX% | %date%" + } diff --git a/tag-xresources/xresources/main b/tag-xresources/xresources/main new file mode 100644 index 0000000..77c21ce --- /dev/null +++ b/tag-xresources/xresources/main @@ -0,0 +1,33 @@ +#include "solarized-light" + +Xcursor.theme: Neutral +Xcursor.size: 22 + +URxvt.fading: 0 +URxvt.geometry: 100x40 +URxvt.urgentOnBell: true + +URxvt.scrollBar: false +URxvt.scrollstyle: plain +URxvt.scrollTtyOutput: false +URxvt.scrollWithBuffer: true +URxvt.scrollTtyKeypress: true +URxvt.saveLines: 16384 +URxvt.secondaryScroll: false + +URxvt.font: -xos4-terminus-medium-r-normal--14-140-72-72-c-80-*-* +URxvt.boldFont: +URxvt.intensityStyles: true + +URxvt.pointerBlank: true +URxvt.pointerBlankDelay: 987654321 +URxvt.letterSpace: 0 + +Emacs.ToolBar: off +Emacs.MenuBar: off +Emacs.ScrollBars: off +Emacs.CursorBlink: off + +Emacs.Font: -*-Droid Sans Mono-medium-*-*-*-*-140-*-*-*-*-*-* +Emacs.fixed-pitch.attributeFont: -*-Droid Sans Mono-medium-*-*-*-*-140-*-*-*-*-*-* +Emacs.variable-pitch.attributeFont: -*-Arimo-medium-*-*-*-*-160-*-*-*-*-*-* diff --git a/tag-xresources/xresources/solarized-light b/tag-xresources/xresources/solarized-light new file mode 100644 index 0000000..3906b7b --- /dev/null +++ b/tag-xresources/xresources/solarized-light @@ -0,0 +1,70 @@ +! Solarized color scheme for the X Window System +! +! http://ethanschoonover.com/solarized + + +! Common + +#define S_yellow #b58900 +#define S_orange #cb4b16 +#define S_red #dc322f +#define S_magenta #d33682 +#define S_violet #6c71c4 +#define S_blue #268bd2 +#define S_cyan #2aa198 +#define S_green #859900 + + +! Dark + +! #define S_base03 #002b36 +! #define S_base02 #073642 +! #define S_base01 #586e75 +! #define S_base00 #657b83 +! #define S_base0 #839496 +! #define S_base1 #93a1a1 +! #define S_base2 #eee8d5 +! #define S_base3 #fdf6e3 + + +! Light + +#define S_base03 #fdf6e3 +#define S_base02 #eee8d5 +#define S_base01 #93a1a1 +#define S_base00 #839496 +#define S_base0 #657b83 +#define S_base1 #586e75 +#define S_base2 #073642 +#define S_base3 #002b36 + + +! To only apply colors to your terminal, for example, prefix +! the color assignment statement with its name. Example: +! +! URxvt*background: S_base03 + +*background: S_base03 +*foreground: S_base0 +*fading: 40 +*fadeColor: S_base03 +*cursorColor: S_base1 +*pointerColorBackground: S_base01 +*pointerColorForeground: S_base1 + +*color0: S_base02 +*color1: S_red +*color2: S_green +*color3: S_yellow +*color4: S_blue +*color5: S_magenta +*color6: S_cyan +*color7: S_base2 +*color8: S_base03 +*color9: S_orange +*color10: S_base01 +*color11: S_base00 +*color12: S_base0 +*color13: S_violet +*color14: S_base1 +*color15: S_base3 diff --git a/tag-zsh/config/zsh/completion/_tmux_pane_words b/tag-zsh/config/zsh/completion/_tmux_pane_words new file mode 100644 index 0000000..6ff9ce1 --- /dev/null +++ b/tag-zsh/config/zsh/completion/_tmux_pane_words @@ -0,0 +1,10 @@ +local expl +local -a w + +if [[ -z "$TMUX_PANE" ]]; then + _message "not running inside tmux!" + return 1 +fi + +w=( ${(u)=$(tmux capture-pane \; show-buffer \; delete-buffer)} ) +_wanted values expl 'words from current tmux pane' compadd -a w diff --git a/tag-zsh/config/zsh/fasd.zsh b/tag-zsh/config/zsh/fasd.zsh new file mode 100644 index 0000000..64dbf7b --- /dev/null +++ b/tag-zsh/config/zsh/fasd.zsh @@ -0,0 +1,85 @@ +alias a='fasd -a' +alias s='fasd -si' +alias sd='fasd -sid' +alias sf='fasd -sif' +alias d='fasd -d' +alias f='fasd -f' +# function to execute built-in cd +fasd_cd() { + if [ $# -le 1 ]; then + fasd "$@" + else + local _fasd_ret="$(fasd -e 'printf %s' "$@")" + [ -z "$_fasd_ret" ] && return + [ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\n "$_fasd_ret" + fi +} +alias z='fasd_cd -d' +alias zz='fasd_cd -d -i' + +# add zsh hook +_fasd_preexec() { + { eval "fasd --proc $(fasd --sanitize $1)"; } >> "/dev/null" 2>&1 +} +autoload -Uz add-zsh-hook +add-zsh-hook preexec _fasd_preexec + +# zsh command mode completion +_fasd_zsh_cmd_complete() { + local compl + read -c compl + (( $+compstate )) && compstate[insert]=menu # no expand if compsys loaded + reply=(${(f)"$(fasd --complete "$compl")"}) +} + +# enbale command mode completion +compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \ + 'c[-1,-A][-1,-D]' -f -- fasd fasd_cd + +(( $+functions[compdef] )) && { + # zsh word mode completion + _fasd_zsh_word_complete() { + [ "$2" ] && local _fasd_cur="$2" + [ -z "$_fasd_cur" ] && local _fasd_cur="${words[CURRENT]}" + local fnd="${_fasd_cur//,/ }" + local typ=${1:-e} + fasd --query $typ "$fnd" 2>> "/dev/null" | \ + sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do + compadd -U -V fasd "$line" + done + compstate[insert]=menu # no expand + } + _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } + _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } + _fasd_zsh_word_complete_trigger() { + local _fasd_cur="${words[CURRENT]}" + eval $(fasd --word-complete-trigger _fasd_zsh_word_complete $_fasd_cur) + } + # define zle widgets + zle -C fasd-complete complete-word _generic + zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete + zstyle ':completion:fasd-complete:*' menu-select + + zle -C fasd-complete-f complete-word _generic + zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f + zstyle ':completion:fasd-complete-f:*' menu-select + + zle -C fasd-complete-d complete-word _generic + zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d + zstyle ':completion:fasd-complete-d:*' menu-select +} + +(( $+functions[compdef] )) && { + # enable word mode completion + orig_comp="$(zstyle -L ':completion:\*' completer 2>> "/dev/null")" + if [ "$orig_comp" ]; then + case $orig_comp in + *_fasd_zsh_word_complete_trigger*);; + *) eval "$orig_comp _fasd_zsh_word_complete_trigger";; + esac + else + zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger + fi + unset orig_comp +} + diff --git a/tag-zsh/config/zsh/freebsd.zsh b/tag-zsh/config/zsh/freebsd.zsh new file mode 100755 index 0000000..6ca0f8d --- /dev/null +++ b/tag-zsh/config/zsh/freebsd.zsh @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh +function update-check () { + sudo portsnap update + sudo portmaster -L --index-only | awk '/ [Nn]ew / { print substr($0,9,9999) }' + sudo pkg audit + pkg updating -d $( ls -ltr -D '%Y%m%d' /var/db/pkg | awk 'END{print $6}' ) +} +alias iotop="top -m io -o total" diff --git a/tag-zsh/config/zsh/functions/fasd/fasd b/tag-zsh/config/zsh/functions/fasd/fasd new file mode 100755 index 0000000..b1e64f4 --- /dev/null +++ b/tag-zsh/config/zsh/functions/fasd/fasd @@ -0,0 +1,624 @@ +#!/usr/bin/env sh + +# Fasd (this file) can be sourced or executed by any POSIX compatible shell. + +# Fasd is originally written based on code from z (https://github.com/rupa/z) +# by rupa deadwyler under the WTFPL license. Most if not all of the code has +# been rewritten. + +# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +fasd() { + + # make zsh do word splitting inside this function + [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions + + case $1 in + --init) shift + while [ "$1" ]; do + case $1 in + env) + { # source rc files if present + [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" + [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" + + # set default options + [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" + [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" + [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" + [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" + [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null + [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 + [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 + [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native + [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 + [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" + [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ + _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" + + if [ -z "$_FASD_AWK" ]; then + # awk preferences + local awk; for awk in mawk gawk original-awk nawk awk; do + $awk "" && _FASD_AWK=$awk && break + done + fi + } >> "${_FASD_SINK:-/dev/null}" 2>&1 + ;; + + auto) cat <> "$_FASD_SINK" 2>&1 + +EOS + ;; + + posix-alias) cat <& /dev/null || fasd -d'; +EOS + ;; + + zsh-hook) cat <> "$_FASD_SINK" 2>&1 +} +autoload -Uz add-zsh-hook +add-zsh-hook preexec _fasd_preexec + +EOS + ;; + + bash-hook) cat <> "$_FASD_SINK" 2>&1 +} + +# add bash hook +case \$PROMPT_COMMAND in + *_fasd_prompt_func*) ;; + *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; +esac + +EOS + ;; + + posix-hook) cat <> "$_FASD_SINK" 2>&1 +} +case \$PS1 in + *_fasd_ps1_func*) ;; + *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; +esac + +EOS + ;; + + tcsh-hook) cat <& /dev/null'; +EOS + + ;; + + zsh-ccomp) cat <> "$_FASD_SINK" | \\ + sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do + compadd -U -V fasd "\$line" + done + compstate[insert]=menu # no expand + } + _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } + _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } + _fasd_zsh_word_complete_trigger() { + local _fasd_cur="\${words[CURRENT]}" + eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) + } + # define zle widgets + zle -C fasd-complete complete-word _generic + zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete + zstyle ':completion:fasd-complete:*' menu-select + + zle -C fasd-complete-f complete-word _generic + zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f + zstyle ':completion:fasd-complete-f:*' menu-select + + zle -C fasd-complete-d complete-word _generic + zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d + zstyle ':completion:fasd-complete-d:*' menu-select +} + +EOS + ;; + + zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") + \${COMP_LINE#* }" | while read -r line; do + quote_readline "\$line" 2>/dev/null || \\ + printf %q "\$line" 2>/dev/null && \\ + printf \\\\n + done) + local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) +} +_fasd_bash_hook_cmd_complete() { + for cmd in \$*; do + complete -F _fasd_bash_cmd_complete \$cmd + done +} + +EOS + ;; + + bash-ccomp-install) cat <$`{}]\{1,\}/\1 /g' + ;; + + --proc) shift # process commands + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # blacklists + local each; for each in $_FASD_BLACKLIST; do + case " $* " in *\ $each\ *) return;; esac + done + + # shifts + while true; do + case " $_FASD_SHIFT " in + *\ $1\ *) shift;; + *) break;; + esac + done + + # ignores + case " $_FASD_IGNORE " in + *\ $1\ *) return;; + esac + + shift; fasd --add "$@" # add all arguments except command + ;; + + --add|-A) shift # add entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # find all valid path arguments, convert them to simplest absolute form + local paths="$(while [ "$1" ]; do + [ -e "$1" ] && printf %s\\n "$1"; shift + done | sed '/^[^/]/s@^@'"$PWD"'/@ + s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ + | tr '\n' '|')" + + # add current pwd if the option is set + [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" + + [ -z "${paths##\|}" ] && return # stop if we have nothing to add + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' + BEGIN { + split(list, files, "|") + for(i in files) { + path = files[i] + if(path == "") continue + paths[path] = path # array for checking + rank[path] = 1 + time[path] = now + } + } + $2 >= 1 { + if($1 in paths) { + rank[$1] = $2 + 1 / $2 + time[$1] = now + } else { + rank[$1] = $2 + time[$1] = $3 + } + count += $2 + } + END { + if(count > max) + for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging + else + for(i in rank) print i "|" rank[i] "|" time[i] + }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --delete|-D) shift # delete entries + # stop if we don't own $_FASD_DATA or $_FASD_RO is set + [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return + + # turn valid arguments into entry-deleting sed commands + local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ + sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 + s@[^/][^/]*//*\.\./@/@;t 0 + s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ + s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" + + # maintain the file + local tempfile + tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return + + sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" + + if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then + env rm -f "$tempfile" + else + env mv -f "$tempfile" "$_FASD_DATA" + fi + ;; + + --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] + [ -f "$_FASD_DATA" ] || return # no db yet + [ "$1" ] && local typ="$1" + [ "$2" ] && local fnd="$2" + [ "$3" ] && local mode="$3" + + # cat all backends + local each _fasd_data; for each in $_FASD_BACKENDS; do + _fasd_data="$_fasd_data +$(fasd --backend $each)" + done + [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" + + # set mode specific code for calculating the prior + case $mode in + rank) local prior='times[i]';; + recent) local prior='sqrt(100000/(1+t-la[i]))';; + *) local prior='times[i] * frecent(la[i])';; + esac + + if [ "$fnd" ]; then # dafault matching + local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g + s@ @[^|]*@g;s/\$$/|/')" + bre='^[^|]*'"$bre"'[^|/]*|' + local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + else # no case mathcing + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + if [ "$_ret" ]; then + _fasd_data="$_ret" + elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching + local fuzzy_bre="$(printf %s\\n "$fnd" | \ + sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ + s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g + s@ @[^|]*@g')" + fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' + _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" + [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= + fi + fi + else # no query arugments + _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do + [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" + done)" + fi + + # query the database + [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ + $_FASD_AWK -v t="$(date +%s)" -F"|" ' + function frecent(time) { + dx = t-time + if( dx < 3600 ) return 6 + if( dx < 86400 ) return 4 + if( dx < 604800 ) return 2 + return 1 + } + { + if(!paths[$1]) { + times[$1] = $2 + la[$1] = $3 + paths[$1] = 1 + } else { + times[$1] += $2 + if($3 > la[$1]) la[$1] = $3 + } + } + END { + for(i in paths) printf "%-10s %s\n", '"$prior"', i + }' - 2>> "$_FASD_SINK" + ;; + + --backend) + case $2 in + native) cat "$_FASD_DATA";; + viminfo) + < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ + s/^..// + p + }' | $_FASD_AWK -v t="$(date +%s)" '{ + t -= 60 + print $0 "|1|" t + }' + ;; + recently-used) + local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed + tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ + sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ + tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ + sum = 0 + for( i=2; i<=NF; i++ ) sum += $i + print $1 "|" sum + }' + ;; + *) eval "$2";; + esac + ;; + + *) # parsing logic and processing + local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= + while [ "$1" ]; do case $1 in + --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; + --query|--add|--delete|-A|-D) fasd "$@"; return $?;; + --version) [ -z "$comp" ] && echo "1.0.1" && return;; + --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; + -*) local o="${1#-}"; while [ "$o" ]; do case $o in + s*) local show=1;; + l*) local lst=1;; + i*) [ -z "$comp" ] && local interactive=1 show=1;; + r*) local mode=rank;; + t*) local mode=recent;; + e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" + local exec="$o" # anything after "-e" + else # use the next argument + local exec="${2:?"-e: Argument needed "}" + shift + fi; break;; + b*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$o" + else + _FASD_BACKENDS="${2:?"-b: Argument needed"}" + shift + fi; break;; + B*) o="${o#?}"; if [ "$o" ]; then + _FASD_BACKENDS="$_FASD_BACKENDS $o" + else + _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" + shift + fi; break;; + a*) local typ=e;; + d*) local typ=d;; + f*) local typ=f;; + R*) local r=r;; + [0-9]*) local _fasd_i="$o"; break;; + h*) [ -z "$comp" ] && echo "fasd [options] [query ...] +[f|a|s|d|z] [options] [query ...] + options: + -s list paths with scores + -l list paths without scores + -i interactive mode + -e set command to execute on the result file + -b only use backend + -B add additional backend + -a match files and directories + -d match directories only + -f match files only + -r match by rank only + -t match by recent access only + -R reverse listing order + -h show a brief help message + -[0-9] select the nth entry + +fasd [-A|-D] [paths ...] + -A add paths + -D delete paths" >&2 && return;; + esac; o="${o#?}"; done;; + *) fnd="$fnd $1"; last="$1";; + esac; shift; done + + # guess whether the last query is selected from tab completion + case $last in + /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then + $exec "$last" + return + fi;; + esac + + local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r + fnd="${fnd# }" + + local res + res="$(fasd --query 2>> "$_FASD_SINK")" # query the database + [ $? -gt 0 ] && return + if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then + res="$(printf %s\\n "$res" | sort -n${R} | \ + sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" + elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then + if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then + res="$(printf %s\\n "$res" | sort -n${R})" + printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 + printf "> " >&2 + local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 + fi + res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" + elif [ "$lst" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' + return + elif [ "$show" ]; then + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell + res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" + else # no args, show + [ "$res" ] && printf %s\\n "$res" | sort -n${r} + return + fi + if [ "$res" ]; then + fasd --add "$res" + [ -z "$exec" ] && exec='printf %s\n' + $exec "$res" + fi + ;; + esac +} + +fasd --init env + +case $- in + *i*) ;; # assume being sourced, do nothing + *) # assume being executed as an executable + if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then + _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" + else + fasd "$@" + fi;; +esac + diff --git a/tag-zsh/config/zsh/functions/pure/prompt_pure_setup b/tag-zsh/config/zsh/functions/pure/prompt_pure_setup new file mode 100644 index 0000000..5c63503 --- /dev/null +++ b/tag-zsh/config/zsh/functions/pure/prompt_pure_setup @@ -0,0 +1,118 @@ +# Pure +# by Sindre Sorhus +# https://github.com/sindresorhus/pure +# MIT License + +# For my own and others sanity +# git: +# %b => current branch +# %a => current action (rebase/merge) +# prompt: +# %F => color dict +# %f => reset color +# %~ => current path +# %* => time +# %n => username +# %m => shortname host +# %(?..) => prompt conditional - %(condition.true.false) + + +# turns seconds into human readable time +# 165392 => 1d 21h 56m 32s +prompt_pure_human_time() { + local tmp=$1 + local days=$(( tmp / 60 / 60 / 24 )) + local hours=$(( tmp / 60 / 60 % 24 )) + local minutes=$(( tmp / 60 % 60 )) + local seconds=$(( tmp % 60 )) + (( $days > 0 )) && echo -n "${days}d " + (( $hours > 0 )) && echo -n "${hours}h " + (( $minutes > 0 )) && echo -n "${minutes}m " + echo "${seconds}s" +} + +# fastest possible way to check if repo is dirty +prompt_pure_git_dirty() { + # check if we're in a git repo + command git rev-parse --is-inside-work-tree &>/dev/null || return + # check if it's dirty + command git diff --quiet --ignore-submodules HEAD &>/dev/null + + (($? == 1)) && echo '*' +} + +# displays the exec time of the last command if set threshold was exceeded +prompt_pure_cmd_exec_time() { + local stop=$(date +%s) + local start=${cmd_timestamp:-$stop} + integer elapsed=$stop-$start + (($elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5})) && prompt_pure_human_time $elapsed +} + +prompt_pure_preexec() { + cmd_timestamp=$(date +%s) + + # shows the current dir and executed command in the title when a process is active + print -Pn "\e]0;" + echo -nE "$PWD:t: $2" + print -Pn "\a" +} + +# string length ignoring ansi escapes +prompt_pure_string_length() { + echo ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} +} + +prompt_pure_precmd() { + # shows the full path in the title + print -Pn '\e]0;%~\a' + + # git info + vcs_info + + local prompt_pure_preprompt='\n%F{blue}%~%F{242}$vcs_info_msg_0_`prompt_pure_git_dirty` $prompt_pure_username%f %F{yellow}`prompt_pure_cmd_exec_time`%f' + print -P $prompt_pure_preprompt + + # check async if there is anything to pull + (( ${PURE_GIT_PULL:-1} )) && { + # check if we're in a git repo + command git rev-parse --is-inside-work-tree &>/dev/null && + # check check if there is anything to pull + command git fetch &>/dev/null && + # check if there is an upstream configured for this branch + command git rev-parse --abbrev-ref @'{u}' &>/dev/null && + (( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && + # some crazy ansi magic to inject the symbol into the previous line + print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}⇣%f\e8" + } &! + + # reset value since `preexec` isn't always triggered + unset cmd_timestamp +} + + +prompt_pure_setup() { + # prevent percentage showing up + # if output doesn't end with a newline + export PROMPT_EOL_MARK='' + + prompt_opts=(cr subst percent) + + autoload -Uz add-zsh-hook + autoload -Uz vcs_info + + add-zsh-hook precmd prompt_pure_precmd + add-zsh-hook preexec prompt_pure_preexec + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:git*' formats ' %b' + zstyle ':vcs_info:git*' actionformats ' %b|%a' + + # show username@host if logged in through SSH + [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%n@%m ' + + # prompt turns red if the previous command didn't exit with 0 + PROMPT='%(?.%F{magenta}.%F{red})❯%f ' +} + +prompt_pure_setup "$@" diff --git a/tag-zsh/config/zsh/functions/runit/_sv b/tag-zsh/config/zsh/functions/runit/_sv new file mode 100644 index 0000000..bf98b3e --- /dev/null +++ b/tag-zsh/config/zsh/functions/runit/_sv @@ -0,0 +1,7 @@ +#compdef sv + +_arguments -A -S -s \ + '-v[wait up to 7 seconds for the command to take effect. (up|down|term|once|cont|exit)]' \ + '-w+[wait for %n seconds]: :_guard "[0-9]#" "numeric value"' \ + '1:command:(status up down once pause cont hup alarm interrupt quit 1 2 term kill exit start stop restart shutdown force-stop force-reload force-restart force-shutdown check)' \ + '*:installed service:_files -W ${SVDIR:-/service}' diff --git a/tag-zsh/config/zsh/functions/runit/getservicedir b/tag-zsh/config/zsh/functions/runit/getservicedir new file mode 100644 index 0000000..2e5d961 --- /dev/null +++ b/tag-zsh/config/zsh/functions/runit/getservicedir @@ -0,0 +1,2 @@ +#!/usr/bin/env zsh +print ${$(readlink ${SVDIR:-/service}/$1):h} \ No newline at end of file diff --git a/tag-zsh/config/zsh/functions/runit/linksv b/tag-zsh/config/zsh/functions/runit/linksv new file mode 100644 index 0000000..7ee7109 --- /dev/null +++ b/tag-zsh/config/zsh/functions/runit/linksv @@ -0,0 +1,16 @@ +#!/usr/bin/env zsh + +if [[ -z $1 ]]; then + echo "No service specified" + return 64 +fi + + +if [[ ! -x $1 ]]; then + echo "Service does not exist in current directory" + return 1 +fi + +mv $1{,.old} +ln -s =sv $1 +chmod -h a-w $1 diff --git a/tag-zsh/config/zsh/functions/runit/renamesv b/tag-zsh/config/zsh/functions/runit/renamesv new file mode 100644 index 0000000..dba1098 --- /dev/null +++ b/tag-zsh/config/zsh/functions/runit/renamesv @@ -0,0 +1,36 @@ +#!/usr/bin/env zsh +local svdir=${SVDIR:-/service} +if [[ -z $1 || -z $2 ]]; then + echo "Usage: $0 source target" + return 64 +fi + +if [[ ! -h $svdir/$1 ]]; then + echo $svdir/$1 does not exist + return 2 +fi + +if [[ -e $svdir/$2 ]]; then + echo $svdir/$2 already exists + return 3 +fi + +local servicedir=`getservicedir` + +if [[ ! ( -w $svdir && -w $servicedir ) ]]; then + echo $svdir or $servicedir is not writeable +fi + +# The service doesn't have to be stopped as removing the link will do that +# However, running the same service twice isn't a great idea, so wait here +sv stop $1 + +rm -f $svdir/$1 || return + +mv $servicedir/{$1,$2} || return + +ln -s {$servicedir,$svdir}/$2 || return + +sv start $2 + +return diff --git a/tag-zsh/config/zsh/prefect.zsh b/tag-zsh/config/zsh/prefect.zsh new file mode 100644 index 0000000..997ba39 --- /dev/null +++ b/tag-zsh/config/zsh/prefect.zsh @@ -0,0 +1,10 @@ +EDITOR="emacs" +VISUAL="emacs" + +if [[ ! -S $SSH_AUTH_SOCK ]] +then + eval `ssh-agent | sed -e '/^echo/d'` + linkAuthSock $SSH_AUTH_SOCK +fi + +export WINEARCH="win32" \ No newline at end of file diff --git a/tag-zsh/config/zsh/server.zsh b/tag-zsh/config/zsh/server.zsh new file mode 100644 index 0000000..d9d7421 --- /dev/null +++ b/tag-zsh/config/zsh/server.zsh @@ -0,0 +1,20 @@ +# -*- shell-script -*- + +export SVDIR=/service +if [[ "$EUID" == "0" ]] || [[ "$USER" == "root" ]] +then + export EDITOR="emacs -nw" +else + export ALTERNATE_EDITOR="emacs" + export EDITOR="emacsclient" +fi + +mailpath= + +# Folder aliases +hash -d music=/tank/media/Music + +zstyle ':completion:*' local server /tank/www/internal '' +zstyle ':completion:*' local external /tank/www/external +zstyle ':completion:*' local alphapulsar.uk.to /tank/www/gaming +zstyle ':completion:*' local home.alanpearce.co.uk /tank/www/external diff --git a/tag-zsh/config/zsh/zlogin b/tag-zsh/config/zsh/zlogin new file mode 100755 index 0000000..e69de29 diff --git a/tag-zsh/config/zsh/zlogout b/tag-zsh/config/zsh/zlogout new file mode 100755 index 0000000..e69de29 diff --git a/tag-zsh/config/zsh/zshenv b/tag-zsh/config/zsh/zshenv new file mode 100755 index 0000000..11932e6 --- /dev/null +++ b/tag-zsh/config/zsh/zshenv @@ -0,0 +1,53 @@ +if [[ $defpath == "" && -d ~/bin ]] +then + defpath=($path) + path=( + $defpath + ~/bin + ) + if [[ -d ~/.gem/ruby/*/bin ]] + then + path=( + $path + ~/.gem/ruby/*/bin + ) + fi +fi + +export PATH + +myfuncs=( ~/projects/dotfiles/zsh/functions/*(/) ) +fpath=( + $myfuncs + ~/projects/dotfiles/zsh/completion/ + $fpath +) +if [[ -d /usr/local/share/zsh-completions ]] +then + fpath=(/usr/local/share/zsh-completions $fpath) +fi + +if [[ -d /usr/local/share/zsh/site-functions ]] +then + fpath=(/usr/local/share/zsh/site-functions $fpath) +fi + +export FPATH + +case $OSTYPE in + *gnu*) + os=gnu + ;; + freebsd*) + os=freebsd + ;; + darwin*) + os=osx +esac + +export os + +if [[ -s $commands[direnv] ]] +then + eval "$(direnv hook zsh)" +fi diff --git a/tag-zsh/config/zsh/zshrc b/tag-zsh/config/zsh/zshrc new file mode 100755 index 0000000..365214c --- /dev/null +++ b/tag-zsh/config/zsh/zshrc @@ -0,0 +1,362 @@ +export PAGER="less" +export EDITOR="emacsclient" +export CLICOLOR=true + +# +# zsh variables +# +HISTFILE=~/.zsh/history +HISTSIZE=4000 +SAVEHIST=3000 + +WORDCHARS='*?_-[]~=.&;!#$%^(){}<>' + +#If a command takes more than 5 seconds, give statistics +REPORTTIME=5 +TIMEFMT="%U user %S system %P cpu %*Es total" + +#Check for user logins +watch=notme +WATCHFMT="%n has %a %l from %M at %t" + +hosts=( + server + prefect + alanpearce.co.uk + home.alanpearce.co.uk +) + +users=(alan root toor) + +function linkAuthSock () { + local linkSock=~/.ssh/ssh_auth_sock + ln -sf $1 ~/.ssh/ssh_auth_sock + export SSH_AUTH_SOCK=$linkSock +} + +if [[ "$SSH_AUTH_SOCK" != "" ]] +then + if [[ -e ~/.ssh/ssh_auth_sock && ! -L ~/.ssh/ssh_auth_sock ]] + then + linkAuthSock $SSH_AUTH_SOCK + fi +fi + +LS_COLORS='no=00:fi=00:di=36:ln=35:pi=30;44:so=35;44:do=35;44:bd=33;44:cd=37;44:or=05;37;41:mi=05;37;41:ex=01;31:*.cmd=01;31:*.exe=01;31:*.com=01;31:*.bat=01;31:*.reg=01;31:*.app=01;31:*.txt=32:*.org=32:*.md=32:*.mkd=32:*.h=32:*.c=32:*.C=32:*.cc=32:*.cpp=32:*.cxx=32:*.objc=32:*.sh=32:*.csh=32:*.zsh=32:*.el=32:*.vim=32:*.java=32:*.pl=32:*.pm=32:*.py=32:*.rb=32:*.hs=32:*.php=32:*.htm=32:*.html=32:*.shtml=32:*.erb=32:*.haml=32:*.xml=32:*.rdf=32:*.css=32:*.sass=32:*.scss=32:*.less=32:*.js=32:*.coffee=32:*.man=32:*.0=32:*.1=32:*.2=32:*.3=32:*.4=32:*.5=32:*.6=32:*.7=32:*.8=32:*.9=32:*.l=32:*.n=32:*.p=32:*.pod=32:*.tex=32:*.bmp=33:*.cgm=33:*.dl=33:*.dvi=33:*.emf=33:*.eps=33:*.gif=33:*.jpeg=33:*.jpg=33:*.JPG=33:*.mng=33:*.pbm=33:*.pcx=33:*.pdf=33:*.pgm=33:*.png=33:*.ppm=33:*.pps=33:*.ppsx=33:*.ps=33:*.svg=33:*.svgz=33:*.tga=33:*.tif=33:*.tiff=33:*.xbm=33:*.xcf=33:*.xpm=33:*.xwd=33:*.xwd=33:*.yuv=33:*.aac=33:*.au=33:*.flac=33:*.mid=33:*.midi=33:*.mka=33:*.mp3=33:*.mpa=33:*.mpeg=33:*.mpg=33:*.ogg=33:*.ra=33:*.wav=33:*.anx=33:*.asf=33:*.avi=33:*.axv=33:*.flc=33:*.fli=33:*.flv=33:*.gl=33:*.m2v=33:*.m4v=33:*.mkv=33:*.mov=33:*.mp4=33:*.mp4v=33:*.mpeg=33:*.mpg=33:*.nuv=33:*.ogm=33:*.ogv=33:*.ogx=33:*.qt=33:*.rm=33:*.rmvb=33:*.swf=33:*.vob=33:*.wmv=33:*.doc=31:*.docx=31:*.rtf=31:*.dot=31:*.dotx=31:*.xls=31:*.xlsx=31:*.ppt=31:*.pptx=31:*.fla=31:*.psd=31:*.7z=1;35:*.apk=1;35:*.arj=1;35:*.bin=1;35:*.bz=1;35:*.bz2=1;35:*.cab=1;35:*.deb=1;35:*.dmg=1;35:*.gem=1;35:*.gz=1;35:*.iso=1;35:*.jar=1;35:*.msi=1;35:*.rar=1;35:*.rpm=1;35:*.tar=1;35:*.tbz=1;35:*.tbz2=1;35:*.tgz=1;35:*.tx=1;35:*.war=1;35:*.xpi=1;35:*.xz=1;35:*.z=1;35:*.Z=1;35:*.zip=1;35:*.ANSI-30-black=30:*.ANSI-01;30-brblack=01;30:*.ANSI-31-red=31:*.ANSI-01;31-brred=01;31:*.ANSI-32-green=32:*.ANSI-01;32-brgreen=01;32:*.ANSI-33-yellow=33:*.ANSI-01;33-bryellow=01;33:*.ANSI-34-blue=34:*.ANSI-01;34-brblue=01;34:*.ANSI-35-magenta=35:*.ANSI-01;35-brmagenta=01;35:*.ANSI-36-cyan=36:*.ANSI-01;36-brcyan=01;36:*.ANSI-37-white=37:*.ANSI-01;37-brwhite=01;37:*.log=01;34:*~=01;34:*#=01;34:*.bak=01;36:*.BAK=01;36:*.old=01;36:*.OLD=01;36:*.org_archive=01;36:*.off=01;36:*.OFF=01;36:*.dist=01;36:*.DIST=01;36:*.orig=01;36:*.ORIG=01;36:*.swp=01;36:*.swo=01;36:*,v=01;36:*.gpg=34:*.gpg=34:*.pgp=34:*.asc=34:*.3des=34:*.aes=34:*.enc=34:' + +#Ignore suffixes in completion +fignore=( + svbin +) + +# +# Modules +# +autoload -Uz compinit bashcompinit +autoload -U colors complist zrecompile zmv zargs zed +autoload -Uz vcs_info +autoload insert-files +zle -N insert-files +zmodload -i zsh/complist +colors +compinit -u -d .zsh/cache/compdump +bashcompinit + +zstyle :compinstall filename '~/.zshrc' + +autoload -Uz _tmux_pane_words +zle -C tmux-pane-words-prefix complete-word _generic +zle -C tmux-pane-words-anywhere complete-word _generic +zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' completer _tmux_pane_words +zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' ignore-line current +zstyle ':completion:tmux-pane-words-anywhere:*' matcher-list 'b:=* m:{A-Za-z}={a-zA-Z}' + +# Speed up completion by not going further than a full match +zstyle ':completion:*' accept-exact '*(N)' + +zstyle ':completion:*:default' use-cache on +zstyle ':completion:*:default' cache-path ~/.zsh/cache/compcache + +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}' +zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _match + +zstyle ':completion:*' verbose yes +zstyle ':completion:*:messages' format '%d' +zstyle ':completion:*:warnings' format 'No matches for: %d' +zstyle ':completion:*:descriptions' format '%U%B%d%b%u' +zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' +zstyle ':completion:*' group-name '' + +# Complete all user processes +zstyle ':completion:*:processes' command 'ps -au$USER' +# Add colour to process lists +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:kill:*' force-list always +zstyle ':completion:*:*:killall:*' menu yes select +zstyle ':completion:*:killall:*' force-list always + +# Complete unreadable log filenames +#zstyle ':completion::complete:(most|tail)::' fake-files '/var/log/*:current' + +# Group manpages by section +zstyle ':completion:*' separate-sections true + +# Users +#zstyle '*' users $users + +zstyle '*' hosts $hosts + +zstyle ':completion:*:functions' ignored-patterns '_*' +zstyle ':completion:*:cd:*' ignore-parents parent pwd + +#This works, but isn't the same as ls +#zstyle ':completion:*:default' list-colors '' +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} + +zstyle ':vcs_info:*' enable git hg + +# Filename suffixes to ignore during completion (except after rm command) +zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' '*?.old' '*?.pro' + +## Prompt +if [[ $TERM != 'dumb' ]] +then + autoload -U promptinit + promptinit + prompt pure +fi + +# Options + +# Changing directories +setopt auto_cd + +# Completion +setopt auto_list # List multiple choices on first tab +unsetopt list_ambiguous # List ambiguous choices rather than completing common prefixes +unsetopt list_beep # Don't try to beep here +setopt list_types # Indicate file types + +# Expansion and globbing +setopt extended_glob # Use #~^ as part of filename patterns +unsetopt nomatch + +# History +unsetopt hist_beep +setopt hist_expire_dups_first +setopt hist_fcntl_lock # Use standard locking on histfile +setopt hist_find_no_dups +setopt hist_ignore_space +setopt hist_reduce_blanks +setopt hist_verify +setopt share_history +setopt inc_append_history + +# Input/Output +unsetopt clobber +unsetopt flow_control +setopt path_dirs # Search PATH even with slashes +setopt print_exit_value + +# Job Control +setopt auto_continue +unsetopt nohup +setopt long_list_jobs +unsetopt notify + +# Scripts and functions +unsetopt multi_func_def +setopt multios + +# Zle +unsetopt beep + +############ +# Keybinds # +############ +#KiTTY +bindkey "OD" backward-word +bindkey "OC" forward-word + +#General +bindkey "[1~" beginning-of-line +bindkey "[4~" end-of-line +bindkey "[5~" beginning-of-history +bindkey "[6~" end-of-history +bindkey "[2~" quoted-insert +bindkey "[3~" delete-char + +bindkey '' backward-delete-char + +bindkey '^I' expand-or-complete-prefix +bindkey '' reverse-menu-complete +bindkey '' up-line-or-search +bindkey '' down-line-or-search + +#urxvt +bindkey '[3;5~' delete-word +bindkey '' backward-word +bindkey '' forward-word + +bindkey 'f' insert-files +bindkey 'd' describe-key-briefly + +bindkey '\' tmux-pane-words-prefix +bindkey '|' tmux-pane-words-anywhere + +# Aliases before functions +alias getcflags='gcc -\#\#\# -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1"' +alias grep='grep --color=auto' +alias df='df -h' +alias du='du -h' +alias md='mkdir -p' +alias rd='rmdir' +alias .='source' + +ls='\ls' +gnu_ls_options="-v --group-directories-first --color=auto" +gnu_ls_isodate="--time-style=long-iso" +bsd_ls_options="-p" +bsd_ls_isodate="-D '%F %k:%M'" + +case $os in + osx) + if [[ -n $commands[gls] ]] + then + ls='\gls' + ls_options=$gnu_ls_options + ls_isodate=$gnu_ls_isodate + else + ls_options=$bsd_ls_options + ls_isodate=$bsd_ls_isodate + fi + ;; + freebsd) + ls_options=$bsd_ls_options + ls_isodate=$bsd_ls_isodate + ;; + gnu) + ls_options=$gnu_ls_options + ls_isodate=$gnu_ls_isodate + ;; +esac +alias l="${ls} ${ls_options} -Bp" +alias l1="${ls} ${ls_options} -1" +alias ls="${ls} ${ls_options} -hF" +alias la="${ls} ${ls_options} -hA" +alias ll="${ls} ${ls_options} ${ls_isodate} -hl" +alias lal="ll -A" +alias lla="lal" +alias llr="ll -t" +alias gpp='g++' +alias lsr="${ls} -tld *(m-2)" # mtime < -2days + +alias salt="noglob salt" +alias pping="prettyping.sh" +alias trans="transmission-remote transmission.home" +alias bitcoin="bitcoind" +alias su="smart_sudo " +alias E="SUDO_EDITOR=\emacsclient -c -a emacs\" sudoedit" +alias wprop='xprop |awk '\'' + /^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/, "\nclass:"); print} + /^WM_NAME/{sub(/.* =/, "title:"); print} + /^WM_WINDOW_ROLE/{sub(/.* =/, "role:"); print}'\''' + +alias et="emacsclient -t" + +alias -g ...='../..' + +#Suffix aliases +alias -s log=less + +if [[ -e =hub ]]; then + alias git="hub" + autoload -U _hub + compdef _hub hub +fi + +# Functions + +magit () { + emacsclient -e "(magit-status \"$PWD\")" +} + +dired () { + emacsclient -e "(dired \"$PWD\")" +} + +pid () { + local i + for i in /proc/<->/stat + [[ "$(< $i)" = *\((${(j:|:)~@})\)* ]] && echo $i:h:t + return 0 +} + +_force_rehash() { + (( CURRENT == 1 )) && rehash + return 1 # Because we didn't really complete anything +} + +portgrep() { + sudo lsof -i :$1 -nP | egrep '(LISTEN|UDP|COMMAND)' +} + +ipgrep() { + sudo lsof -i @$1 -nP +} + +smart_sudo () { + if [[ -n $1 ]]; then + \sudo $argv + else + #if no parameters were given, then assume we want a root shell + \sudo -i -u toor + fi +} + +compdef _sudo smart_sudo + +smart_compile () { + local zcompargs + if [[ $1 = *zshrc* ]]; then + zcompargs="-R" + fi + + if [[ $EUID -ne 0 || $1 != *alan* ]]; then + zrecompile -q -p $zcompargs $1 + fi + if [[ -n $2 ]]; then + . $1 + fi +} + +emacs_change_focus () { + emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null +} + +ec () { + local visibleFrames + visibleFrames=`emacsclient -e '(length (visible-frame-list))'` + if [[ $? -ne 0 ]]; then + print "Daemon not running" + return 1 + fi + + if [[ $visibleFrames -eq 1 ]]; then + emacsclient -n -c "$@" && emacs_change_focus + else + emacs_change_focus + if [[ $# -gt 0 ]]; then + emacsclient -n "$@" + fi + fi +} + +_FASD_DATA="$HOME/.zsh/fasd-data" +autoload -U fasd +source ~/.zsh/cache/fasd-init-zsh + +if [[ $OSTYPE == freebsd* ]]; then + source ~/projects/dotfiles/zsh/freebsd.zsh +fi diff --git a/tag-zsh/fasdrc b/tag-zsh/fasdrc new file mode 100644 index 0000000..22259d7 --- /dev/null +++ b/tag-zsh/fasdrc @@ -0,0 +1,8 @@ +# -*- mode: sh; -*- +current () { + for path in *; do + printf "./%s|1\\n" "$path" + done +} + +alias e="f -t -e $EDITOR -B current" diff --git a/tag-zsh/zshenv b/tag-zsh/zshenv new file mode 100644 index 0000000..48b93e1 --- /dev/null +++ b/tag-zsh/zshenv @@ -0,0 +1,3 @@ +ZDOTDIR="$HOME/.config/zsh" + +source "$ZDOTDIR"/.zshenv diff --git a/tmux.conf b/tmux.conf deleted file mode 100644 index 697e123..0000000 --- a/tmux.conf +++ /dev/null @@ -1,19 +0,0 @@ -#setw -g xterm-keys on -#set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@" - -set-window-option -g utf8 on -set-option -g status-utf8 on -set-option -g prefix C-z - -bind C-n send-prefix -unbind-key C-b - -set -g default-terminal "screen-256color" - -# Colemak style -bind-key C-i next-window - -set -g base-index 1 - -set -g update-environment "DISPLAY SSH_ASKPASS SSH_AGENT_GIT SSH_CONNECTION WINDOWID XAUTHORITY" -set-environment -g 'SSH_AUTH_SOCK' '/home/alan/.ssh/ssh_auth_sock' \ No newline at end of file diff --git a/xbindkeysrc.scm b/xbindkeysrc.scm deleted file mode 100644 index 7b00c38..0000000 --- a/xbindkeysrc.scm +++ /dev/null @@ -1,57 +0,0 @@ -;; To specify a key, you can use 'xbindkeys --key' or -;; 'xbindkeys --multikey' and put one of the two lines in this file. - -;; A list of keys is in /usr/include/X11/keysym.h and in -;; /usr/include/X11/keysymdef.h -;; The XK_ is not needed. - -;; List of modifier: -;; Release, Control, Shift, Mod1 (Alt), Mod2 (NumLock), -;; Mod3 (CapsLock), Mod4, Mod5 (Scroll). - - -;; The release modifier is not a standard X modifier, but you can -;; use it if you want to catch release instead of press events - -;; By defaults, xbindkeys does not pay attention to modifiers -;; NumLock, CapsLock and ScrollLock. -;; Uncomment the lines below if you want to use them. -;; To dissable them, call the functions with #f - - -;;;;EXTRA FUNCTIONS: Enable numlock, scrolllock or capslock usage -;;(set-numlock! #t) -;;(set-scrolllock! #t) -;;(set-capslock! #t) - -;;;;; Scheme API reference -;;;; -;; Optional modifier state: -;; (set-numlock! #f or #t) -;; (set-scrolllock! #f or #t) -;; (set-capslock! #f or #t) -;; -;; Shell command key: -;; (xbindkey key "foo-bar-command [args]") -;; (xbindkey '(modifier* key) "foo-bar-command [args]") -;; -;; Scheme function key: -;; (xbindkey-function key function-name-or-lambda-function) -;; (xbindkey-function '(modifier* key) function-name-or-lambda-function) -;; -;; Other functions: -;; (remove-xbindkey key) -;; (run-command "foo-bar-command [args]") -;; (grab-all-keys) -;; (ungrab-all-keys) -;; (remove-all-keys) -;; (debug) - -(xbindkey '(mod4 F9) "mpc toggle") -(xbindkey '(mod4 F10) "mpc prev") -(xbindkey '(mod4 F11) "mpc next") -(xbindkey '(mod4 F12) "mpc stop") - -(xbindkey '(mod4 p) "dmenu_run -fn '-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*' -nb '#002b36' -nf '#fdf6e3' -sb '#586e75' -sf '#fdf6e3' -hist '/home/alan/.cache/dmenu_run_history'") -(xbindkey '(mod4 shift T) "urxvtc") -(xbindkey '(mod4 shift E) "emacsclient -c") diff --git a/xmobarrc b/xmobarrc deleted file mode 100644 index 7dfcef2..0000000 --- a/xmobarrc +++ /dev/null @@ -1,40 +0,0 @@ -Config { font = "-misc-termsyn-medium-r-normal--11-79-100-100-c-60-*-*" - , borderColor = "#657b83" - , border = TopB - , bgColor = "#002b36" - , fgColor = "#fdf6e3" - , position = Bottom - , lowerOnStart = False - , hideOnStart = False - , persistent = True - , commands = [ Run Weather "EGNX" ["-t", "ºC" - ,"-L", "12" - ,"-H", "18" - ,"--low", "lightblue" - ,"--normal", "green" - ,"--high", "red" - ] 36000 - , Run DynNetwork ["-t", "Net: ¦KB" - ,"-L", "512" - ,"-H", "10240" - ,"--low", "green" - ,"--normal", "yellow" - ,"--high", "red" - ,"-m", "5" - ] 5 - , Run Cpu ["-p", "3" - ,"-L", "3" - ,"-H", "50" - ,"--normal", "green" - ,"--high", "red" - ] 5 - , Run Memory ["-p", "3" - ,"-t", "Mem: %" - ] 20 - , Run Date "%a %b %_d %Y %H:%M:%S" "date" 10 - , Run MPD ["-t", ": - "] 10 - ] - , sepChar = "%" - , alignSep = "}{" - , template = "%cpu% | %memory% | %dynnetwork% | %mpd% }{ %EGNX% | %date%" - } diff --git a/xresources/main b/xresources/main deleted file mode 100644 index 77c21ce..0000000 --- a/xresources/main +++ /dev/null @@ -1,33 +0,0 @@ -#include "solarized-light" - -Xcursor.theme: Neutral -Xcursor.size: 22 - -URxvt.fading: 0 -URxvt.geometry: 100x40 -URxvt.urgentOnBell: true - -URxvt.scrollBar: false -URxvt.scrollstyle: plain -URxvt.scrollTtyOutput: false -URxvt.scrollWithBuffer: true -URxvt.scrollTtyKeypress: true -URxvt.saveLines: 16384 -URxvt.secondaryScroll: false - -URxvt.font: -xos4-terminus-medium-r-normal--14-140-72-72-c-80-*-* -URxvt.boldFont: -URxvt.intensityStyles: true - -URxvt.pointerBlank: true -URxvt.pointerBlankDelay: 987654321 -URxvt.letterSpace: 0 - -Emacs.ToolBar: off -Emacs.MenuBar: off -Emacs.ScrollBars: off -Emacs.CursorBlink: off - -Emacs.Font: -*-Droid Sans Mono-medium-*-*-*-*-140-*-*-*-*-*-* -Emacs.fixed-pitch.attributeFont: -*-Droid Sans Mono-medium-*-*-*-*-140-*-*-*-*-*-* -Emacs.variable-pitch.attributeFont: -*-Arimo-medium-*-*-*-*-160-*-*-*-*-*-* diff --git a/xresources/prefect b/xresources/prefect deleted file mode 100644 index b8cb7f0..0000000 --- a/xresources/prefect +++ /dev/null @@ -1,4 +0,0 @@ -#include "main" - -Emacs.Font: -*-Droid Sans Mono-medium-*-*-*-*-120-*-*-*-*-*-* -Emacs.fixed-pitch.attributeFont: -*-Droid Sans Mono-medium-*-*-*-*-120-*-*-*-*-*-* diff --git a/xresources/solarized-light b/xresources/solarized-light deleted file mode 100644 index 3906b7b..0000000 --- a/xresources/solarized-light +++ /dev/null @@ -1,70 +0,0 @@ -! Solarized color scheme for the X Window System -! -! http://ethanschoonover.com/solarized - - -! Common - -#define S_yellow #b58900 -#define S_orange #cb4b16 -#define S_red #dc322f -#define S_magenta #d33682 -#define S_violet #6c71c4 -#define S_blue #268bd2 -#define S_cyan #2aa198 -#define S_green #859900 - - -! Dark - -! #define S_base03 #002b36 -! #define S_base02 #073642 -! #define S_base01 #586e75 -! #define S_base00 #657b83 -! #define S_base0 #839496 -! #define S_base1 #93a1a1 -! #define S_base2 #eee8d5 -! #define S_base3 #fdf6e3 - - -! Light - -#define S_base03 #fdf6e3 -#define S_base02 #eee8d5 -#define S_base01 #93a1a1 -#define S_base00 #839496 -#define S_base0 #657b83 -#define S_base1 #586e75 -#define S_base2 #073642 -#define S_base3 #002b36 - - -! To only apply colors to your terminal, for example, prefix -! the color assignment statement with its name. Example: -! -! URxvt*background: S_base03 - -*background: S_base03 -*foreground: S_base0 -*fading: 40 -*fadeColor: S_base03 -*cursorColor: S_base1 -*pointerColorBackground: S_base01 -*pointerColorForeground: S_base1 - -*color0: S_base02 -*color1: S_red -*color2: S_green -*color3: S_yellow -*color4: S_blue -*color5: S_magenta -*color6: S_cyan -*color7: S_base2 -*color8: S_base03 -*color9: S_orange -*color10: S_base01 -*color11: S_base00 -*color12: S_base0 -*color13: S_violet -*color14: S_base1 -*color15: S_base3 diff --git a/zsh/completion/_tmux_pane_words b/zsh/completion/_tmux_pane_words deleted file mode 100644 index 6ff9ce1..0000000 --- a/zsh/completion/_tmux_pane_words +++ /dev/null @@ -1,10 +0,0 @@ -local expl -local -a w - -if [[ -z "$TMUX_PANE" ]]; then - _message "not running inside tmux!" - return 1 -fi - -w=( ${(u)=$(tmux capture-pane \; show-buffer \; delete-buffer)} ) -_wanted values expl 'words from current tmux pane' compadd -a w diff --git a/zsh/environment.zsh b/zsh/environment.zsh deleted file mode 100755 index 11932e6..0000000 --- a/zsh/environment.zsh +++ /dev/null @@ -1,53 +0,0 @@ -if [[ $defpath == "" && -d ~/bin ]] -then - defpath=($path) - path=( - $defpath - ~/bin - ) - if [[ -d ~/.gem/ruby/*/bin ]] - then - path=( - $path - ~/.gem/ruby/*/bin - ) - fi -fi - -export PATH - -myfuncs=( ~/projects/dotfiles/zsh/functions/*(/) ) -fpath=( - $myfuncs - ~/projects/dotfiles/zsh/completion/ - $fpath -) -if [[ -d /usr/local/share/zsh-completions ]] -then - fpath=(/usr/local/share/zsh-completions $fpath) -fi - -if [[ -d /usr/local/share/zsh/site-functions ]] -then - fpath=(/usr/local/share/zsh/site-functions $fpath) -fi - -export FPATH - -case $OSTYPE in - *gnu*) - os=gnu - ;; - freebsd*) - os=freebsd - ;; - darwin*) - os=osx -esac - -export os - -if [[ -s $commands[direnv] ]] -then - eval "$(direnv hook zsh)" -fi diff --git a/zsh/fasd.zsh b/zsh/fasd.zsh deleted file mode 100644 index 64dbf7b..0000000 --- a/zsh/fasd.zsh +++ /dev/null @@ -1,85 +0,0 @@ -alias a='fasd -a' -alias s='fasd -si' -alias sd='fasd -sid' -alias sf='fasd -sif' -alias d='fasd -d' -alias f='fasd -f' -# function to execute built-in cd -fasd_cd() { - if [ $# -le 1 ]; then - fasd "$@" - else - local _fasd_ret="$(fasd -e 'printf %s' "$@")" - [ -z "$_fasd_ret" ] && return - [ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\n "$_fasd_ret" - fi -} -alias z='fasd_cd -d' -alias zz='fasd_cd -d -i' - -# add zsh hook -_fasd_preexec() { - { eval "fasd --proc $(fasd --sanitize $1)"; } >> "/dev/null" 2>&1 -} -autoload -Uz add-zsh-hook -add-zsh-hook preexec _fasd_preexec - -# zsh command mode completion -_fasd_zsh_cmd_complete() { - local compl - read -c compl - (( $+compstate )) && compstate[insert]=menu # no expand if compsys loaded - reply=(${(f)"$(fasd --complete "$compl")"}) -} - -# enbale command mode completion -compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \ - 'c[-1,-A][-1,-D]' -f -- fasd fasd_cd - -(( $+functions[compdef] )) && { - # zsh word mode completion - _fasd_zsh_word_complete() { - [ "$2" ] && local _fasd_cur="$2" - [ -z "$_fasd_cur" ] && local _fasd_cur="${words[CURRENT]}" - local fnd="${_fasd_cur//,/ }" - local typ=${1:-e} - fasd --query $typ "$fnd" 2>> "/dev/null" | \ - sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do - compadd -U -V fasd "$line" - done - compstate[insert]=menu # no expand - } - _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } - _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } - _fasd_zsh_word_complete_trigger() { - local _fasd_cur="${words[CURRENT]}" - eval $(fasd --word-complete-trigger _fasd_zsh_word_complete $_fasd_cur) - } - # define zle widgets - zle -C fasd-complete complete-word _generic - zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete - zstyle ':completion:fasd-complete:*' menu-select - - zle -C fasd-complete-f complete-word _generic - zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f - zstyle ':completion:fasd-complete-f:*' menu-select - - zle -C fasd-complete-d complete-word _generic - zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d - zstyle ':completion:fasd-complete-d:*' menu-select -} - -(( $+functions[compdef] )) && { - # enable word mode completion - orig_comp="$(zstyle -L ':completion:\*' completer 2>> "/dev/null")" - if [ "$orig_comp" ]; then - case $orig_comp in - *_fasd_zsh_word_complete_trigger*);; - *) eval "$orig_comp _fasd_zsh_word_complete_trigger";; - esac - else - zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger - fi - unset orig_comp -} - diff --git a/zsh/fasdrc b/zsh/fasdrc deleted file mode 100644 index 22259d7..0000000 --- a/zsh/fasdrc +++ /dev/null @@ -1,8 +0,0 @@ -# -*- mode: sh; -*- -current () { - for path in *; do - printf "./%s|1\\n" "$path" - done -} - -alias e="f -t -e $EDITOR -B current" diff --git a/zsh/freebsd.zsh b/zsh/freebsd.zsh deleted file mode 100755 index 6ca0f8d..0000000 --- a/zsh/freebsd.zsh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env zsh -function update-check () { - sudo portsnap update - sudo portmaster -L --index-only | awk '/ [Nn]ew / { print substr($0,9,9999) }' - sudo pkg audit - pkg updating -d $( ls -ltr -D '%Y%m%d' /var/db/pkg | awk 'END{print $6}' ) -} -alias iotop="top -m io -o total" diff --git a/zsh/functions/fasd/fasd b/zsh/functions/fasd/fasd deleted file mode 100755 index b1e64f4..0000000 --- a/zsh/functions/fasd/fasd +++ /dev/null @@ -1,624 +0,0 @@ -#!/usr/bin/env sh - -# Fasd (this file) can be sourced or executed by any POSIX compatible shell. - -# Fasd is originally written based on code from z (https://github.com/rupa/z) -# by rupa deadwyler under the WTFPL license. Most if not all of the code has -# been rewritten. - -# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -fasd() { - - # make zsh do word splitting inside this function - [ "$ZSH_VERSION" ] && emulate sh && setopt localoptions - - case $1 in - --init) shift - while [ "$1" ]; do - case $1 in - env) - { # source rc files if present - [ -s "/etc/fasdrc" ] && . "/etc/fasdrc" - [ -s "$HOME/.fasdrc" ] && . "$HOME/.fasdrc" - - # set default options - [ -z "$_FASD_DATA" ] && _FASD_DATA="$HOME/.fasd" - [ -z "$_FASD_BLACKLIST" ] && _FASD_BLACKLIST="--help" - [ -z "$_FASD_SHIFT" ] && _FASD_SHIFT="sudo busybox" - [ -z "$_FASD_IGNORE" ] && _FASD_IGNORE="fasd ls echo" - [ -z "$_FASD_SINK" ] && _FASD_SINK=/dev/null - [ -z "$_FASD_TRACK_PWD" ] && _FASD_TRACK_PWD=1 - [ -z "$_FASD_MAX" ] && _FASD_MAX=2000 - [ -z "$_FASD_BACKENDS" ] && _FASD_BACKENDS=native - [ -z "$_FASD_FUZZY" ] && _FASD_FUZZY=2 - [ -z "$_FASD_VIMINFO" ] && _FASD_VIMINFO="$HOME/.viminfo" - [ -z "$_FASD_RECENTLY_USED_XBEL" ] && \ - _FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel" - - if [ -z "$_FASD_AWK" ]; then - # awk preferences - local awk; for awk in mawk gawk original-awk nawk awk; do - $awk "" && _FASD_AWK=$awk && break - done - fi - } >> "${_FASD_SINK:-/dev/null}" 2>&1 - ;; - - auto) cat <> "$_FASD_SINK" 2>&1 - -EOS - ;; - - posix-alias) cat <& /dev/null || fasd -d'; -EOS - ;; - - zsh-hook) cat <> "$_FASD_SINK" 2>&1 -} -autoload -Uz add-zsh-hook -add-zsh-hook preexec _fasd_preexec - -EOS - ;; - - bash-hook) cat <> "$_FASD_SINK" 2>&1 -} - -# add bash hook -case \$PROMPT_COMMAND in - *_fasd_prompt_func*) ;; - *) PROMPT_COMMAND="_fasd_prompt_func;\$PROMPT_COMMAND";; -esac - -EOS - ;; - - posix-hook) cat <> "$_FASD_SINK" 2>&1 -} -case \$PS1 in - *_fasd_ps1_func*) ;; - *) export PS1="\\\$(_fasd_ps1_func)\$PS1";; -esac - -EOS - ;; - - tcsh-hook) cat <& /dev/null'; -EOS - - ;; - - zsh-ccomp) cat <> "$_FASD_SINK" | \\ - sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do - compadd -U -V fasd "\$line" - done - compstate[insert]=menu # no expand - } - _fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; } - _fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; } - _fasd_zsh_word_complete_trigger() { - local _fasd_cur="\${words[CURRENT]}" - eval \$(fasd --word-complete-trigger _fasd_zsh_word_complete \$_fasd_cur) - } - # define zle widgets - zle -C fasd-complete complete-word _generic - zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete - zstyle ':completion:fasd-complete:*' menu-select - - zle -C fasd-complete-f complete-word _generic - zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f - zstyle ':completion:fasd-complete-f:*' menu-select - - zle -C fasd-complete-d complete-word _generic - zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d - zstyle ':completion:fasd-complete-d:*' menu-select -} - -EOS - ;; - - zsh-ccomp-install) cat <> "$_FASD_SINK" | sed -n "\\\$s/^.*'\\\\(.*\\\\)'/\\\\1/p") - \${COMP_LINE#* }" | while read -r line; do - quote_readline "\$line" 2>/dev/null || \\ - printf %q "\$line" 2>/dev/null && \\ - printf \\\\n - done) - local IFS=\$'\\n'; COMPREPLY=( \$RESULT ) -} -_fasd_bash_hook_cmd_complete() { - for cmd in \$*; do - complete -F _fasd_bash_cmd_complete \$cmd - done -} - -EOS - ;; - - bash-ccomp-install) cat <$`{}]\{1,\}/\1 /g' - ;; - - --proc) shift # process commands - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # blacklists - local each; for each in $_FASD_BLACKLIST; do - case " $* " in *\ $each\ *) return;; esac - done - - # shifts - while true; do - case " $_FASD_SHIFT " in - *\ $1\ *) shift;; - *) break;; - esac - done - - # ignores - case " $_FASD_IGNORE " in - *\ $1\ *) return;; - esac - - shift; fasd --add "$@" # add all arguments except command - ;; - - --add|-A) shift # add entries - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # find all valid path arguments, convert them to simplest absolute form - local paths="$(while [ "$1" ]; do - [ -e "$1" ] && printf %s\\n "$1"; shift - done | sed '/^[^/]/s@^@'"$PWD"'/@ - s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 - s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \ - | tr '\n' '|')" - - # add current pwd if the option is set - [ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD" - - [ -z "${paths##\|}" ] && return # stop if we have nothing to add - - # maintain the file - local tempfile - tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - $_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" ' - BEGIN { - split(list, files, "|") - for(i in files) { - path = files[i] - if(path == "") continue - paths[path] = path # array for checking - rank[path] = 1 - time[path] = now - } - } - $2 >= 1 { - if($1 in paths) { - rank[$1] = $2 + 1 / $2 - time[$1] = now - } else { - rank[$1] = $2 - time[$1] = $3 - } - count += $2 - } - END { - if(count > max) - for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging - else - for(i in rank) print i "|" rank[i] "|" time[i] - }' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" - if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$_FASD_DATA" - fi - ;; - - --delete|-D) shift # delete entries - # stop if we don't own $_FASD_DATA or $_FASD_RO is set - [ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return - - # turn valid arguments into entry-deleting sed commands - local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \ - sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0 - s@[^/][^/]*//*\.\./@/@;t 0 - s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@ - s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")" - - # maintain the file - local tempfile - tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return - - sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile" - - if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then - env rm -f "$tempfile" - else - env mv -f "$tempfile" "$_FASD_DATA" - fi - ;; - - --query) shift # query the db, --query [$typ ["$fnd" [$mode]]] - [ -f "$_FASD_DATA" ] || return # no db yet - [ "$1" ] && local typ="$1" - [ "$2" ] && local fnd="$2" - [ "$3" ] && local mode="$3" - - # cat all backends - local each _fasd_data; for each in $_FASD_BACKENDS; do - _fasd_data="$_fasd_data -$(fasd --backend $each)" - done - [ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")" - - # set mode specific code for calculating the prior - case $mode in - rank) local prior='times[i]';; - recent) local prior='sqrt(100000/(1+t-la[i]))';; - *) local prior='times[i] * frecent(la[i])';; - esac - - if [ "$fnd" ]; then # dafault matching - local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g - s@ @[^|]*@g;s/\$$/|/')" - bre='^[^|]*'"$bre"'[^|/]*|' - local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - if [ "$_ret" ]; then - _fasd_data="$_ret" - else # no case mathcing - _ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - if [ "$_ret" ]; then - _fasd_data="$_ret" - elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching - local fuzzy_bre="$(printf %s\\n "$fnd" | \ - sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/ - s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g - s@ @[^|]*@g')" - fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|' - _ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")" - [ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - [ "$_ret" ] && _fasd_data="$_ret" || _fasd_data= - fi - fi - else # no query arugments - _fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do - [ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line" - done)" - fi - - # query the database - [ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \ - $_FASD_AWK -v t="$(date +%s)" -F"|" ' - function frecent(time) { - dx = t-time - if( dx < 3600 ) return 6 - if( dx < 86400 ) return 4 - if( dx < 604800 ) return 2 - return 1 - } - { - if(!paths[$1]) { - times[$1] = $2 - la[$1] = $3 - paths[$1] = 1 - } else { - times[$1] += $2 - if($3 > la[$1]) la[$1] = $3 - } - } - END { - for(i in paths) printf "%-10s %s\n", '"$prior"', i - }' - 2>> "$_FASD_SINK" - ;; - - --backend) - case $2 in - native) cat "$_FASD_DATA";; - viminfo) - < "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@ - s/^..// - p - }' | $_FASD_AWK -v t="$(date +%s)" '{ - t -= 60 - print $0 "|1|" t - }' - ;; - recently-used) - local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed - tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \ - sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \ - tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{ - sum = 0 - for( i=2; i<=NF; i++ ) sum += $i - print $1 "|" sum - }' - ;; - *) eval "$2";; - esac - ;; - - *) # parsing logic and processing - local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec= - while [ "$1" ]; do case $1 in - --complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;; - --query|--add|--delete|-A|-D) fasd "$@"; return $?;; - --version) [ -z "$comp" ] && echo "1.0.1" && return;; - --) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;; - -*) local o="${1#-}"; while [ "$o" ]; do case $o in - s*) local show=1;; - l*) local lst=1;; - i*) [ -z "$comp" ] && local interactive=1 show=1;; - r*) local mode=rank;; - t*) local mode=recent;; - e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e" - local exec="$o" # anything after "-e" - else # use the next argument - local exec="${2:?"-e: Argument needed "}" - shift - fi; break;; - b*) o="${o#?}"; if [ "$o" ]; then - _FASD_BACKENDS="$o" - else - _FASD_BACKENDS="${2:?"-b: Argument needed"}" - shift - fi; break;; - B*) o="${o#?}"; if [ "$o" ]; then - _FASD_BACKENDS="$_FASD_BACKENDS $o" - else - _FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}" - shift - fi; break;; - a*) local typ=e;; - d*) local typ=d;; - f*) local typ=f;; - R*) local r=r;; - [0-9]*) local _fasd_i="$o"; break;; - h*) [ -z "$comp" ] && echo "fasd [options] [query ...] -[f|a|s|d|z] [options] [query ...] - options: - -s list paths with scores - -l list paths without scores - -i interactive mode - -e set command to execute on the result file - -b only use backend - -B add additional backend - -a match files and directories - -d match directories only - -f match files only - -r match by rank only - -t match by recent access only - -R reverse listing order - -h show a brief help message - -[0-9] select the nth entry - -fasd [-A|-D] [paths ...] - -A add paths - -D delete paths" >&2 && return;; - esac; o="${o#?}"; done;; - *) fnd="$fnd $1"; last="$1";; - esac; shift; done - - # guess whether the last query is selected from tab completion - case $last in - /?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then - $exec "$last" - return - fi;; - esac - - local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r - fnd="${fnd# }" - - local res - res="$(fasd --query 2>> "$_FASD_SINK")" # query the database - [ $? -gt 0 ] && return - if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then - res="$(printf %s\\n "$res" | sort -n${R} | \ - sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')" - elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then - if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then - res="$(printf %s\\n "$res" | sort -n${R})" - printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2 - printf "> " >&2 - local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1 - fi - res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')" - elif [ "$lst" ]; then - [ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//' - return - elif [ "$show" ]; then - [ "$res" ] && printf %s\\n "$res" | sort -n${r} - return - elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell - res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')" - else # no args, show - [ "$res" ] && printf %s\\n "$res" | sort -n${r} - return - fi - if [ "$res" ]; then - fasd --add "$res" - [ -z "$exec" ] && exec='printf %s\n' - $exec "$res" - fi - ;; - esac -} - -fasd --init env - -case $- in - *i*) ;; # assume being sourced, do nothing - *) # assume being executed as an executable - if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then - _FASD_SET=1 exec $_FASD_SHELL "$0" "$@" - else - fasd "$@" - fi;; -esac - diff --git a/zsh/functions/pure/prompt_pure_setup b/zsh/functions/pure/prompt_pure_setup deleted file mode 100644 index 5c63503..0000000 --- a/zsh/functions/pure/prompt_pure_setup +++ /dev/null @@ -1,118 +0,0 @@ -# Pure -# by Sindre Sorhus -# https://github.com/sindresorhus/pure -# MIT License - -# For my own and others sanity -# git: -# %b => current branch -# %a => current action (rebase/merge) -# prompt: -# %F => color dict -# %f => reset color -# %~ => current path -# %* => time -# %n => username -# %m => shortname host -# %(?..) => prompt conditional - %(condition.true.false) - - -# turns seconds into human readable time -# 165392 => 1d 21h 56m 32s -prompt_pure_human_time() { - local tmp=$1 - local days=$(( tmp / 60 / 60 / 24 )) - local hours=$(( tmp / 60 / 60 % 24 )) - local minutes=$(( tmp / 60 % 60 )) - local seconds=$(( tmp % 60 )) - (( $days > 0 )) && echo -n "${days}d " - (( $hours > 0 )) && echo -n "${hours}h " - (( $minutes > 0 )) && echo -n "${minutes}m " - echo "${seconds}s" -} - -# fastest possible way to check if repo is dirty -prompt_pure_git_dirty() { - # check if we're in a git repo - command git rev-parse --is-inside-work-tree &>/dev/null || return - # check if it's dirty - command git diff --quiet --ignore-submodules HEAD &>/dev/null - - (($? == 1)) && echo '*' -} - -# displays the exec time of the last command if set threshold was exceeded -prompt_pure_cmd_exec_time() { - local stop=$(date +%s) - local start=${cmd_timestamp:-$stop} - integer elapsed=$stop-$start - (($elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5})) && prompt_pure_human_time $elapsed -} - -prompt_pure_preexec() { - cmd_timestamp=$(date +%s) - - # shows the current dir and executed command in the title when a process is active - print -Pn "\e]0;" - echo -nE "$PWD:t: $2" - print -Pn "\a" -} - -# string length ignoring ansi escapes -prompt_pure_string_length() { - echo ${#${(S%%)1//(\%([KF1]|)\{*\}|\%[Bbkf])}} -} - -prompt_pure_precmd() { - # shows the full path in the title - print -Pn '\e]0;%~\a' - - # git info - vcs_info - - local prompt_pure_preprompt='\n%F{blue}%~%F{242}$vcs_info_msg_0_`prompt_pure_git_dirty` $prompt_pure_username%f %F{yellow}`prompt_pure_cmd_exec_time`%f' - print -P $prompt_pure_preprompt - - # check async if there is anything to pull - (( ${PURE_GIT_PULL:-1} )) && { - # check if we're in a git repo - command git rev-parse --is-inside-work-tree &>/dev/null && - # check check if there is anything to pull - command git fetch &>/dev/null && - # check if there is an upstream configured for this branch - command git rev-parse --abbrev-ref @'{u}' &>/dev/null && - (( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && - # some crazy ansi magic to inject the symbol into the previous line - print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}⇣%f\e8" - } &! - - # reset value since `preexec` isn't always triggered - unset cmd_timestamp -} - - -prompt_pure_setup() { - # prevent percentage showing up - # if output doesn't end with a newline - export PROMPT_EOL_MARK='' - - prompt_opts=(cr subst percent) - - autoload -Uz add-zsh-hook - autoload -Uz vcs_info - - add-zsh-hook precmd prompt_pure_precmd - add-zsh-hook preexec prompt_pure_preexec - - zstyle ':vcs_info:*' enable git - zstyle ':vcs_info:git*' formats ' %b' - zstyle ':vcs_info:git*' actionformats ' %b|%a' - - # show username@host if logged in through SSH - [[ "$SSH_CONNECTION" != '' ]] && prompt_pure_username='%n@%m ' - - # prompt turns red if the previous command didn't exit with 0 - PROMPT='%(?.%F{magenta}.%F{red})❯%f ' -} - -prompt_pure_setup "$@" diff --git a/zsh/functions/runit/_sv b/zsh/functions/runit/_sv deleted file mode 100644 index bf98b3e..0000000 --- a/zsh/functions/runit/_sv +++ /dev/null @@ -1,7 +0,0 @@ -#compdef sv - -_arguments -A -S -s \ - '-v[wait up to 7 seconds for the command to take effect. (up|down|term|once|cont|exit)]' \ - '-w+[wait for %n seconds]: :_guard "[0-9]#" "numeric value"' \ - '1:command:(status up down once pause cont hup alarm interrupt quit 1 2 term kill exit start stop restart shutdown force-stop force-reload force-restart force-shutdown check)' \ - '*:installed service:_files -W ${SVDIR:-/service}' diff --git a/zsh/functions/runit/getservicedir b/zsh/functions/runit/getservicedir deleted file mode 100644 index 2e5d961..0000000 --- a/zsh/functions/runit/getservicedir +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env zsh -print ${$(readlink ${SVDIR:-/service}/$1):h} \ No newline at end of file diff --git a/zsh/functions/runit/linksv b/zsh/functions/runit/linksv deleted file mode 100644 index 7ee7109..0000000 --- a/zsh/functions/runit/linksv +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env zsh - -if [[ -z $1 ]]; then - echo "No service specified" - return 64 -fi - - -if [[ ! -x $1 ]]; then - echo "Service does not exist in current directory" - return 1 -fi - -mv $1{,.old} -ln -s =sv $1 -chmod -h a-w $1 diff --git a/zsh/functions/runit/renamesv b/zsh/functions/runit/renamesv deleted file mode 100644 index dba1098..0000000 --- a/zsh/functions/runit/renamesv +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env zsh -local svdir=${SVDIR:-/service} -if [[ -z $1 || -z $2 ]]; then - echo "Usage: $0 source target" - return 64 -fi - -if [[ ! -h $svdir/$1 ]]; then - echo $svdir/$1 does not exist - return 2 -fi - -if [[ -e $svdir/$2 ]]; then - echo $svdir/$2 already exists - return 3 -fi - -local servicedir=`getservicedir` - -if [[ ! ( -w $svdir && -w $servicedir ) ]]; then - echo $svdir or $servicedir is not writeable -fi - -# The service doesn't have to be stopped as removing the link will do that -# However, running the same service twice isn't a great idea, so wait here -sv stop $1 - -rm -f $svdir/$1 || return - -mv $servicedir/{$1,$2} || return - -ln -s {$servicedir,$svdir}/$2 || return - -sv start $2 - -return diff --git a/zsh/interactive.zsh b/zsh/interactive.zsh deleted file mode 100755 index 365214c..0000000 --- a/zsh/interactive.zsh +++ /dev/null @@ -1,362 +0,0 @@ -export PAGER="less" -export EDITOR="emacsclient" -export CLICOLOR=true - -# -# zsh variables -# -HISTFILE=~/.zsh/history -HISTSIZE=4000 -SAVEHIST=3000 - -WORDCHARS='*?_-[]~=.&;!#$%^(){}<>' - -#If a command takes more than 5 seconds, give statistics -REPORTTIME=5 -TIMEFMT="%U user %S system %P cpu %*Es total" - -#Check for user logins -watch=notme -WATCHFMT="%n has %a %l from %M at %t" - -hosts=( - server - prefect - alanpearce.co.uk - home.alanpearce.co.uk -) - -users=(alan root toor) - -function linkAuthSock () { - local linkSock=~/.ssh/ssh_auth_sock - ln -sf $1 ~/.ssh/ssh_auth_sock - export SSH_AUTH_SOCK=$linkSock -} - -if [[ "$SSH_AUTH_SOCK" != "" ]] -then - if [[ -e ~/.ssh/ssh_auth_sock && ! -L ~/.ssh/ssh_auth_sock ]] - then - linkAuthSock $SSH_AUTH_SOCK - fi -fi - -LS_COLORS='no=00:fi=00:di=36:ln=35:pi=30;44:so=35;44:do=35;44:bd=33;44:cd=37;44:or=05;37;41:mi=05;37;41:ex=01;31:*.cmd=01;31:*.exe=01;31:*.com=01;31:*.bat=01;31:*.reg=01;31:*.app=01;31:*.txt=32:*.org=32:*.md=32:*.mkd=32:*.h=32:*.c=32:*.C=32:*.cc=32:*.cpp=32:*.cxx=32:*.objc=32:*.sh=32:*.csh=32:*.zsh=32:*.el=32:*.vim=32:*.java=32:*.pl=32:*.pm=32:*.py=32:*.rb=32:*.hs=32:*.php=32:*.htm=32:*.html=32:*.shtml=32:*.erb=32:*.haml=32:*.xml=32:*.rdf=32:*.css=32:*.sass=32:*.scss=32:*.less=32:*.js=32:*.coffee=32:*.man=32:*.0=32:*.1=32:*.2=32:*.3=32:*.4=32:*.5=32:*.6=32:*.7=32:*.8=32:*.9=32:*.l=32:*.n=32:*.p=32:*.pod=32:*.tex=32:*.bmp=33:*.cgm=33:*.dl=33:*.dvi=33:*.emf=33:*.eps=33:*.gif=33:*.jpeg=33:*.jpg=33:*.JPG=33:*.mng=33:*.pbm=33:*.pcx=33:*.pdf=33:*.pgm=33:*.png=33:*.ppm=33:*.pps=33:*.ppsx=33:*.ps=33:*.svg=33:*.svgz=33:*.tga=33:*.tif=33:*.tiff=33:*.xbm=33:*.xcf=33:*.xpm=33:*.xwd=33:*.xwd=33:*.yuv=33:*.aac=33:*.au=33:*.flac=33:*.mid=33:*.midi=33:*.mka=33:*.mp3=33:*.mpa=33:*.mpeg=33:*.mpg=33:*.ogg=33:*.ra=33:*.wav=33:*.anx=33:*.asf=33:*.avi=33:*.axv=33:*.flc=33:*.fli=33:*.flv=33:*.gl=33:*.m2v=33:*.m4v=33:*.mkv=33:*.mov=33:*.mp4=33:*.mp4v=33:*.mpeg=33:*.mpg=33:*.nuv=33:*.ogm=33:*.ogv=33:*.ogx=33:*.qt=33:*.rm=33:*.rmvb=33:*.swf=33:*.vob=33:*.wmv=33:*.doc=31:*.docx=31:*.rtf=31:*.dot=31:*.dotx=31:*.xls=31:*.xlsx=31:*.ppt=31:*.pptx=31:*.fla=31:*.psd=31:*.7z=1;35:*.apk=1;35:*.arj=1;35:*.bin=1;35:*.bz=1;35:*.bz2=1;35:*.cab=1;35:*.deb=1;35:*.dmg=1;35:*.gem=1;35:*.gz=1;35:*.iso=1;35:*.jar=1;35:*.msi=1;35:*.rar=1;35:*.rpm=1;35:*.tar=1;35:*.tbz=1;35:*.tbz2=1;35:*.tgz=1;35:*.tx=1;35:*.war=1;35:*.xpi=1;35:*.xz=1;35:*.z=1;35:*.Z=1;35:*.zip=1;35:*.ANSI-30-black=30:*.ANSI-01;30-brblack=01;30:*.ANSI-31-red=31:*.ANSI-01;31-brred=01;31:*.ANSI-32-green=32:*.ANSI-01;32-brgreen=01;32:*.ANSI-33-yellow=33:*.ANSI-01;33-bryellow=01;33:*.ANSI-34-blue=34:*.ANSI-01;34-brblue=01;34:*.ANSI-35-magenta=35:*.ANSI-01;35-brmagenta=01;35:*.ANSI-36-cyan=36:*.ANSI-01;36-brcyan=01;36:*.ANSI-37-white=37:*.ANSI-01;37-brwhite=01;37:*.log=01;34:*~=01;34:*#=01;34:*.bak=01;36:*.BAK=01;36:*.old=01;36:*.OLD=01;36:*.org_archive=01;36:*.off=01;36:*.OFF=01;36:*.dist=01;36:*.DIST=01;36:*.orig=01;36:*.ORIG=01;36:*.swp=01;36:*.swo=01;36:*,v=01;36:*.gpg=34:*.gpg=34:*.pgp=34:*.asc=34:*.3des=34:*.aes=34:*.enc=34:' - -#Ignore suffixes in completion -fignore=( - svbin -) - -# -# Modules -# -autoload -Uz compinit bashcompinit -autoload -U colors complist zrecompile zmv zargs zed -autoload -Uz vcs_info -autoload insert-files -zle -N insert-files -zmodload -i zsh/complist -colors -compinit -u -d .zsh/cache/compdump -bashcompinit - -zstyle :compinstall filename '~/.zshrc' - -autoload -Uz _tmux_pane_words -zle -C tmux-pane-words-prefix complete-word _generic -zle -C tmux-pane-words-anywhere complete-word _generic -zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' completer _tmux_pane_words -zstyle ':completion:tmux-pane-words-(prefix|anywhere):*' ignore-line current -zstyle ':completion:tmux-pane-words-anywhere:*' matcher-list 'b:=* m:{A-Za-z}={a-zA-Z}' - -# Speed up completion by not going further than a full match -zstyle ':completion:*' accept-exact '*(N)' - -zstyle ':completion:*:default' use-cache on -zstyle ':completion:*:default' cache-path ~/.zsh/cache/compcache - -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}' -zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _match - -zstyle ':completion:*' verbose yes -zstyle ':completion:*:messages' format '%d' -zstyle ':completion:*:warnings' format 'No matches for: %d' -zstyle ':completion:*:descriptions' format '%U%B%d%b%u' -zstyle ':completion:*:corrections' format '%B%d (errors: %e)%b' -zstyle ':completion:*' group-name '' - -# Complete all user processes -zstyle ':completion:*:processes' command 'ps -au$USER' -# Add colour to process lists -zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' -zstyle ':completion:*:*:kill:*' menu yes select -zstyle ':completion:*:kill:*' force-list always -zstyle ':completion:*:*:killall:*' menu yes select -zstyle ':completion:*:killall:*' force-list always - -# Complete unreadable log filenames -#zstyle ':completion::complete:(most|tail)::' fake-files '/var/log/*:current' - -# Group manpages by section -zstyle ':completion:*' separate-sections true - -# Users -#zstyle '*' users $users - -zstyle '*' hosts $hosts - -zstyle ':completion:*:functions' ignored-patterns '_*' -zstyle ':completion:*:cd:*' ignore-parents parent pwd - -#This works, but isn't the same as ls -#zstyle ':completion:*:default' list-colors '' -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} - -zstyle ':vcs_info:*' enable git hg - -# Filename suffixes to ignore during completion (except after rm command) -zstyle ':completion:*:*:(^rm):*:*files' ignored-patterns '*?.o' '*?.c~' '*?.old' '*?.pro' - -## Prompt -if [[ $TERM != 'dumb' ]] -then - autoload -U promptinit - promptinit - prompt pure -fi - -# Options - -# Changing directories -setopt auto_cd - -# Completion -setopt auto_list # List multiple choices on first tab -unsetopt list_ambiguous # List ambiguous choices rather than completing common prefixes -unsetopt list_beep # Don't try to beep here -setopt list_types # Indicate file types - -# Expansion and globbing -setopt extended_glob # Use #~^ as part of filename patterns -unsetopt nomatch - -# History -unsetopt hist_beep -setopt hist_expire_dups_first -setopt hist_fcntl_lock # Use standard locking on histfile -setopt hist_find_no_dups -setopt hist_ignore_space -setopt hist_reduce_blanks -setopt hist_verify -setopt share_history -setopt inc_append_history - -# Input/Output -unsetopt clobber -unsetopt flow_control -setopt path_dirs # Search PATH even with slashes -setopt print_exit_value - -# Job Control -setopt auto_continue -unsetopt nohup -setopt long_list_jobs -unsetopt notify - -# Scripts and functions -unsetopt multi_func_def -setopt multios - -# Zle -unsetopt beep - -############ -# Keybinds # -############ -#KiTTY -bindkey "OD" backward-word -bindkey "OC" forward-word - -#General -bindkey "[1~" beginning-of-line -bindkey "[4~" end-of-line -bindkey "[5~" beginning-of-history -bindkey "[6~" end-of-history -bindkey "[2~" quoted-insert -bindkey "[3~" delete-char - -bindkey '' backward-delete-char - -bindkey '^I' expand-or-complete-prefix -bindkey '' reverse-menu-complete -bindkey '' up-line-or-search -bindkey '' down-line-or-search - -#urxvt -bindkey '[3;5~' delete-word -bindkey '' backward-word -bindkey '' forward-word - -bindkey 'f' insert-files -bindkey 'd' describe-key-briefly - -bindkey '\' tmux-pane-words-prefix -bindkey '|' tmux-pane-words-anywhere - -# Aliases before functions -alias getcflags='gcc -\#\#\# -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1"' -alias grep='grep --color=auto' -alias df='df -h' -alias du='du -h' -alias md='mkdir -p' -alias rd='rmdir' -alias .='source' - -ls='\ls' -gnu_ls_options="-v --group-directories-first --color=auto" -gnu_ls_isodate="--time-style=long-iso" -bsd_ls_options="-p" -bsd_ls_isodate="-D '%F %k:%M'" - -case $os in - osx) - if [[ -n $commands[gls] ]] - then - ls='\gls' - ls_options=$gnu_ls_options - ls_isodate=$gnu_ls_isodate - else - ls_options=$bsd_ls_options - ls_isodate=$bsd_ls_isodate - fi - ;; - freebsd) - ls_options=$bsd_ls_options - ls_isodate=$bsd_ls_isodate - ;; - gnu) - ls_options=$gnu_ls_options - ls_isodate=$gnu_ls_isodate - ;; -esac -alias l="${ls} ${ls_options} -Bp" -alias l1="${ls} ${ls_options} -1" -alias ls="${ls} ${ls_options} -hF" -alias la="${ls} ${ls_options} -hA" -alias ll="${ls} ${ls_options} ${ls_isodate} -hl" -alias lal="ll -A" -alias lla="lal" -alias llr="ll -t" -alias gpp='g++' -alias lsr="${ls} -tld *(m-2)" # mtime < -2days - -alias salt="noglob salt" -alias pping="prettyping.sh" -alias trans="transmission-remote transmission.home" -alias bitcoin="bitcoind" -alias su="smart_sudo " -alias E="SUDO_EDITOR=\emacsclient -c -a emacs\" sudoedit" -alias wprop='xprop |awk '\'' - /^WM_CLASS/{sub(/.* =/, "instance:"); sub(/,/, "\nclass:"); print} - /^WM_NAME/{sub(/.* =/, "title:"); print} - /^WM_WINDOW_ROLE/{sub(/.* =/, "role:"); print}'\''' - -alias et="emacsclient -t" - -alias -g ...='../..' - -#Suffix aliases -alias -s log=less - -if [[ -e =hub ]]; then - alias git="hub" - autoload -U _hub - compdef _hub hub -fi - -# Functions - -magit () { - emacsclient -e "(magit-status \"$PWD\")" -} - -dired () { - emacsclient -e "(dired \"$PWD\")" -} - -pid () { - local i - for i in /proc/<->/stat - [[ "$(< $i)" = *\((${(j:|:)~@})\)* ]] && echo $i:h:t - return 0 -} - -_force_rehash() { - (( CURRENT == 1 )) && rehash - return 1 # Because we didn't really complete anything -} - -portgrep() { - sudo lsof -i :$1 -nP | egrep '(LISTEN|UDP|COMMAND)' -} - -ipgrep() { - sudo lsof -i @$1 -nP -} - -smart_sudo () { - if [[ -n $1 ]]; then - \sudo $argv - else - #if no parameters were given, then assume we want a root shell - \sudo -i -u toor - fi -} - -compdef _sudo smart_sudo - -smart_compile () { - local zcompargs - if [[ $1 = *zshrc* ]]; then - zcompargs="-R" - fi - - if [[ $EUID -ne 0 || $1 != *alan* ]]; then - zrecompile -q -p $zcompargs $1 - fi - if [[ -n $2 ]]; then - . $1 - fi -} - -emacs_change_focus () { - emacsclient -n -e "(select-frame-set-input-focus (selected-frame))" > /dev/null -} - -ec () { - local visibleFrames - visibleFrames=`emacsclient -e '(length (visible-frame-list))'` - if [[ $? -ne 0 ]]; then - print "Daemon not running" - return 1 - fi - - if [[ $visibleFrames -eq 1 ]]; then - emacsclient -n -c "$@" && emacs_change_focus - else - emacs_change_focus - if [[ $# -gt 0 ]]; then - emacsclient -n "$@" - fi - fi -} - -_FASD_DATA="$HOME/.zsh/fasd-data" -autoload -U fasd -source ~/.zsh/cache/fasd-init-zsh - -if [[ $OSTYPE == freebsd* ]]; then - source ~/projects/dotfiles/zsh/freebsd.zsh -fi diff --git a/zsh/login.zsh b/zsh/login.zsh deleted file mode 100755 index e69de29..0000000 diff --git a/zsh/logout.zsh b/zsh/logout.zsh deleted file mode 100755 index e69de29..0000000 diff --git a/zsh/prefect.zsh b/zsh/prefect.zsh deleted file mode 100644 index 997ba39..0000000 --- a/zsh/prefect.zsh +++ /dev/null @@ -1,10 +0,0 @@ -EDITOR="emacs" -VISUAL="emacs" - -if [[ ! -S $SSH_AUTH_SOCK ]] -then - eval `ssh-agent | sed -e '/^echo/d'` - linkAuthSock $SSH_AUTH_SOCK -fi - -export WINEARCH="win32" \ No newline at end of file diff --git a/zsh/server.zsh b/zsh/server.zsh deleted file mode 100644 index d9d7421..0000000 --- a/zsh/server.zsh +++ /dev/null @@ -1,20 +0,0 @@ -# -*- shell-script -*- - -export SVDIR=/service -if [[ "$EUID" == "0" ]] || [[ "$USER" == "root" ]] -then - export EDITOR="emacs -nw" -else - export ALTERNATE_EDITOR="emacs" - export EDITOR="emacsclient" -fi - -mailpath= - -# Folder aliases -hash -d music=/tank/media/Music - -zstyle ':completion:*' local server /tank/www/internal '' -zstyle ':completion:*' local external /tank/www/external -zstyle ':completion:*' local alphapulsar.uk.to /tank/www/gaming -zstyle ':completion:*' local home.alanpearce.co.uk /tank/www/external -- cgit 1.4.1