--- a/bin/pastebin Mon Jan 06 17:02:45 2020 -0800
+++ b/bin/pastebin Mon Jan 06 17:03:06 2020 -0800
@@ -4,7 +4,7 @@
PASTE_SHA=$(ssh paste.stevelosh.com 'cat > tmppaste && sha1sum tmppaste | cut -d" " -f1 && mv tmppaste /var/www/paste/`sha1sum tmppaste | cut -d" " -f1`')
-echo -n "http://paste.stevelosh.com/$PASTE_SHA" | pbcopy
+echo -n "https://paste.stevelosh.com/$PASTE_SHA" | pbcopy
echo -n 'Copied '
tput bold
pbpaste
--- a/lisp/pick.lisp Mon Jan 06 17:02:45 2020 -0800
+++ b/lisp/pick.lisp Mon Jan 06 17:03:06 2020 -0800
@@ -34,7 +34,7 @@
(defun filter (choices)
(loop
- :with width = (1+ (reduce #'max choices :key #'length))
+ :with width = (1+ (reduce #'max choices :key #'length :initial-value 0))
:for choice :in choices
:when (prompt "~A~vA[yN] " choice (- width (length choice)) #\space)
:collect choice))
@@ -90,7 +90,15 @@
(adopt:define-string *help-text*
"pick displays its arguments one-by-one on standard error and prompts you ~
interactively to choose some of them. The chosen items will be printed to ~
- standard output.")
+ standard output.~@
+ ~@
+ An argument of - will cause pick to read lines from standard input as ~
+ choices. Using an explicit - instead of reading from standard input when no ~
+ arguments are present prevents something like 'pick `ls -1 | grep foo`' from ~
+ silently hanging forever if no files match.~@
+ ~@
+ This version was inspired by the pick program described in 'The UNIX ~
+ Programming Environment'.")
(defparameter *ui*
(adopt:make-interface
@@ -113,6 +121,10 @@
(with-open-file (*interactive-input* "/dev/tty" :direction :input)
(let ((*separator* (gethash 'separator options))
(*interactive-output* *error-output*))
- (run (or arguments (read-lines *standard-input*))))))
+ (run (mapcan (lambda (arg)
+ (if (string= "-" arg)
+ (read-lines *standard-input*)
+ (list arg)))
+ arguments)))))
(error (c) (adopt:print-error-and-exit c))))