summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2017-04-26 12:28:48 +0200
committerAlan Pearce2017-04-26 12:28:48 +0200
commit5d78e5eb3cb75ce81a98e4d09d873dc1cc61da79 (patch)
treefaee4e103b33a2b7c9814753e4f6a54a9404a4e6
parent803c99c5f1205f82e3f2e2ed7eda77a84450184b (diff)
parentdfbb1bb931161ee1fdb8a8fdf14fb5e15c810787 (diff)
downloaddotfiles-5d78e5eb3cb75ce81a98e4d09d873dc1cc61da79.tar.lz
dotfiles-5d78e5eb3cb75ce81a98e4d09d873dc1cc61da79.tar.zst
dotfiles-5d78e5eb3cb75ce81a98e4d09d873dc1cc61da79.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--README.org24
-rw-r--r--emacs/.emacs.d/ap-spotcap.local.el.gpgbin2447 -> 2136 bytes
-rw-r--r--emacs/.emacs.d/init.org190
-rw-r--r--git/.config/git/config2
-rw-r--r--ledger/.ledgerrc1
-rw-r--r--zsh/.config/zsh/.zshenv19
-rw-r--r--zsh/.config/zsh/.zshrc50
7 files changed, 214 insertions, 72 deletions
diff --git a/README.org b/README.org
index 7333ed3..2ed0633 100644
--- a/README.org
+++ b/README.org
@@ -7,6 +7,11 @@ It doesn't use any configuration frameworks, just packages installed
 via package managers.  For Z shell I use [[https://zplug.sh/][zplug]] and for Emacs I use the
 built-in package.el via [[https://github.com/jwiegley/use-package][use-package]].
 
+I've included a wrapper script for =stow= which sets the target
+directory to =$HOME=, instead of =../=.  This allows the repository to
+be cloned anywhere, instead of following the =stow= convention of
+being one level below the target directory.
+
 It should work on:
 - Linux
 - OSX
@@ -15,17 +20,30 @@ It should work on:
 
 ** Installation
 
-Installing a set of dotfiles with stow is simple.  For example, with
+Clone the project anywhere, e.g. with =[[https://github.com/motemen/ghq][ghq]]=
+
+#+BEGIN_SRC sh :exports code
+ghq get git://git.alanpearce.eu/dotfiles
+ghq look git.alanpearce.eu/dotfiles
+#+END_SRC
+
+Or just with normal git
+
+#+BEGIN_SRC sh :exports code
+git clone git://git.alanpearce.eu/dotfiles ~/projects/alanpearce-dotfiles
+#+END_SRC
+
+Installing a set of dotfiles with =stow= is simple.  For example, with
 Emacs:
 
 #+BEGIN_SRC sh :exports code
-stow -S emacs
+./stow -S emacs
 #+END_SRC
 
 And then to uninstall
 
 #+BEGIN_SRC sh :exports code
-stow -D emacs
+./stow -D emacs
 #+END_SRC
 
 *** Z Shell
diff --git a/emacs/.emacs.d/ap-spotcap.local.el.gpg b/emacs/.emacs.d/ap-spotcap.local.el.gpg
index c17384c..e8c7590 100644
--- a/emacs/.emacs.d/ap-spotcap.local.el.gpg
+++ b/emacs/.emacs.d/ap-spotcap.local.el.gpg
Binary files differdiff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index 305787e..034ac0b 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -120,10 +120,6 @@ Ring the bell sometimes, but not so often
           (ding))))
 #+END_SRC
 
-#+BEGIN_SRC emacs-lisp
-(use-package dash)
-#+END_SRC
-
 ** Colours
 
 Let’s try a more minimal theme.
@@ -329,7 +325,7 @@ modes.
               (setq cyphejor-rules `(("emacs"       "ε")
                                      ("diff"        "Δ")
                                      ("js2"         "js")
-                                     ("magit-status" ,(char-to-string (-find #'char-displayable-p '(11942 5848 177))))
+                                     ("magit-status" ,(char-to-string (seq-find #'char-displayable-p '(11942 5848 177))))
                                      ("inferior"    "i" :prefix)
                                      ("interaction" "i" :prefix)
                                      ("interactive" "i" :prefix)
@@ -430,14 +426,9 @@ configuration with crux.el
 * Projects
 
 #+BEGIN_SRC emacs-lisp
-(defvar work-project-directory "~/work")
-(defvar home-project-directory "~/projects")
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp
 (defun switch-to-dotfiles ()
   (interactive)
-  (projectile-switch-project-by-name (expand-file-name "~/dotfiles")))
+  (projectile-switch-project-by-name (car (split-string (shell-command-to-string "ghq list --full-path dotfiles")))))
 #+END_SRC
 
 ** The Silver Searcher
@@ -483,17 +474,6 @@ based upon some folder conventions I use.
   :config (progn
             (projectile-global-mode)
             (add-to-list 'projectile-globally-ignored-directories ".stversions")
-            (defun ap/subfolder-projects (dir)
-              (--map (file-relative-name it dir)
-                     (-filter (lambda (subdir)
-                                (--reduce-from (or acc (funcall it subdir)) nil
-                                               projectile-project-root-files-functions))
-                              (-filter #'file-directory-p (directory-files dir t "\\<")))))
-
-            (defun ap/open-subfolder-project (from-dir &optional arg)
-              (let ((project-dir (projectile-completing-read "Open project: "
-                                                             (ap/subfolder-projects from-dir))))
-                (projectile-switch-project-by-name (expand-file-name project-dir from-dir) arg)))
 
             (defun yarn-install (&optional arg)
               (interactive "P")
@@ -510,16 +490,24 @@ based upon some folder conventions I use.
               (projectile-with-default-dir (projectile-project-root)
                 (cmd-to-echo "yarn" (concat "add " package))))
 
-            (defun ap/open-work-project (&optional arg)
-              (interactive "P")
-              (ap/open-subfolder-project work-project-directory arg))
+            (defun yarn-run (cmd)
+              (interactive "scommand: ")
+              (projectile-with-default-dir (projectile-project-root)
+                (cmd-to-echo "yarn" (concat "run " cmd))))
 
-            (defun ap/open-home-project (&optional arg)
+            (defun ap/open-project (&optional arg)
               (interactive "P")
-              (ap/open-subfolder-project home-project-directory arg))
+              (let ((project-dir (projectile-completing-read
+                                  "Open project: "
+                                  (ghq--find-projects))))
+                (projectile-switch-project-by-name
+                 (expand-file-name project-dir (ghq--find-root)) arg)))
 
             (setq projectile-switch-project-action #'projectile-commander
                   projectile-completion-system 'ivy)))
+
+(use-package counsel-projectile
+  :config (counsel-projectile-on))
 #+END_SRC
 
 ** vc
@@ -583,6 +571,17 @@ a particular way, but it changed later.
   :commands git-timemachine)
 #+END_SRC
 
+** ghq
+
+[[https://github.com/motemen/ghq][=ghq=]] clones VCS-backed projects to a common directory.  It should
+seem familiar to anyone who's used =go get= before.  [[https://github.com/rcoedo/emacs-ghq][=emacs-ghq=]] is a
+simple wrapper for it.
+
+#+BEGIN_SRC emacs-lisp
+(use-package ghq
+  :if (executable-find "ghq"))
+#+END_SRC
+
 * Files
 
 ** Auto-saving
@@ -718,13 +717,6 @@ that I can sudo on remote machines
             (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))))
-
-(use-package tramp-sh
-  :ensure nil
-  :defer t
-  :config (progn
-            (add-to-list 'tramp-remote-path "/usr/local/sbin")
-            (add-to-list 'tramp-remote-path "~/bin")))
 #+END_SRC
 
 ** ediff
@@ -965,7 +957,6 @@ seems to work perfectly well for me.
 
 #+BEGIN_SRC emacs-lisp
 (use-package company-nixos-options
-  :if (eq system-type 'gnu/linux)
   :config (progn
             (add-to-list 'company-backends 'company-nixos-options)))
 #+END_SRC
@@ -1120,9 +1111,9 @@ helps to make documentation for other languages easier to access
     `(progn
        (defun ,fun ()
          (when (require 'counsel-dash nil :noerror)
-           (-each (-difference ',docsets
-                               (helm-dash-installed-docsets))
-             #'counsel-dash-install-docset)
+           (seq-map #'counsel-dash-install-docset
+             (seq-difference ',docsets
+                                  (helm-dash-installed-docsets)))
            (setq-local counsel-dash-docsets ',docsets)))
        (add-hook (quote ,hook) (function ,fun)))))
 
@@ -1176,6 +1167,52 @@ rather useful.
             (setq eldoc-idle-delay 0.1)
             (eldoc-add-command 'paredit-backward-delete 'paredit-close-round)))
 #+END_SRC
+* Mail
+
+** Gnus
+
+At work, I use gnus for email.  Some of the setup is specific to my
+workplace, so I keep it in a host-specific, GPG-encrypted file.
+
+#+BEGIN_SRC emacs-lisp
+(use-package gnus
+  :config (progn
+            (setq gnus-gcc-mark-as-read t
+                  mml-secure-openpgp-encrypt-to-self t
+                  send-mail-function #'smtpmail-send-it
+                  message-send-mail-function #'smtpmail-send-it)))
+
+(with-eval-after-load 'gnus-mime
+  (define-key gnus-mime-button-map " " #'gnus-mime-view-part-externally))
+
+(with-eval-after-load "mailcap"
+  (when (eq system-type 'darwin)
+    (mailcap-add-mailcap-entry "application" "pdf" '((viewer . "/usr/bin/qlmanage -p %s") (type . "application/pdf")))))
+
+(with-eval-after-load "mm-decode"
+  (add-to-list 'mm-discouraged-alternatives "text/html")
+  (add-to-list 'mm-discouraged-alternatives "text/richtext"))
+#+END_SRC
+
+** BBDB
+
+As I'm using Emacs for email, it makes sense to have contact
+information here as well.
+
+#+BEGIN_SRC emacs-lisp
+(use-package bbdb
+  :config (progn
+            (bbdb-initialize 'gnus 'mail 'message 'pgp)
+            (bbdb-mua-auto-update-init 'gnus 'message)
+            (setq bbdb-send-mail-style 'gnus
+                  bbdb-complete-mail-allow-cycling t
+                  bbdb-mua-auto-update t
+                  bbdb-mua-update-interactive-p '(query . create)
+                  bbdb-message-all-addresses t
+                  bbdb-offer-save t
+                  bbdb-offer-to-create 1)))
+#+END_SRC
+
 * Misc
 
 #+BEGIN_SRC emacs-lisp
@@ -1320,8 +1357,8 @@ replacement for helm so far.
   :demand t
   :config (progn
             (ivy-mode 1)
-            (setq ivy-re-builders-alist '((internal-complete-buffer . ivy--regex-fuzzy)
-                                          (t . ivy--regex-plus)))
+            (setq ivy-re-builders-alist '((t . ivy--regex-plus))
+                  ivy-extra-directories '("./"))
             (defun ivy-imenu-get-candidates-from (alist  &optional prefix)
               (cl-loop for elm in alist
                        nconc (if (imenu--subalist-p elm)
@@ -1848,6 +1885,14 @@ I don’t work with these as often as I would like
 (add-hook 'lisp-mode-hook #'set-common-lisp-indentation)
 #+END_SRC
 
+**** hyperspec
+
+#+BEGIN_SRC emacs-lisp
+(use-package hyperspec
+  :config (progn
+            (setq common-lisp-hyperspec-root "file://opt/local/share/doc/lisp/HyperSpec-7-0/")))
+#+END_SRC
+
 **** geiser
 
 A REPL thing for Scheme.  Hopefully I’ll get to use it more in the
@@ -1872,8 +1917,9 @@ A REPL thing (and more) for Lisp.
             (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"))))
+              (slime-setup '(slime-fancy slime-asdf)))
+            (setq inferior-lisp-program (or (executable-find "sbcl")
+                                            (executable-find "ccl64")))))
 #+END_SRC
 
 *** Clojure
@@ -2138,6 +2184,53 @@ I derived a mode for twig, in order to use its =mode-hook=.
                                                  ispell-really-hunspell t)))))
 #+END_SRC
 
+#+BEGIN_SRC emacs-lisp
+(use-package flyspell
+  :config (progn
+            (defun flyspell-detect-ispell-args (&optional run-together)
+              "If RUN-TOGETHER is true, spell check the CamelCase words.
+ Please note RUN-TOGETHER will make aspell less capable. So it should only be used in prog-mode-hook."
+              (let (args)
+                (when ispell-program-name
+                  (cond
+                   ((string-match "aspell$" ispell-program-name)
+                    (setq args (list "--sug-mode=ultra"))
+                    (if run-together
+                        (setq args (append args '("--run-together" "--run-together-limit=16" "--run-together-min=2")))))
+                   ((string-match "hunspell$" ispell-program-name)
+                    (setq args nil))))
+                args))
+            ;; `ispell-extra-args' is *always* used when start CLI aspell process
+            (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
+            ;; (setq ispell-cmd-args (flyspell-detect-ispell-args))
+            (defadvice ispell-word (around my-ispell-word activate)
+              (let ((old-ispell-extra-args ispell-extra-args))
+                (ispell-kill-ispell t)
+                ;; use emacs original arguments
+                (setq ispell-extra-args (flyspell-detect-ispell-args))
+                ad-do-it
+                ;; restore our own ispell arguments
+                (setq ispell-extra-args old-ispell-extra-args)
+                (ispell-kill-ispell t)))
+
+            (defadvice flyspell-auto-correct-word (around my-flyspell-auto-correct-word activate)
+              (let* ((old-ispell-extra-args ispell-extra-args))
+                (ispell-kill-ispell t)
+                ;; use emacs original arguments
+                (setq ispell-extra-args (flyspell-detect-ispell-args))
+                ad-do-it
+                ;; restore our own ispell arguments
+                (setq ispell-extra-args old-ispell-extra-args)
+                (ispell-kill-ispell t)))
+            (setq flyspell-issue-message-flag nil)
+
+            (defun fly-text-mode-hook-setup ()
+              ;; Turn off RUN-TOGETHER option when spell check text-mode
+              (setq-local ispell-extra-args (flyspell-detect-ispell-args)))
+            (add-hook 'text-mode-hook 'fly-text-mode-hook-setup)
+            (add-hook 'prog-mode-hook #'flyspell-prog-mode)))
+#+END_SRC
+
 * Scripting
 
 Make a shell-script buffer executable after saving it, if it has a shebang.
@@ -2274,8 +2367,6 @@ I like to use the clipboard more than the primary selection in X11.
          ("s" . copy-as-format-slack)))
 #+END_SRC
 
-**
-
 ** Selection
 
 I’m quite used to deleting text by selecting it and typing.  Emacs has
@@ -2363,12 +2454,11 @@ saw that multiple-cursors was released for Emacs.
 #+BEGIN_SRC emacs-lisp
 (use-package multiple-cursors
   :defer 1
-  :config (progn
-            (bind-key "C-." #'mc/mark-next-like-this)
-            (bind-key "C-," #'mc/mark-previous-like-this)
-            (bind-key "M-<f3>" #'mc/mark-all-like-this-dwim)
-            (bind-key "C-<f3>" #'mc/mark-more-like-this-extended)
-            (bind-key "C-S-L" #'mc/edit-lines)))
+  :bind* (("C-." . mc/mark-next-like-this)
+          ("C-," . mc/mark-previous-like-this)
+          ("M-<f3>" . mc/mark-all-like-this-dwim)
+          ("C-<f3>" . mc/mark-more-like-this-extended)
+          ("C-S-L" . mc/edit-lines)))
 #+END_SRC
 
 ** paredit
diff --git a/git/.config/git/config b/git/.config/git/config
index ed5fc67..b0d5606 100644
--- a/git/.config/git/config
+++ b/git/.config/git/config
@@ -22,6 +22,8 @@
 	delete-merged = "!sh -c 'git branch --merged | grep -v "\\*" | grep -v master | grep -v dev | xargs -n 1 git branch -d'"
 [github]
 	user = alan@alanpearce.uk
+[ghq "ssh://alanpearce.eu/"]
+  vcs = git
 [diff]
 	algorithm = patience
 [include]
diff --git a/ledger/.ledgerrc b/ledger/.ledgerrc
new file mode 100644
index 0000000..e2499f3
--- /dev/null
+++ b/ledger/.ledgerrc
@@ -0,0 +1 @@
+--date-format %F
diff --git a/zsh/.config/zsh/.zshenv b/zsh/.config/zsh/.zshenv
index 512dc56..b026d9a 100644
--- a/zsh/.config/zsh/.zshenv
+++ b/zsh/.config/zsh/.zshenv
@@ -10,7 +10,7 @@ then
     . $ZDOTDIR/zshenv.private
   fi
 
-  ZPLUG_HOME=${ZPLUG_HOME:-~/projects/zplug}
+  ZPLUG_HOME=${ZPLUG_HOME:-~/projects/github.com/zplug/zplug/}
 
   if [[ -z $SSH_AUTH_SOCK ]]
   then
@@ -46,6 +46,23 @@ then
       ;;
   esac
 
+  if [[ ${path[(I)$HOME/bin ]} ]]
+  then
+    path+=($HOME/bin)
+  fi
+
+  if [[ ${path[(I)$HOME/.local/bin ]} ]]
+  then
+    path+=($HOME/.local/bin)
+  fi
+
+  if [[ ${path[(I)$HOME/go/bin ]} ]]
+  then
+    path+=($HOME/go/bin)
+  fi
+
   export GTAGSCONF=~/.globalrc
   export GTAGSLABEL=ctags
+
+  export GHQ_ROOT="$HOME/projects:$HOME/go/src"
 fi
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc
index 8a9c806..23f852e 100644
--- a/zsh/.config/zsh/.zshrc
+++ b/zsh/.config/zsh/.zshrc
@@ -6,6 +6,7 @@ zplug "junegunn/fzf-bin", from:gh-r, as:command, rename-to:fzf
 zplug "junegunn/fzf", as:plugin, use:"shell/*.zsh", defer:2
 zplug "junegunn/fzf", as:command, use:"bin/*"
 zplug "caarlos0/zsh-open-pr", as:plugin
+zplug "zdharma/fast-syntax-highlighting", as:plugin
 zplug "unixorn/tumult.plugin.zsh", as:plugin, if:"[[ $os -eq darwin ]]"
 if [[ -n $commands[nix-env] ]]
 then
@@ -13,10 +14,10 @@ then
   fpath=($fpath $ZPLUG_REPOS/spwhitt/nix-zsh-completions)
 fi
 
-zplug "gerges/oh-my-zsh-jira-plus", as:plugin, if:"[[ ${(SN)HOST%spotcap} ]]"
 zplug "plugins/yarn", from:oh-my-zsh, defer:2, if:"[[ -n $commands[yarn] ]]", defer:2
 zplug "lukechilds/zsh-better-npm-completion", if:"[[ -n $commands[npm] ]]", defer:2
 zplug "hlissner/zsh-autopair", defer:2
+zplug "${GOPATH:=$HOME/go}/src/github.com/motemen/ghq/zsh/", from:local, if:"[[ -n $commands[ghq] ]]", defer:2
 
 HISTSIZE=3000
 SAVEHIST=10000
@@ -24,16 +25,6 @@ HISTFILE=${XDG_CACHE_HOME:=$HOME/.cache}/zsh/history
 
 WORDCHARS=${${WORDCHARS//[-.]}//[\/]}
 
-if [[ ${path[(I)$HOME/bin ]} ]]
-then
-  path+=($HOME/bin)
-fi
-
-if [[ ${path[(I)$HOME/.local/bin ]} ]]
-then
-  path+=($HOME/.local/bin)
-fi
-
 if [[ -d /opt/local/share/zsh/site-functions ]]
 then
   fpath+=(/opt/local/share/zsh/site-functions)
@@ -121,11 +112,15 @@ ds () {
   du -hd1 $1 | sort -h
 }
 
+# returns the first ghq root, whereas $GHQ_ROOT returns all
+hash -d p=$(ghq root)
+hash -d go=${GOPATH:-$HOME/go}
+
 zle -C hist-complete complete-word _generic
 zstyle ':completion:hist-complete:*' completer _history
 bindkey '\e ' hist-complete
 
-zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' '+m:{A-Z}={a-z}'
+zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
 zstyle ':completion:*' completer _expand _complete _match
 
 if [[ -z $SSH_AUTH_SOCK && $commands[ssh-agent] ]]
@@ -133,12 +128,6 @@ then
   eval $(ssh-agent)
 fi
 
-if zplug check gerges/oh-my-zsh-jira-plus
-then
-  JIRA_RAPID_BOARD=true
-  JIRA_URL=https://spotcap.atlassian.net
-fi
-
 # Then, source plugins and add commands to $PATH
 zplug load
 
@@ -230,6 +219,7 @@ fi
 
 if zplug check junegunn/fzf
 then
+  bindkey '^T' transpose-chars
   _fzf_compgen_path() {
     echo "$1"
     command find -L "$1" \
@@ -242,6 +232,30 @@ then
             -name .git -prune -o -name .svn -prune -o -type d \
             -a -not -path "$1" -print 2> /dev/null | sed 's@^\./@@'
   }
+
+  fp () {
+    ghq look $(ghq list | fzf +m)
+  }
+  cd-project-widget () {
+    local cmd="ghq list"
+    setopt localoptions pipefail 2> /dev/null
+    local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" fzf +m)"
+    if [[ -z "$dir" ]]; then
+      zle redisplay
+      return 0
+    fi
+    cd $(ghq list --full-path | grep "$dir")
+    local ret=$?
+    zle reset-prompt
+    typeset -f zle-line-init >/dev/null && zle zle-line-init
+    return $ret
+  }
+  zle -N cd-project-widget
+  bindkey '\es' cd-project-widget
 fi
 
+function function eb-active-environment () {
+  aws elasticbeanstalk describe-environments | grep $(dig +short $1 CNAME) | cut -f10
+}
+
 unsetopt flow_control       # Let me use ^S and ^Q