mirror of
https://github.com/stumpwm/stumpwm-contrib.git
synced 2026-09-10 07:26:25 -04:00
Save *input-history* on quitting StumpWM and reloading it again on start (#93)
Add Command History module
This commit is contained in:
parent
de3ce80c23
commit
81f64c8fb9
|
|
@ -78,3 +78,4 @@ to the world!
|
|||
- [[./util/windowtags/README.org][windowtags]]
|
||||
- [[./util/kbd-layouts/README.org][kbd-layouts]]
|
||||
- [[./util/pinentry/README.org][pinentry]]
|
||||
- [[./util/command-history/README.org][command-history]]
|
||||
|
|
|
|||
13
util/command-history/README.org
Normal file
13
util/command-history/README.org
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# command-history
|
||||
|
||||
*** Problem
|
||||
After quiting StumpWM, you command history is gone.
|
||||
This simple plugin saves the lisp =stumpwm::*input-history*= to =~/.stumpwm.d/history= and loads it again when starting StumpWM.
|
||||
|
||||
** Usage
|
||||
Add this to your =.stumpwmrc=:
|
||||
|
||||
Load contrib module:
|
||||
#+BEGIN_SRC lisp
|
||||
(load-module "command-history")
|
||||
#+END_SRC
|
||||
11
util/command-history/command-history.asd
Normal file
11
util/command-history/command-history.asd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
;;;; command-history.asd
|
||||
|
||||
(asdf:defsystem #:command-history
|
||||
:description "Save and load the stumpwm::*input-history* to a file"
|
||||
:author "Arjen Dijkstra"
|
||||
:license "GPLv3"
|
||||
:version "0.0.1"
|
||||
:serial t
|
||||
:depends-on (#:stumpwm)
|
||||
:components ((:file "package")
|
||||
(:file "command-history")))
|
||||
34
util/command-history/command-history.lisp
Normal file
34
util/command-history/command-history.lisp
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
;;;; command-history.lisp
|
||||
|
||||
(in-package #:command-history)
|
||||
|
||||
(export '(*start-hook*
|
||||
*quit-hook*))
|
||||
|
||||
(defvar *home-dir* (getenv "HOME"))
|
||||
|
||||
(defvar *command-history-file*
|
||||
(merge-pathnames
|
||||
(format nil "~A/.stumpwm.d/history" *home-dir*)))
|
||||
|
||||
(defun load-input-history ()
|
||||
"Load *input-history* to file."
|
||||
(with-open-file (in *command-history-file* :if-does-not-exist nil)
|
||||
(when in
|
||||
(with-standard-io-syntax
|
||||
(setf stumpwm::*input-history* (read in))))))
|
||||
|
||||
(defun save-input-history ()
|
||||
"Save current *input-history* to file."
|
||||
(with-open-file (out *command-history-file*
|
||||
:direction :output
|
||||
:if-does-not-exist :create
|
||||
:if-exists :supersede)
|
||||
(with-standard-io-syntax
|
||||
(print
|
||||
(remove-duplicates stumpwm::*input-history* :test #'string= :from-end t)
|
||||
out))))
|
||||
|
||||
(add-hook *start-hook* 'load-input-history)
|
||||
|
||||
(add-hook *quit-hook* 'save-input-history)
|
||||
4
util/command-history/package.lisp
Normal file
4
util/command-history/package.lisp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;;;; package.lisp
|
||||
|
||||
(defpackage #:command-history
|
||||
(:use #:cl :stumpwm))
|
||||
Loading…
Reference in a new issue