mirror of
https://github.com/stumpwm/stumpwm-contrib.git
synced 2026-09-10 07:26:25 -04:00
- added module to make shell history persistent.
This commit is contained in:
parent
d981d18af8
commit
42286d1f68
|
|
@ -106,6 +106,7 @@ Please see =README.org= files for each module for further details. Missing modul
|
|||
- [[./util/golden-ratio/README.org][swm-golden-ratio]] :: Resize the currently focused frame to the golden ratio
|
||||
- [[./util/kbd-layouts/README.org][kbd-layouts]] :: Keyboard layout switcher for StumpWM
|
||||
- [[./util/logitech-g15-keysyms/README.org][logitech-g15-keysyms]] :: Describe logitech-g15-keysyms here
|
||||
- [[./util/lookup/README.org][lookup]] :: Dictionary/search engine lookup module for StumpWM.
|
||||
- [[./util/notify/README.org][notify]] :: DBus-based notification server part
|
||||
- [[./util/numpad-layouts/README.org][numpad-layouts]] :: A module for handling different keyboards numpad layouts
|
||||
- [[./util/pass/README.org][pass]] :: Integrate 'pass' with StumpWM
|
||||
|
|
@ -116,6 +117,7 @@ Please see =README.org= files for each module for further details. Missing modul
|
|||
- [[./util/qubes/README.org][qubes]] :: Integration to Qubes OS (https://www.qubes-os.org)
|
||||
- [[./util/screenshot/README.org][screenshot]] :: Takes screenshots and stores them as png files
|
||||
- [[./util/searchengines/README.org][searchengines]] :: Allows searching text using prompt or clipboard contents with various search engines
|
||||
- [[./util/shell-command-history/README.org][shell-command-history]] :: Save and load the stumpwm::*input-shell-history* to a file
|
||||
- [[./util/surfraw/README.org][surfraw]] :: Integrates surfraw with stumpwm.
|
||||
- [[./util/swm-emacs/README.org][swm-emacs]] :: A set of utilities for launching the beast.
|
||||
- [[./util/swm-gaps/README.org][swm-gaps]] :: Pretty (useless) gaps for StumpWM
|
||||
|
|
|
|||
27
util/shell-command-history/README.org
Normal file
27
util/shell-command-history/README.org
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
* Problem
|
||||
|
||||
After quiting StumpWM, your shell command history is gone. This
|
||||
simple plugin saves the lisp ~stumpwm::*input-shell-history*~ to the
|
||||
contents of special variable ~*shell-command-history-file*~ (default
|
||||
to: ~~/.stumpwm.d/shell-history~) and loads it again when starting
|
||||
StumpWM.
|
||||
|
||||
** Usage
|
||||
Add this to your ~.stumpwmrc~ (your main configuration file):
|
||||
|
||||
Load contrib module:
|
||||
#+BEGIN_SRC lisp
|
||||
(load-module "shell-command-history")
|
||||
#+END_SRC
|
||||
|
||||
You can customize the shell history file's path:
|
||||
|
||||
#+BEGIN_SRC lisp
|
||||
(setf shell-command-history:*shell-command-history-file*
|
||||
"/home/cage/.cache/stumpwm/shell-command-history")
|
||||
#+END_SRC
|
||||
|
||||
* NOTE
|
||||
|
||||
This code is derived from ~command-history~ © Arjen Dijkstra, released
|
||||
under GPLv3
|
||||
9
util/shell-command-history/package.lisp
Normal file
9
util/shell-command-history/package.lisp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
;;;; package.lisp
|
||||
|
||||
(defpackage :shell-command-history
|
||||
(:use :cl
|
||||
:stumpwm)
|
||||
(:export
|
||||
:*shell-command-history-file*
|
||||
:*start-hook*
|
||||
:*quit-hook*))
|
||||
11
util/shell-command-history/shell-command-history.asd
Normal file
11
util/shell-command-history/shell-command-history.asd
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
;;;; shell-command-history.asd
|
||||
|
||||
(asdf:defsystem :shell-command-history
|
||||
:description "Save and load the stumpwm::*input-shell-history* to a file"
|
||||
:author "cage"
|
||||
:license "GPLv3"
|
||||
:version "0.0.1"
|
||||
:serial t
|
||||
:depends-on (:stumpwm)
|
||||
:components ((:file "package")
|
||||
(:file "shell-command-history")))
|
||||
30
util/shell-command-history/shell-command-history.lisp
Normal file
30
util/shell-command-history/shell-command-history.lisp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
;;;; command-history.lisp
|
||||
|
||||
(in-package #:shell-command-history)
|
||||
|
||||
(defvar *home-dir* (getenv "HOME"))
|
||||
|
||||
(defvar *shell-command-history-file* (merge-pathnames (format nil
|
||||
"~A/.stumpwm.d/shell-history"
|
||||
*home-dir*)))
|
||||
|
||||
(defun load-input-history ()
|
||||
"Load *input-history* to file."
|
||||
(with-open-file (in *shell-command-history-file* :if-does-not-exist nil)
|
||||
(when in
|
||||
(with-standard-io-syntax
|
||||
(setf stumpwm::*input-shell-history* (read in))))))
|
||||
|
||||
(defun save-input-history ()
|
||||
"Save current *input-history* to file."
|
||||
(with-open-file (out *shell-command-history-file*
|
||||
:direction :output
|
||||
:if-does-not-exist :create
|
||||
:if-exists :supersede)
|
||||
(with-standard-io-syntax
|
||||
(print (remove-duplicates stumpwm::*input-shell-history* :test #'string= :from-end t)
|
||||
out))))
|
||||
|
||||
(add-hook *start-hook* 'load-input-history)
|
||||
|
||||
(add-hook *quit-hook* 'save-input-history)
|
||||
Loading…
Reference in a new issue