Skip to content

Instantly share code, notes, and snippets.

@lesliesrussell
lesliesrussell / tempbind.el
Created January 20, 2024 13:23
temporarily rebind a key with automatic restore
(defun my-temporary-bind-key-with-restore ()
"Prompt for a register, a key sequence, and a command to temporarily bind the key to,
then automatically restore the original binding after a specified duration."
(interactive)
(let* ((register (read-char "Choose a register to save the current binding: "))
(key (read-key-sequence "Enter the key sequence to bind: "))
(original-command (key-binding key))
(new-command (read-command "Enter the command to bind to the key: "))
(duration (read-number "Enter the duration in seconds for the temporary binding: ")))
;; Save the original key binding to the register
@lesliesrussell
lesliesrussell / movement.el
Last active February 16, 2024 14:35
emacs movement by thing
;; Defines a transient keymap for movement controls and sets up a global key binding to activate this transient map. This transient map, `my-movement-transient-map`, includes bindings for various movement commands like moving forward or backward by a word or character and moving to the next or previous line. The `activate-my-movement-map` function is defined to activate this transient map, and it is globally bound to `C-f`.
;; This setup allows you to press `C-f` followed by one of the specified keys (`f`, `b`, `c`, `l`, `n`, `p`) to perform the corresponding movement operation. The `set-transient-map` call with a second argument of `t` ensures that the transient map stays active until one of its keys is pressed.
;; This is a neat way to create a custom, modal-like interface for movement within Emacs, leveraging your Emacs Lisp skills to tailor your editing environment to your preferences. If you have any specific modifications or additional features you'd like to implement, feel free to ask!
(defun my-dig
@lesliesrussell
lesliesrussell / test.el
Last active January 13, 2024 22:52
extract the hex color for the current line in "list-faces-display"
(defun extract-hex-code-current-line ()
(interactive)
(let ((line (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
(when (string-match "#\\([0-9a-fA-F]\\{6\\}\\)" line)
(let ((hex-code (match-string 1 line)))
(kill-new hex-code) ; Copy the hex code to the kill ring
(message "Copied hex code: %s" hex-code))))) ; Optional: Display a message confirming the action
(with-eval-after-load 'help-mode
(define-key help-mode-map (kbd "C-c h") 'extract-hex-code-current-line))
#!/bin/bash
FONT_COLOR=$(shuf -n 1 ~/.motd/colors)
FONT_STROKE=$(shuf -n 1 ~/.motd/colors)
GRAVITY=$(shuf -n 1 ~/.motd/gravity)
WEIGHT=$(shuf -i05-20 -n1)
SIZE=$(shuf -i20-100 -n1)
FONT=$(randomfont)
QUOTE=$(randommotd)
#!/bin/bash
OUTFILE=$(mktemp --suffix=.tex)
BASE_DATE=$(date --date=now +%Y-%m)
RED_LETTER_DAY=$(date --date=now +%F)
ORIGWAL=$(cat ~/.cache/wal/wal)
CAL_COLOR=$(xrdb -query | grep *.color66 | awk -F# '{print $2}')
@lesliesrussell
lesliesrussell / wallpaper.sh
Last active April 4, 2019 14:07 — forked from sewera/wallpaper.sh
A simple bash script using feh and date to enjoy a different background every day!
#!/bin/bash
NIGHT_PAPERS=~/Pictures/wallpaper/blue/*
DAY_PAPERS=~/Pictures/wallpaper/amber/*
if [ $(( $(date --date=now +10#%H) )) -gt 6 ] && [ $(( $(date --date=now +10#%H) )) -lt 19 ]
then
WALLPAPER_DIR=$DAY_PAPERS
else
WALLPAPER_DIR=$NIGHT_PAPERS
@lesliesrussell
lesliesrussell / 1_intro.txt
Created March 26, 2019 01:21 — forked from jgillman/1_intro.txt
i3 config from /u/twodogsdave
If this is hard to read in your browser, just copy the text and paste it into your editor.
Turn 'line wrapping' on. :)
This is a 'how to' for anyone interested in a i3 setup and also for anyone currently
using i3 and wants to tweak there setup a little more. I am constantly updating my
i3 config with cool 'stuff.' I hope you enjoy reading and if you use some of the code,
great! I don't know everything and am still learning, too. :)
This is my system settings for i3. Specifically, I use [Manjaro i3](https://forum.manjaro.org/index.php?topic=28022.0).