git.fiddlerwoaroof.com
Browse code

initial

fiddlerwoaroof authored on 01/11/2015 20:40:16
Showing 4 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+# A simple clipboard utility
2
+
3
+This wraps <https://github.com/Shinmera/buildapp> to provide a handy suite of
4
+utilities to manage a set of named clipboards.
5
+
6
+# Installation
7
+
8
+  sbcl --load ~/quicklisp/setup.lisp --eval '(ql:quickload :buildapp)' --eval '(buildapp:build-buildapp)'
9
+
10
+  ./buildapp --output ~/bin/multicall/uclip --asdf-tree ~/quicklisp/quicklisp --asdf-path `pwd` --load-system uclip --dispatched-entry ucopy/uclip::copy --dispatched-entry /uclip::paste --dispatched-entry upaste/uclip::paste --dispatched-entry uswitch/uclip::switch-clipboards --dispatched-entry uclipop/uclip::pop-clipboard
11
+
12
+  args  -n1  ln -fs multicall/uclip <<EOF
13
+  ucopy
14
+  upaste
15
+  uswitch
16
+  uclipop
17
+  EOF
0 18
new file mode 100644
... ...
@@ -0,0 +1,5 @@
1
+;;;; package.lisp
2
+
3
+(defpackage #:uclip
4
+  (:use #:cl #:alexandria #:ubiquitous #:anaphora))
5
+
0 6
new file mode 100644
... ...
@@ -0,0 +1,13 @@
1
+;;;; ubiquitous-clipboard.asd
2
+
3
+(asdf:defsystem #:uclip
4
+  :description "Describe uclip here"
5
+  :author "fiddlerwoaroof <fiddlerwoaroof+uc@gmail.com>"
6
+  :license "GPL2"
7
+  :depends-on (#:alexandria
8
+                #:anaphora
9
+                #:ubiquitous)
10
+  :serial t
11
+  :components ((:file "package")
12
+               (:file "uclip")))
13
+
0 14
new file mode 100644
... ...
@@ -0,0 +1,40 @@
1
+;;;; uclip.lisp
2
+
3
+(in-package #:uclip)
4
+
5
+
6
+
7
+(defvar *current-clipboard*)
8
+(defun init ()
9
+  (restore 'uclip) 
10
+  (setf *current-clipboard* (defaulted-value "main" 'current-clipboard)))
11
+
12
+(defun copy (argv)
13
+  (init)
14
+  (push (cond ((null (cdr argv))
15
+               (apply #'concatenate
16
+                      (list* 'string
17
+                             (loop for a := (read-line *standard-input* nil)
18
+                                   while (not (null a))
19
+                                   collect (format nil "~a~%" a)))))
20
+              (t (format nil "~{~a~^ ~}" (cdr argv))))
21
+        (value 'clipboard *current-clipboard*)))
22
+
23
+(defun paste (argv)
24
+  (declare (ignore argv))
25
+  (init) 
26
+  (let ((*current-clipboard*
27
+          (if (cdr argv) (cadr argv) *current-clipboard*)))
28
+    (awhen (car (value 'clipboard *current-clipboard*))
29
+      (format t "~a" it))))
30
+
31
+(defun switch-clipboards (argv)
32
+  (init) 
33
+  (setf *current-clipboard*
34
+        (setf (value 'current-clipboard) (cadr argv))))
35
+
36
+(defun pop-clipboard (argv)
37
+  (declare (ignore argv))
38
+  (init) 
39
+  (when (value 'clipboard *current-clipboard*)
40
+    (format t "~a" (pop (value 'clipboard *current-clipboard*)))))