Skip to content

Instantly share code, notes, and snippets.

@salopst
Last active November 11, 2023 11:53
Show Gist options
  • Save salopst/7fb540617d6e1912377f7b95ad2f401a to your computer and use it in GitHub Desktop.
Save salopst/7fb540617d6e1912377f7b95ad2f401a to your computer and use it in GitHub Desktop.
Poor-man's online text editor

Poor-man's online text editor

Leaving notes for yourself like a pleb.

Dark background for vterm

(defun my-buffer-face-mode () ;; https://emacs.stackexchange.com/questions/3038/using-a-different-font-for-each-major-mode "Change vterm background colour" (interactive) (setq buffer-face-mode-face '(:background "#574F4A")) (buffer-face-mode) (add-hook 'vterm-mode-hook 'my-buffer-face-mode))

Kill annoying "error" beer in Nautilus/GNOME generally

dconf write /org/gnome/desktop/sound/event-sounds "false" or
gsettings set org.gnome.desktop.sound event-sounds false
And disable the shitty PC speaker, the nuclear option:
rmmod pcspkr ; echo "blacklist pcspkr" >>/etc/modprobe.d/blacklist.conf

Let's get some purdy flags next to input sources

(no, flegs do not map to languages, but whatever)

/usr/share/X11/xkb/rules/evdev.xml
add fleg icons after lang abbrev:
<shortDescription>gr 🇬🇷</shortDescription>

GNOME "Emacs keys" (which are basically fucking useless) are defined at:

/usr/share/themes/Emacs/gtk-3.0/gtk-keys.css

Where are .desktop files?

~/.local/share/applications
~/.config/autostart
~/.local/share/flatpak/app/WHATEVER/...

(vs) code cannot be found

'f course'nt it cannae, you silly goose, you installed it as a flatpak.

echo -e "\nalias code='flatpak run com.visualstudio.code'\n" >> ~/.config/shell/appimage-aliases.sh

How reflect these in Markdown?

Texinfo provides numerous subtle distinctions that show up clearly in each of these output formats. Compare, for example, @var, @dfn and @emph; compare @code, @samp, @file, @command, @option, @kbd, and @key.

Haskell

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
ghcup install hls

Some Elisp

;;;; START Tested in emacs-q, now move to emacs
(keymap-global-set "<escape>" #'keyboard-quit)   ;; C-g by default
(keymap-global-set "C-/" #'comment-line)         ;; C-/ like C-x C-; (is `undo` by default)
(keymap-global-set "C-d" #'delete-forward-char)  ;; better than default delete-char
(keymap-global-set "C-h" #'delete-backward-char) ;; can use <f1> for help anyway.

;; let's have some spacing "borders"
(setq-default left-margin-width 3 right-margin-width 3)
;; Use them now.
(set-window-buffer nil (current-buffer))

(use-package vertico-multiform
  :ensure nil
  :hook (after-init . vertico-multiform-mode)
  :init
  (setq vertico-multiform-commands
        '((consult-line (:not posframe))
          (gopar/consult-line (:not posframe))
          (consult-ag (:not posframe))
          (t posframe))))

;; just for looks
;; https://github.com/tumashu/vertico-posframe
(use-package vertico-posframe
  :ensure t
  :custom
  (vertico-posframe-parameters
   '((left-fringe . 8)
     (right-fringe . 8))))

(require 'vertico-posframe)
(vertico-posframe-mode 1)

;; like zap-to-char but with avy power, and works backwards of point
;; {https://github.com/mrkkrp/zzz-to-char}
(use-package zzz-to-char
  :ensure t)
(keymap-global-set "M-z" #'zzz-up-to-char)

(use-package avy
  :ensure t)
(keymap-global-set "C-j" #'avy-goto-char-timer)

;; tabular data{
(use-package csv
  :ensure t)

;;;; END Tested in emacs-q, now move to emacs

;; insert an org-more link with the URL and title of the page currently open in Firefox:
;; https://www.reddit.com/r/emacs/comments/16rbsnw/whats_something_in_your_emacs_config_that_makes_a/k23gklb/
(defun ff-link-org () 
  (interactive)
  (insert (shell-command-to-string "lz4jsoncat $FIREFOX_DIR/sessionstore-backups/recovery.jsonlz4 | jq -r '.windows[0].tabs | sort_by(.lastAccessed)[-1] | .entries[.index-1] | \"[[\" + (.url) + \"][\" + (.title) + \"]]\"' | tr -d '\n'"))) 
(global-set-key (kbd "C-c f") 'ff-link-org)

Git

Create a new repository on the command line

touch README.md
git init
git branch -m master main
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/salopst/some-project.git
git push -u origin main

Push an existing repository from the command line

git remote add origin https://github.com/salopst/some-project.git
git push -u origin main

Clone a subdir of a git repository

git_sparse_clone "https://github.com/neovim/neovim.git" "/"" "~/.config/nvim/doc"

 function git_sparse_clone() (
   rurl="$1" localdir="$2" && shift 2
   mkdir -p "$localdir"
   cd "$localdir"
   git init
   git remote add -f origin "$rurl"
   git config core.sparseCheckout true
   # Loops over remaining args
   for i; do
     echo "$i" >> .git/info/sparse-checkout
   done
   git pull origin master
 )
 git clone \
   --depth 1  \
   --filter=blob:none  \
   --sparse \
   https://github.com/neovim/neovim.git \
 ;
 cd ~/.config/nvim/doc
 git sparse-checkout set runtime/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment