next: Add experimental shell mode.
parent
629424836d
commit
a30d284343
|
@ -65,3 +65,47 @@
|
|||
(with-result (url (buffer-get-url))
|
||||
(uiop:run-program (list "mpv" url))))
|
||||
(define-key "C-M-c v" 'play-video-in-current-page)
|
||||
|
||||
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(define-mode shell-mode ()
|
||||
"A basic shell prompt."
|
||||
((keymap
|
||||
:initform
|
||||
(let ((map (make-keymap)))
|
||||
(define-key :keymap map
|
||||
"c" 'run-shell-command
|
||||
"k" 'clear-shell)
|
||||
map))))
|
||||
|
||||
(define-parenscript clear-shell-output ()
|
||||
(setf (ps:chain document body inner-h-t-m-l) ""))
|
||||
|
||||
(define-command clear-shell (shell-mode)
|
||||
"Clear the output in the shell buffer."
|
||||
(rpc-buffer-evaluate-javascript
|
||||
*interface* (active-buffer *interface*)
|
||||
(clear-shell-output)))
|
||||
|
||||
(define-parenscript append-output (output)
|
||||
(setf (ps:chain document body inner-h-t-m-l)
|
||||
(ps:chain document body inner-h-t-m-l
|
||||
(concat (ps:lisp
|
||||
(format nil "<pre><code>~a</code></pre><br/>" output))))))
|
||||
|
||||
(define-command run-shell-command (shell-mode)
|
||||
"Run a shell command."
|
||||
(with-result
|
||||
(input (read-from-minibuffer
|
||||
(minibuffer *interface*)
|
||||
:input-prompt "Run in shell for Aparna:"))
|
||||
(rpc-buffer-evaluate-javascript
|
||||
*interface* (active-buffer *interface*)
|
||||
(append-output
|
||||
:output
|
||||
(uiop:run-program input :force-shell t :output :string)))))
|
||||
|
||||
(define-command shell ()
|
||||
"Open a shell buffer."
|
||||
(set-active-buffer *interface* (make-buffer :name "*shell*" :default-modes '(shell-mode))))
|
||||
|
||||
(define-key "C-x s" #'shell)
|
||||
|
|
Loading…
Reference in New Issue