# HG changeset patch # User Steve Losh # Date 1562171416 14400 # Node ID e27888136324cc4658b1ac095e4579edd443cb57 # Parent 639612e93fe858c2bc8fbc54c2d7fcf6dcc65368 More diff -r 639612e93fe8 -r e27888136324 bin/heading --- a/bin/heading Mon Jun 24 16:16:16 2019 -0700 +++ b/bin/heading Wed Jul 03 12:30:16 2019 -0400 @@ -4,5 +4,5 @@ shift echo -toilet -t -k -F metal:crop -f "$FONT" "$@" +toilet -t -F gay:crop -f "$FONT" "$@" echo diff -r 639612e93fe8 -r e27888136324 bin/pathpb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/pathpb Wed Jul 03 12:30:16 2019 -0400 @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +readlink -n -f "$1" | pbcopy diff -r 639612e93fe8 -r e27888136324 fish/config.fish --- a/fish/config.fish Mon Jun 24 16:16:16 2019 -0700 +++ b/fish/config.fish Wed Jul 03 12:30:16 2019 -0400 @@ -21,8 +21,6 @@ alias p pass alias pw pass-work -complete -c s -w ssh - # I give up alias :q exit alias :qa exit @@ -43,7 +41,9 @@ )" end -make_completion g "git" +complete -c s -w ssh +complete -c cw -w which +complete -c ew -w which # }}} # Bind Keys {{{ @@ -87,6 +87,7 @@ prepend_to_path "$HOME/src/dotfiles/bin" prepend_to_path "$HOME/src/hg" prepend_to_path "$HOME/bin" +prepend_to_path "$HOME/.go/bin" set BROWSER open diff -r 639612e93fe8 -r e27888136324 grcat/conf.tail-vm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/grcat/conf.tail-vm Wed Jul 03 12:30:16 2019 -0400 @@ -0,0 +1,15 @@ +# err +regexp=(ERR ) +colours=default,red +======= +# warn +regexp=(WARN ) +colours=default,yellow +======= +# info +regexp=(INFO ) +colours=default,cyan +======= +# time +regexp=(^\d\d:\d\d:\d\d) +colours=bright_black diff -r 639612e93fe8 -r e27888136324 lisp/batchcolor.lisp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lisp/batchcolor.lisp Wed Jul 03 12:30:16 2019 -0400 @@ -0,0 +1,122 @@ +(eval-when (:compile-toplevel :load-toplevel :execute) + (ql:quickload '(:adopt :cl-ppcre ) :silent t)) + +(defpackage :batchcolor + (:use :cl) + (:export :toplevel :*ui*)) + +(in-package :batchcolor) + +;;;; Configuration ------------------------------------------------------------ +(defparameter *version* "0.0.1") +(defparameter *colors* (make-hash-table :test #'equal)) + + +;;;; Functionality ------------------------------------------------------------ +(defun rgb-code (color) + (destructuring-bind (r g b) color + ;; The 256 color mode color values are essentially r/g/b in base 6, but + ;; shifted 16 higher to account for the intiial 8+8 colors. + (+ (* r 36) + (* g 6) + (* b 1) + 16))) + +(defun random-color () + (loop :for color = (list (random 6) (random 6) (random 6)) + :while (<= (apply #'+ color) 3) + :finally (return color))) + +(defun find-color (string) + (let ((current (gethash string *colors*))) + (if current + current + (setf (gethash string *colors*) (random-color))))) + +(defun ansi-color-start (color) + (format nil "~C[38;5;~Dm" #\Escape (rgb-code color))) + +(defun ansi-color-end () + (format nil "~C[0m" #\Escape)) + +(defun colorize-line (scanner line &aux (start 0)) + (ppcre:do-scans (ms me rs re scanner line) + (setf rs (remove nil rs) + re (remove nil re)) + (when (/= 1 (length rs)) + (error "Regex must contain exactly 1 register group, e.g. 'x (fo+) y'.")) + (let* ((word-start (aref rs 0)) + (word-end (aref re 0)) + (word (subseq line word-start word-end)) + (color (find-color word))) + (write-string line *standard-output* :start start :end word-start) + (format t "~A~A~A" (ansi-color-start color) word (ansi-color-end)) + (setf start word-end))) + (write-line line *standard-output* :start start) + (values)) + + +;;;; Run ---------------------------------------------------------------------- +(defun run (pattern) + (loop + :with scanner = (ppcre:create-scanner pattern) + :for line = (read-line *standard-input* nil) + :while line :do (colorize-line scanner line))) + + +;;;; User Interface ----------------------------------------------------------- +(defparameter *examples* + '(("Colorize IRC nicknames in a chat log:" + . "cat channel.log | batchcolor '<(\\\\w+)>'") + ("Colorize UUIDs in a request log:" + . "tail -f /var/log/foo | batchcolor '([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})'"))) + + +(defparameter *option-help* + (adopt:make-option 'help + :help "Display help and exit." + :long "help" + :short #\h + :reduce (constantly t))) + +(defparameter *option-version* + (adopt:make-option 'version + :help "Display version information and exit." + :long "version" + :reduce (constantly t))) + + +(adopt:define-string *help-text* + "batchcolor takes a regular expression and matches it against standard ~ + input one line at a time. Each unique match is highlighted in a random ~ + color.") + +(defparameter *ui* + (adopt:make-interface + :name "batchcolor" + :usage "[OPTIONS] REGEX" + :summary "colorize regex matches in batches" + :help *help-text* + :examples *examples* + :contents (list *option-help* + *option-version*))) + + +(defun toplevel () + #+sbcl (sb-ext:disable-debugger) + (handler-case + (multiple-value-bind (arguments options) (adopt:parse-options *ui*) + (when (gethash 'help options) + (adopt:print-help-and-exit *ui*)) + (when (gethash 'version options) + (write-line *version*) + (adopt:exit)) + (if (/= 1 (length arguments)) + (adopt:print-help-and-exit *ui*) + (destructuring-bind (pattern) arguments + (run pattern)))) + (error (c) (adopt:print-error-and-exit c)) + #+sbcl (sb-sys:interactive-interrupt (c) + (declare (ignore c)) + (adopt:exit)))) + diff -r 639612e93fe8 -r e27888136324 lispwords --- a/lispwords Mon Jun 24 16:16:16 2019 -0700 +++ b/lispwords Wed Jul 03 12:30:16 2019 -0400 @@ -111,6 +111,7 @@ ; ppcre (2 register-groups-bind do-register-groups) +(1 do-scans) ; lparallel (1 pdotimes) diff -r 639612e93fe8 -r e27888136324 stumpwmrc --- a/stumpwmrc Mon Jun 24 16:16:16 2019 -0700 +++ b/stumpwmrc Wed Jul 03 12:30:16 2019 -0400 @@ -389,7 +389,7 @@ (run-or-raise "firefox" '(:class "Firefox"))) (defcommand terminal () () - (run-shell-command "st -f 'Ubuntu Mono:size=12'")) + (run-shell-command "st -f 'Ubuntu Mono:size=10'")) ;;;; Timers ------------------------------------------------------------------- diff -r 639612e93fe8 -r e27888136324 vim/vimrc --- a/vim/vimrc Mon Jun 24 16:16:16 2019 -0700 +++ b/vim/vimrc Wed Jul 03 12:30:16 2019 -0400 @@ -271,7 +271,9 @@ silent! digr // 9585 "U+2571=╱ BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT silent! digr \\ 9586 "U+2572=╲ BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT -silent! digr \|\| 8214 "U+2016=‖ DOUBLE VERTICAL LINE +silent! digr \|\| 8214 "U+2016=‖ DOUBLE VERTICAL LINE + +silent! digr ~~ 8967 "U+2307=⌇ WAVY LINE " }}} " Convenience mappings ---------------------------------------------------- {{{ @@ -2816,7 +2818,7 @@ autocmd! " Settings - au FileType vlime_sldb setlocal nowrap + au FileType vlime_sldb setlocal nowrap foldmethod=indent shiftwidth=8 tabstop=8 au FileType vlime_repl setlocal nowrap winfixheight " Keys for Lisp files @@ -2826,8 +2828,8 @@ au FileType lisp nnoremap i :call vlime#plugin#Inspect(vlime#ui#CurExprOrAtom()) au FileType lisp nnoremap I :call vlime#plugin#Inspect() au FileType lisp nnoremap M :call vlime#plugin#DocumentationSymbol(vlime#ui#CurAtom()) + au FileType lisp nnoremap gi :call IndentToplevelLispForm() au FileType lisp setlocal indentexpr=vlime#plugin#CalcCurIndent() - au FileType lisp nnoremap gi :call IndentToplevelLispForm() " Keys for the REPL au FileType vlime_repl nnoremap i :call vlime#ui#repl#InspectCurREPLPresentation()