git.fiddlerwoaroof.com
Browse code

zsh and emacs changes

- zsh: make vsp and friends work more reliably cross-platform
- emacs: various tweaks

Ed Langley authored on 09/03/2018 16:31:07
Showing 5 changed files
... ...
@@ -6,6 +6,7 @@
6 6
 
7 7
 ;;(let ((file-name-handler-alist nil))
8 8
 
9
+(setq fwoar.is-ordinary (not (string= invocation-name "EmacsNotes")))
9 10
 (add-hook 'after-init-hook
10 11
           (lambda ()
11 12
             ;; (require 'projectile)
... ...
@@ -13,8 +14,11 @@
13 14
 
14 15
             (unless (fboundp 'server-running-p)
15 16
               (require 'server))
16
-            (unless (server-running-p)
17
-              (server-start))
17
+            (let ((server-name (if fwoar.is-ordinary
18
+                                   server-name
19
+                                 "notes")))
20
+                               (unless (server-running-p)
21
+               (server-start)))
18 22
             (projectile-mode)
19 23
             (evil-mode)
20 24
             (paredit-mode)
... ...
@@ -30,7 +34,6 @@
30 34
 
31 35
             ))
32 36
 
33
-
34 37
 (when (file-exists-p "/usr/local/bin/gls")
35 38
   (setq insert-directory-program "/usr/local/bin/gls"))
36 39
 
... ...
@@ -342,8 +345,6 @@
342 345
 
343 346
 (setq gc-cons-threshold (* 100 1024))
344 347
 
345
-(setq fwoar.is-ordinary (not (string= invocation-name "EmacsNotes")))
346
-
347 348
 (unless fwoar.is-ordinary
348 349
   (setq with-editor-emacsclient-executable "/usr/local/bin/emacsclient")
349 350
   (require 'cjpad)
350 351
new file mode 100644
... ...
@@ -0,0 +1,19 @@
1
+(defun op--collect-args (body)
2
+  (flet ((walker (body &optional args)
3
+                 (if (null body)
4
+                     args
5
+                   (if (symbolp body)
6
+                       (when (eql ?\_ (elt (symbol-name body) 0))
7
+                         (cons body args))
8
+                     (if (listp body)
9
+                         (append (op--collect-args (car body))
10
+                                 (op--collect-args (cdr body))
11
+                                 ))))))
12
+    (sort (walker body)
13
+          (lambda (a b)
14
+            (< (string-to-number (subseq (symbol-name a) 1))
15
+               (string-to-number (subseq (symbol-name b) 1)))))))
16
+
17
+(defmacro op (&rest body)
18
+  `(lambda ,(op--collect-args body)
19
+     ,@body))
... ...
@@ -1,5 +1,5 @@
1
-if [[ -o interactive ]]; then
2
-  if [ "$TERM" != "screen" -a "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" ]; then
1
+if [[ $TERM_PROGRAM == "iTerm.app" && -o interactive ]]; then
2
+  if [ "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != "screen" -a "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" ]; then
3 3
     ITERM_SHELL_INTEGRATION_INSTALLED=Yes
4 4
     ITERM2_SHOULD_DECORATE_PROMPT="1"
5 5
     # Indicates start of command output. Runs just before command executes.
... ...
@@ -120,7 +120,11 @@ if [[ -o interactive ]]; then
120 120
     }
121 121
 
122 122
     # If hostname -f is slow on your system, set iterm2_hostname prior to sourcing this script.
123
-    [[ -z "$iterm2_hostname" ]] && iterm2_hostname=`hostname -f`
123
+    [[ -z "$iterm2_hostname" ]] && iterm2_hostname=`hostname -f 2>/dev/null`
124
+    # some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option
125
+    if [ $? -ne 0 ]; then
126
+      iterm2_hostname=`hostname`
127
+    fi
124 128
 
125 129
     if [[ "$TERM_PROGRAM" = "iTerm.app" ]]; then 
126 130
       [[ -z $precmd_functions ]] && precmd_functions=()
... ...
@@ -129,8 +133,8 @@ if [[ -o interactive ]]; then
129 133
       [[ -z $preexec_functions ]] && preexec_functions=()
130 134
       preexec_functions=($preexec_functions iterm2_preexec)
131 135
 
132
-      iterm2_print_state_data
133
-      printf "\033]1337;ShellIntegrationVersion=5;shell=zsh\007"
134
-    fi
136
+    iterm2_print_state_data
137
+    printf "\033]1337;ShellIntegrationVersion=6;shell=zsh\007"
135 138
   fi
136 139
 fi
140
+alias imgcat=~/.iterm2/imgcat;alias imgls=~/.iterm2/imgls;alias it2attention=~/.iterm2/it2attention;alias it2check=~/.iterm2/it2check;alias it2copy=~/.iterm2/it2copy;alias it2dl=~/.iterm2/it2dl;alias it2getvar=~/.iterm2/it2getvar;alias it2setcolor=~/.iterm2/it2setcolor;alias it2setkeylabel=~/.iterm2/it2setkeylabel;alias it2ul=~/.iterm2/it2ul;alias it2universion=~/.iterm2/it2universion
... ...
@@ -1,27 +1,35 @@
1
+man-() {
2
+  (echo ".ll 18.0i"; echo ".nr LL 18.0i"; /bin/cat) | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c
3
+}
4
+
1 5
 vspf() {
2
-  tmux split-window -h "$*"
6
+  tmux split-window -h "$*; sleep 1"
3 7
 }
4 8
 vsp() {
5
-  tmux split-window -d -h "$*"
9
+  tmux split-window -d -h "$*; sleep 1"
6 10
 }
7 11
 sp() {
8
-  tmux split-window -d "$*"
12
+  tmux split-window -d "$*; sleep 1"
9 13
 }
10 14
 spf() {
11
-  tmux split-window "$*"
15
+  tmux split-window "$*; sleep 1"
16
+}
17
+
18
+pager() {
19
+  $PAGER -f "$*"
12 20
 }
13 21
 
14 22
 _vman_helper() {
15 23
   inp="`mktemp -u`"
16 24
   mkfifo "$inp"
17 25
   echo "$inp"
18
-  vsp man -l "$inp"
26
+  vsp man- "$inp"
19 27
 }
20 28
 
21 29
 vman() {
22 30
   if [[ x"$TMUX" != x"" ]]; then
23 31
     if [[ x"$1" == "x" ]]; then
24
-      cat - > `_vman_helper`
32
+      cat - | man- > `_vman_helper`
25 33
     else
26 34
       vsp man $*
27 35
     fi
... ...
@@ -34,7 +42,7 @@ _vless_helper() {
34 42
   inp="`mktemp -u`"
35 43
   mkfifo "$inp"
36 44
   echo "$inp"
37
-  vsp $PAGER "$inp"
45
+  vsp ${PAGER:-less} -f "$inp"
38 46
 }
39 47
 
40 48
 vless() {
... ...
@@ -1,9 +1,5 @@
1 1
 # Requires pandoc
2 2
 
3
-man-() {
4
-  (echo ".ll 18.0i"; echo ".nr LL 18.0i"; /bin/cat) | /usr/bin/tbl | /usr/bin/groff -Wall -mtty-char -Tascii -mandoc -c
5
-}
6
-
7 3
 2man() {
8 4
   input="$2"
9 5
   if [[ "$input" == "" ]]; then
... ...
@@ -17,11 +13,11 @@ alias md2man='2man markdown'
17 13
 alias latex2man='2man latex'
18 14
 
19 15
 _pandoc_view() {
20
-  2man $1 $2 | man -l -
16
+  2man $1 $2 | man-
21 17
 }
22 18
 
23 19
 pandoc_view() {
24
-  man_fun="man -l -"
20
+  man_fun="man-"
25 21
   _pandoc_view $*
26 22
 }
27 23
 
... ...
@@ -34,7 +30,7 @@ dump_md() {
34 30
 }
35 31
 
36 32
 vpandoc_view() {
37
-  man_fun=vman
33
+  man_fuvman
38 34
   _pandoc_view $*
39 35
 }
40 36