Skip to content

Instantly share code, notes, and snippets.

@knollet
knollet / void_TMOUT.sh
Created August 13, 2024 10:09
bash TMOUT
## source this
## the DEBUG-trap seems to be executed AFTER the setting of the alarm, so this seems to help
function my_clear_alarm() {
trap true SIGALRM
}
trap my_clear_alarm DEBUG
@knollet
knollet / emacs-xterm-paste.el
Created August 1, 2024 15:45
emasc 27.2 -- bug with putty/xterm-paste and emacs/term
;; in 27.2 ansi-term and some modification of xterm-paste don't work together so good
;; (results in a hang which you can only get out of by ^G
;; this solves it
(require 'term) ;; so this gets not overwritten the wrong way round
(defun term--xterm-paste (ev)
"Insert the text pasted in an XTerm bracketed paste operation."
(interactive "e")
(term-send-raw-string (cadr ev)))
@knollet
knollet / trash.sh
Last active July 31, 2024 11:28
Trash on the shell. Small bashrc implementation
function trash {
TRASHDIR="$HOME/TRASH"
DATE="$(date '+%Y-%m-%d_%H:%M:%S.%N')"
if [ -z "$1" ]; then
echo "usage: $0 <filenames...>" > /dev/stderr
exit 1
fi
for FILE in "$@"; do
@knollet
knollet / insert-pair.el
Created November 16, 2023 17:04
surround.el
;;;;; insert pair -- "Surround"
(global-set-key (kbd "<f12> s \"") 'insert-pair)
(global-set-key (kbd "<f12> s '") 'insert-pair)
(global-set-key (kbd "<f12> s (") 'insert-pair)
(global-set-key (kbd "<f12> s [") 'insert-pair)
(global-set-key (kbd "<f12> s {") 'insert-pair)
(global-set-key (kbd "<f12> s <") 'insert-pair)
@knollet
knollet / tmacs-emacs.el
Last active November 17, 2023 10:39
start an ansi-term with a reasonable name
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; tmacs
(defvar tmacs--counter 0)
(defun tmacs--find-free-number ()
(cl-do ((num 0 (+ 1 num)))
((not (get-buffer (format "*tmacs<%s>*" num)))
num)))
(defun tmacs ()
(interactive)
(defun mo-paging--what-page ()
"Print page and line number of point."
(interactive)
(save-restriction
(widen)
(save-excursion
(let ((count 1)
(opoint (point)))
(goto-char (point-min))
(while (re-search-forward page-delimiter opoint t)
(defun buffer-minus (subtrahend)
"This function takes the name of a buffer,
and removes every line in the current buffer present in the given one.
The lines are removed with `delete-matching-lines' which uses the given string as a regex
but it is good enough..."
(interactive "*b")
(let ((sub-list
(with-current-buffer subtrahend
(string-split (buffer-string) "\n" t "[\t ]+"))))

Emacs with 24 bits color in terminal

Troubleshooting

Recompile terminfo

Once the colors just stopped working, recompiling terminfo (see tic) worked for me. Perhaps there was an system wide update of terminfo and the format was changed somehow, so the old compiled files

@knollet
knollet / my-trash-cli.sh
Last active September 1, 2023 10:11
source my-trash-cli.sh
function trash {
TRASHDIR="$HOME/TRASH"
DATE="$(date '+%Y-%m-%d_%H:%M:%S.%N')"
if [ -z "$1" ]; then
echo "usage: $0 <filenames...>" > /dev/stderr
exit 1
fi
for FILE in "$@"; do
@knollet
knollet / .emacs
Last active May 15, 2023 08:31
Snippet to have paste in (ansi-)term-mode with C-c C-y
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ansi-term
(add-hook 'term-exec-hook
(lambda ()
(define-key term-raw-map (kbd "C-c C-y") 'term-paste)
(define-key term-raw-map (kbd "C-c y") 'term-paste)))