Skip to content

Instantly share code, notes, and snippets.

@runejuhl
Created October 18, 2017 17:05
Show Gist options
  • Save runejuhl/b40072238ca9a58dd0c1488e45a0c88c to your computer and use it in GitHub Desktop.
Save runejuhl/b40072238ca9a58dd0c1488e45a0c88c to your computer and use it in GitHub Desktop.
(defvar *default-groups*
;; index, name, optionally key binding
'((1 "www")
(2 "irc")
(3 "mail")
(4 "emacs")
(5 "enableit")
(6 "projects")
(7 "stuff")
(8 "repl")
(9 "clojure")
(10 "shell1" "0")
(11 "shell2" "-")
(12 "shell3" "=")))
;;; functions
(defun initialize-groups ()
;; Initialize all default group and add keybindings for them.
(let* ((screen (current-screen))
(group (current-group))
(groups (progn
;; since the first group is always named *default-group-name*,
;; we have this special case
(if (string-equal (group-name group) *default-group-name*)
(setf (group-name group) (cadar *default-groups*)))
*default-groups*)))
(map
nil
(lambda (group)
(destructuring-bind (idx name &optional key) group
(let ((key (or key idx)))
(progn
;; create group if it doesn't exist
(unless (find-group screen name)
(add-group screen name))
;; select group on s-key
(define-key *top-map* (kbd (format nil "s-~A" key))
(format nil "gselect ~A" idx))
;; move to group on C-s-key
(define-key *top-map* (kbd (format nil "C-s-~A" key))
(format nil "gmove ~A" idx))))))
groups)))
;; do the things!
(initialize-groups)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment