1 #+TITLE: System Configuration
2 #+DESCRIPTION: Personal system configuration in org-mode format.
3 #+AUTHOR: Armaan Bhojwani
4 #+EMAIL: me@armaanb.net
7 Welcome to my system configuration! This file contains my Emacs configuration, but also my config files for many of the other programs on my system!
9 I am currently using Emacs 28 with native compilation, so some settings and packages may not be available for older versions of Emacs. This is a purely personal configuration, so while I can guarantee that it works on my setup, it might not work for you.
11 I chose to create a powerful, yet not overly heavy Emacs configuration. Things like a fancy modeline, icons, or LSP mode do not increase my productivity, and create visual clutter, and thus have been excluded.
13 Another important choice has been to integrate Emacs into a large part of my computing environment (see [[*Emacs OS]]). I use email, IRC, RSS, et cetera, all through Emacs which simplifies my workflow and creates an amazingly integrated environment.
15 Lastly, I use Evil mode. Modal keybindings are simpler and more ergonomic than standard Emacs style, and Vim keybindings are what I'm comfortable with and are pervasive throughout computing.
17 Released under the [[https://opensource.org/licenses/MIT][MIT license]] by Armaan Bhojwani, 2021. Note that many snippets are taken from online, and other sources, who are credited for their work near their contributions.
19 ** Bootstrap straight.el
20 straight.el is really nice for managing package, and it integrates nicely with use-package. It uses the bootstrapping system defined here for installation.
21 #+begin_src emacs-lisp
22 (defvar native-comp-deferred-compilation-deny-list ())
23 (defvar bootstrap-version)
25 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
26 (bootstrap-version 5))
27 (unless (file-exists-p bootstrap-file)
29 (url-retrieve-synchronously
30 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
31 'silent 'inhibit-cookies)
32 (goto-char (point-max))
33 (eval-print-last-sexp)))
34 (load bootstrap-file nil 'nomessage))
36 ** Replace package.el with straight
37 #+begin_src emacs-lisp
38 (straight-use-package 'use-package)
39 (setq straight-use-package-by-default t)
43 Use the Modus Operandi theme by Protesilaos Stavrou. Its the best theme for Emacs by far, because how clear and readable it is. It is highly customizable, but I just set a few options here.
44 #+begin_src emacs-lisp
45 (setq modus-themes-slanted-constructs t
46 modus-themes-bold-constructs t
47 modus-themes-mode-line '3d
48 modus-themes-scale-headings t
49 modus-themes-diffs 'desaturated)
50 (load-theme 'modus-vivendi t)
54 JetBrains Mono is a great programming font with ligatures. The "NF" means that it has been patched with the [[https://www.nerdfonts.com/][Nerd Fonts]].
55 #+begin_src emacs-lisp
56 (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
59 #+begin_src emacs-lisp
61 :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
63 (ligature-set-ligatures
64 '(prog-mode text-mode)
65 '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "/=" "/=="
66 "/>" "//" "/*" "*>" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
67 "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>"
68 "<-|" "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>"
69 "</" "<*" "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>"
70 ":=" "::=" "=>>" "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!=="
71 "!!" "!=" ">]" ">:" ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&"
72 "&&" "|||>" "||>" "|>" "|]" "|}" "|=>" "|->" "|=" "||-" "|-"
73 "||=" "||" ".." ".?" ".=" ".-" "..<" "..." "+++" "+>" "++"
74 "[||]" "[<" "[|" "{|" "?." "?=" "?:" "##" "###" "####" "#["
75 "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_" "__" "~~"
76 "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
77 (global-ligature-mode t))
80 Display relative line numbers except in certain modes.
81 #+begin_src emacs-lisp
82 (global-display-line-numbers-mode)
83 (setq display-line-numbers-type 'relative)
84 (dolist (no-line-num '(term-mode-hook
90 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
92 ** Highlight matching parenthesis
93 #+begin_src emacs-lisp
95 :config (show-paren-mode)
96 :custom (show-paren-style 'parenthesis))
99 *** Show current function
100 #+begin_src emacs-lisp
101 (which-function-mode)
103 *** Make position in file more descriptive
104 Show current column and file size.
105 #+begin_src emacs-lisp
107 (size-indication-mode)
110 #+begin_src emacs-lisp
112 :config (minions-mode))
115 Show a ruler at a certain number of chars depending on mode.
116 #+begin_src emacs-lisp
117 (setq display-fill-column-indicator-column 80)
118 (global-display-fill-column-indicator-mode)
120 ** Highlight todo items in comments
121 #+begin_src emacs-lisp
123 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
124 :config (global-hl-todo-mode 1))
127 #+begin_src emacs-lisp
131 Soft wrap words and do operations by visual lines in some modes.
132 #+begin_src emacs-lisp
133 (dolist (hook '(text-mode-hook
136 mu4e-view-mode-hook))
137 (add-hook hook (lambda () (visual-line-mode 1))))
139 ** Display number of matches in search
140 #+begin_src emacs-lisp
142 :config (global-anzu-mode)
144 ([remap query-replace] . anzu-query-replace)
145 ([remap query-replace-regexp] . anzu-query-replace-regexp))
147 *** TODO This config doesn't work right
149 Invert modeline color instead of audible bell or the standard visual bell.
150 #+begin_src emacs-lisp
151 (setq visible-bell nil
153 (lambda () (invert-face 'mode-line)
154 (run-with-timer 0.1 nil #'invert-face 'mode-line)))
158 #+begin_src emacs-lisp
160 :custom (select-enable-clipboard nil)
163 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
164 ;; Use visual line motions even outside of visual-line-mode buffers
165 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
166 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
167 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
170 Evil bindings for tons of packages.
171 #+begin_src emacs-lisp
172 (use-package evil-collection
174 :init (evil-collection-init)
175 :custom (evil-collection-setup-minibuffer t))
179 #+begin_src emacs-lisp
180 (use-package evil-surround
181 :config (global-evil-surround-mode))
184 Makes commenting super easy
185 #+begin_src emacs-lisp
186 (use-package evil-nerd-commenter
187 :bind (:map evil-normal-state-map
188 ("gc" . evilnc-comment-or-uncomment-lines))
189 :custom (evilnc-invert-comment-line-by-line nil))
193 #+begin_src emacs-lisp
194 (evil-set-undo-system 'undo-redo)
196 ** Number incrementing
197 Add back C-a/C-x bindings.
198 #+begin_src emacs-lisp
199 (use-package evil-numbers
200 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
201 :bind (:map evil-normal-state-map
202 ("C-M-a" . evil-numbers/inc-at-pt)
203 ("C-M-x" . evil-numbers/dec-at-pt)))
206 #+begin_src emacs-lisp
207 (use-package evil-org
209 :hook (org-mode . evil-org-mode)
211 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
213 (use-package evil-org-agenda
214 :straight (:type built-in)
216 :config (evil-org-agenda-set-keys))
220 #+begin_src emacs-lisp
222 :straight (:type built-in)
223 :commands (org-capture org-agenda)
226 (org-agenda-start-with-log-mode t)
227 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
229 (org-log-into-drawer t)
230 (org-src-tab-acts-natively t)
231 (org-src-fontify-natively t)
232 (org-startup-indented t)
233 (org-hide-emphasis-markers t)
234 (org-fontify-whole-block-delimiter-line nil)
235 (org-archive-default-command 'org-archive-to-archive-sibling)
237 ("C-c a" . org-agenda)
238 (:map evil-normal-state-map ("ga" . org-archive-subtree-default)))
241 Define templates for lots of common structure elements. Mostly just used within this file.
242 #+begin_src emacs-lisp
243 (use-package org-tempo
245 :straight (:type built-in)
247 (dolist (addition '(("el" . "src emacs-lisp")
248 ("el" . "src emacs-lisp")
249 ("sp" . "src conf :tangle ~/.spectrwm.conf")
250 ("ash" . "src shell :tangle ~/.config/ash/ashrc")
251 ("pi" . "src conf :tangle ~/.config/picom/picom.conf")
252 ("git" . "src conf :tangle ~/.gitconfig")
253 ("du" . "src conf :tangle ~/.config/dunst/dunstrc")
254 ("za" . "src conf :tangle ~/.config/zathura/zathurarc")
255 ("ff1" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css")
256 ("ff2" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css")
257 ("xr" . "src conf :tangle ~/.Xresources")
258 ("tm" . "src conf :tangle ~/.tmux.conf")
259 ("gp" . "src conf :tangle ~/.gnupg/gpg.conf")
260 ("ag" . "src conf :tangle ~/.gnupg/gpg-agent.conf")))
261 (add-to-list 'org-structure-template-alist addition)))
265 A well balanced completion framework.
266 #+begin_src emacs-lisp
268 :bind (:map ivy-minibuffer-map
269 ("TAB" . ivy-alt-done))
270 (:map ivy-switch-buffer-map
271 ("M-d" . ivy-switch-buffer-kill))
275 #+begin_src emacs-lisp
276 (use-package ivy-rich
278 :config (ivy-rich-mode))
282 #+begin_src emacs-lisp
284 :bind ("C-M-j" . 'counsel-switch-buffer)
285 :config (counsel-mode))
287 ** Remember frequent commands
288 #+begin_src emacs-lisp
289 (use-package ivy-prescient
292 (prescient-persist-mode)
293 (ivy-prescient-mode))
297 Use elfeed for reading RSS. I have another file with all the feeds in it that I'd rather keep private.
298 #+begin_src emacs-lisp
300 :bind (("C-c e" . elfeed))
301 :config (load "~/.emacs.d/feeds.el")
302 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
305 Use mu4e for reading emails.
306 Contexts are a not very well known feature of mu4e that makes it super easy to manage multiple accounts. Much better than some of the hacky methods and external packages that I've seen.
307 *** TODO Switch to mbsync
308 =offlineimap= really crappy (slow and requires python2), and I need to replace it with =mbsync=.
309 *** TODO Include mbsync/offlineimap config
310 *** TODO Split up and document this config a bit
312 #+begin_src emacs-lisp
313 (use-package smtpmail
314 :straight (:type built-in))
316 :load-path "/usr/share/emacs/site-lisp/mu4e"
317 :straight (:build nil)
318 :bind (("C-c m" . mu4e))
320 (setq user-full-name "Armaan Bhojwani"
321 smtpmail-local-domain "armaanb.net"
322 smtpmail-stream-type 'ssl
323 smtpmail-smtp-service '465
324 mu4e-change-filenames-when-moving t
325 mu4e-get-mail-command "offlineimap -q"
326 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
327 message-citation-line-function 'message-insert-formatted-citation-line
328 mu4e-completing-read-function 'ivy-completing-read
329 mu4e-confirm-quit nil
331 mail-user-agent 'mu4e-user-agent
332 mail-context-policy 'pick-first
334 `( ,(make-mu4e-context
336 :enter-func (lambda () (mu4e-message "Entering school context"))
337 :leave-func (lambda () (mu4e-message "Leaving school context"))
338 :match-func (lambda (msg)
340 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
341 :vars '((user-mail-address . "abhojwani22@nobles.edu")
342 (mu4e-sent-folder . "/school/Sent")
343 (mu4e-drafts-folder . "/school/Drafts")
344 (mu4e-trash-folder . "/school/Trash")
345 (mu4e-refile-folder . "/school/Archive")
346 (message-cite-reply-position . above)
347 (user-mail-address . "abhojwani22@nobles.edu")
348 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
349 (smtpmail-smtp-server . "smtp.gmail.com")))
352 :enter-func (lambda () (mu4e-message "Entering personal context"))
353 :leave-func (lambda () (mu4e-message "Leaving personal context"))
354 :match-func (lambda (msg)
356 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
357 :vars '((mu4e-sent-folder . "/personal/Sent")
358 (mu4e-drafts-folder . "/personal/Drafts")
359 (mu4e-trash-folder . "/personal/Trash")
360 (mu4e-refile-folder . "/personal/Archive")
361 (user-mail-address . "me@armaanb.net")
362 (message-cite-reply-position . below)
363 (smtpmail-smtp-user . "me@armaanb.net")
364 (smtpmail-smtp-server . "smtp.mailbox.org")))))
365 (add-to-list 'mu4e-bookmarks
366 '(:name "Unified inbox"
367 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
369 :hook ((mu4e-compose-mode . flyspell-mode)
370 (mu4e-compose-mode . auto-fill-mode)
371 (message-send-hook . (lambda () (unless (yes-or-no-p "Ya sure 'bout that?")
372 (signal 'quit nil))))))
374 *** Discourage Gnus from displaying HTML emails
375 #+begin_src emacs-lisp
376 (with-eval-after-load "mm-decode"
377 (add-to-list 'mm-discouraged-alternatives "text/html")
378 (add-to-list 'mm-discouraged-alternatives "text/richtext"))
381 Set EWW as default browser except for multimedia which should open in MPV.
382 #+begin_src emacs-lisp
383 (defun browse-url-mpv (url &optional new-window)
386 (start-process "mpv" "*mpv*" "mpv" url))
388 (setq browse-url-handlers
390 (("youtu\\.?be" . browse-url-mpv)
391 ("peertube.*" . browse-url-mpv)
392 ("vid.*" . browse-url-mpv)
393 ("vid.*" . browse-url-mpv)
394 ("*.mp4" . browse-url-mpv)
395 ("*.mp3" . browse-url-mpv)
396 ("*.ogg" . browse-url-mpv)
397 ("." . eww-browse-url)
401 Some EWW enhancements.
402 *** Give buffer a useful name
403 #+begin_src emacs-lisp
404 ;; From https://protesilaos.com/dotemacs/
405 (defun prot-eww--rename-buffer ()
406 "Rename EWW buffer using page title or URL.
407 To be used by `eww-after-render-hook'."
408 (let ((name (if (eq "" (plist-get eww-data :title))
409 (plist-get eww-data :url)
410 (plist-get eww-data :title))))
411 (rename-buffer (format "*%s # eww*" name) t)))
414 :straight (:type built-in)
415 :bind (("C-c w" . eww))
416 :hook (eww-after-render-hook prot-eww--rename-buffer))
419 #+begin_src emacs-lisp
420 (global-set-key (kbd "C-c w") 'eww)
423 Circe is a really nice IRC client that claims to be above RCIRC and below ERC in terms of features. ERC felt a bit messy and finicky to me, and Circe has all the features that I need. This setup gets the password for my bouncer (Pounce) instances via my =~/.authinfo.gpg= file.
424 #+begin_src emacs-lisp
425 (defun fetch-password (&rest params)
426 (require 'auth-source)
427 (let ((match (car (apply 'auth-source-search params))))
429 (let ((secret (plist-get match :secret)))
430 (if (functionp secret)
433 (error "Password not found for %S" params))))
438 (enable-circe-color-nicks)
439 (setq circe-network-defaults '(("libera"
440 :host "irc.armaanb.net"
445 :pass (lambda (null) (fetch-password
447 :machine "irc.armaanb.net"
450 :host "irc.armaanb.net"
455 :pass (lambda (null) (fetch-password
457 :machine "irc.armaanb.net"
460 :host "irc.armaanb.net"
465 :pass (lambda (null) (fetch-password
467 :machine "irc.armaanb.net"
469 :custom (circe-default-part-message "goodbye!")
470 :bind (:map circe-mode-map ("C-c C-r" . circe-reconnect-all)))
475 (if (get-buffer "irc.armaanb.net:6696")
476 (switch-to-buffer "irc.armaanb.net:6696")
477 (progn (circe "libera")
481 (global-set-key (kbd "C-c i") 'acheam-irc)
484 Still experimenting with this setup. Not sure if I will keep it, but it works well for seeing my calendar events. I use =vdirsyncer= to sync my calendar events which I'm really not happy with.
485 #+begin_src emacs-lisp
486 (defun sync-calendar ()
487 "Sync calendars with vdirsyncer"
489 (async-shell-command "vdirsyncer sync"))
492 :bind (:map cfw:calendar-mode-map ("C-S-u" . sync-calendar)))
493 (use-package calfw-ical)
494 (use-package calfw-org)
496 (defun acheam-calendar ()
499 (cfw:open-calendar-buffer
500 :contents-sources (list
501 (cfw:org-create-source "Green")
502 (cfw:ical-create-source
504 "~/.local/share/vdirsyncer/mailbox/Y2FsOi8vMC8zMQ.ics"
506 (cfw:ical-create-source
508 "~/.local/share/vdirsyncer/mailbox/Y2FsOi8vMC8zMQ.ics"
510 (cfw:ical-create-source
512 "~/.local/share/vdirsyncer/school/abhojwani22@nobles.edu.ics"
516 (global-set-key (kbd "C-c c") 'acheam-calendar)
519 #+begin_src emacs-lisp
520 (use-package pdf-tools
521 :hook (pdf-view-mode . pdf-view-midnight-minor-mode))
525 #+begin_src emacs-lisp
527 :hook (python-mode . blacken-mode)
528 :custom (blacken-line-length 79))
531 ** Strip trailing whitespace
532 #+begin_src emacs-lisp
533 (use-package ws-butler
534 :config (ws-butler-global-mode))
537 Automatic linting. I need to look into configuring this more.
538 #+begin_src emacs-lisp
539 (use-package flycheck
540 :config (global-flycheck-mode))
542 ** Project management
543 I never use this, but apparently its very powerful. Another item on my todo list.
544 #+begin_src emacs-lisp
545 (use-package projectile
546 :config (projectile-mode)
547 :custom ((projectile-completion-system 'ivy))
549 ("C-c p" . projectile-command-map)
551 (when (file-directory-p "~/Code")
552 (setq projectile-project-search-path '("~/Code")))
553 (setq projectile-switch-project-action #'projectile-dired))
555 (use-package counsel-projectile
557 :config (counsel-projectile-mode))
560 The best file manager!
561 #+begin_src emacs-lisp
563 :straight (:type built-in)
564 :commands (dired dired-jump)
565 :custom ((dired-listing-switches "-agho --group-directories-first"))
566 :config (evil-collection-define-key 'normal 'dired-mode-map
567 "h" 'dired-single-up-directory
568 "l" 'dired-single-buffer))
570 (use-package dired-single
571 :commands (dired dired-jump))
573 (use-package dired-open
574 :commands (dired dired-jump)
575 :custom (dired-open-extensions '(("png" . "feh")
578 (use-package dired-hide-dotfiles
579 :hook (dired-mode . dired-hide-dotfiles-mode)
581 (evil-collection-define-key 'normal 'dired-mode-map
582 "H" 'dired-hide-dotfiles-mode))
586 A very good Git interface.
587 #+begin_src emacs-lisp
591 #+begin_src emacs-lisp
593 (use-package git-email
594 :straight (git-email :repo "https://git.sr.ht/~yoctocell/git-email")
595 :config (git-email-piem-mode))
597 * General text editing
599 Automatically indent after every change. I'm not sure how much I like this. It slows down the editor and code sometimes ends up in a half-indented state meaning I have to manually reformat using "==" anyways.
600 #+begin_src emacs-lisp
601 (use-package aggressive-indent
602 :config (global-aggressive-indent-mode))
605 Spell check in text mode, and in prog-mode comments.
606 #+begin_src emacs-lisp
607 (dolist (hook '(text-mode-hook))
608 (add-hook hook (lambda () (flyspell-mode))))
609 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
610 (add-hook hook (lambda () (flyspell-mode -1))))
611 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
612 (setq ispell-silently-savep t)
615 #+begin_src emacs-lisp
616 (setq-default tab-width 2)
619 Opens file where you left it.
620 #+begin_src emacs-lisp
624 Distraction free writing a la junegunn/goyo.
625 #+begin_src emacs-lisp
626 (use-package olivetti
627 :bind ("C-c o" . olivetti-mode))
630 Abbreviate things! I just use this for things like my email address and copyright notice.
631 #+begin_src emacs-lisp
632 (setq abbrev-file-name "~/.emacs.d/abbrevs.el")
633 (setq save-abbrevs 'silent)
634 (setq-default abbrev-mode t)
637 #+begin_src emacs-lisp
638 (setq tramp-default-method "ssh")
640 ** Follow version controlled symlinks
641 #+begin_src emacs-lisp
642 (setq vc-follow-symlinks t)
645 #+begin_src emacs-lisp
646 (defun doas-edit (&optional arg)
647 "Edit currently visited file as root.
649 With a prefix ARG prompt for a file to visit.
650 Will also prompt for a file to visit if current
651 buffer is not visiting a file.
653 Modified from Emacs Redux."
655 (if (or arg (not buffer-file-name))
656 (find-file (concat "/doas:root@localhost:"
657 (ido-read-file-name "Find file(as root): ")))
658 (find-alternate-file (concat "/doas:root@localhost:" buffer-file-name))))
660 (global-set-key (kbd "C-x C-r") #'doas-edit)
663 #+begin_src emacs-lisp
664 (use-package markdown-mode)
668 #+begin_src emacs-lisp
669 (use-package ace-window
670 :bind ("M-o" . ace-window))
672 ** Kill current buffer
673 Makes "C-x k" binding faster.
674 #+begin_src emacs-lisp
675 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
679 #+begin_src emacs-lisp
680 (use-package scad-mode)
682 ** Control backup and lock files
683 Stop backup files from spewing everywhere.
684 #+begin_src emacs-lisp
685 (setq backup-directory-alist `(("." . "~/.emacs.d/backups"))
686 create-lockfiles nil)
688 ** Make yes/no easier
689 #+begin_src emacs-lisp
690 (defalias 'yes-or-no-p 'y-or-n-p)
692 ** Move customize file
693 No more clogging up init.el.
694 #+begin_src emacs-lisp
695 (setq custom-file "~/.emacs.d/custom.el")
699 #+begin_src emacs-lisp
701 :commands (helpful-callable helpful-variable helpful-command helpful-key)
703 (counsel-describe-function-function #'helpful-callable)
704 (counsel-describe-variable-function #'helpful-variable)
706 ([remap describe-function] . counsel-describe-function)
707 ([remap describe-command] . helpful-command)
708 ([remap describe-variable] . counsel-describe-variable)
709 ([remap describe-key] . helpful-key))
712 #+begin_src emacs-lisp
713 (use-package epa-file
714 :straight (:type built-in)
716 (epa-file-select-keys nil)
717 (epa-file-encrypt-to '("me@armaanb.net"))
718 (password-cache-expiry (* 60 15)))
720 (use-package pinentry
721 :config (pinentry-start))
724 #+begin_src emacs-lisp
726 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
727 :custom (0x0-default-service 'envs))
729 *** TODO Replace this with uploading to my own server
730 Similar to the ufile alias in my ashrc
731 ** Automatically clean buffers
732 Automatically close unused buffers (except those of Circe) at midnight.
733 #+begin_src emacs-lisp
735 (add-to-list 'clean-buffer-list-kill-never-regexps (lambda (buffer-name)
736 (with-current-buffer buffer-name
737 (derived-mode-p 'lui-mode))))
741 Spectrwm is a really awesome window manager! Would highly recommend.
743 #+begin_src conf :tangle ~/.spectrwm.conf
747 autorun = ws[1]:/home/armaa/Code/scripts/autostart
750 Disable the bar by default (it can still be brought back up with MOD+b). The font just needs to be set to something that you have installed, otherwise spectrwm won't launch.
751 #+begin_src conf :tangle ~/.spectrwm.conf
753 bar_font = xos4 JetBrains Mono:pixelsize=14:antialias=true # any installed font
756 I'm not a huge fan of how spectrwm handles keybindings, probably my biggest gripe with it.
758 #+begin_src conf :tangle ~/.spectrwm.conf
759 program[term] = st -e tmux
760 program[screenshot_all] = flameshot gui
761 program[notif] = /home/armaa/Code/scripts/setter status
762 program[pass] = /home/armaa/Code/scripts/passmenu
765 bind[pass] = MOD+Shift+p
768 #+begin_src conf :tangle ~/.spectrwm.conf
769 program[paup] = /home/armaa/Code/scripts/setter audio +5
770 program[padown] = /home/armaa/Code/scripts/setter audio -5
771 program[pamute] = /home/armaa/Code/scripts/setter audio
772 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
773 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
774 program[next] = playerctl next
775 program[prev] = playerctl previous
776 program[pause] = playerctl play-pause
778 bind[padown] = XF86AudioLowerVolume
779 bind[paup] = XF86AudioRaiseVolume
780 bind[pamute] = XF86AudioMute
781 bind[brigdown] = XF86MonBrightnessDown
782 bind[brigup] = XF86MonBrightnessUp
783 bind[pause] = XF86AudioPlay
784 bind[next] = XF86AudioNext
785 bind[prev] = XF86AudioPrev
788 #+begin_src conf :tangle ~/.spectrwm.conf
789 program[h] = xdotool keyup h key --clearmodifiers Left
790 program[j] = xdotool keyup j key --clearmodifiers Down
791 program[k] = xdotool keyup k key --clearmodifiers Up
792 program[l] = xdotool keyup l key --clearmodifiers Right
794 bind[h] = MOD + Control + h
795 bind[j] = MOD + Control + j
796 bind[k] = MOD + Control + k
797 bind[l] = MOD + Control + l
800 #+begin_src conf :tangle ~/.spectrwm.conf
801 program[email] = emacsclient -ce "(mu4e)"
802 program[irc] = emacsclient -ce '(acheam-irc)'
803 program[rss] = emacsclient -ce '(elfeed)'
804 program[calendar] = emacsclient -ce '(acheam-calendar)'
805 program[calc] = emacsclient -ce '(progn (calc) (windmove-up) (delete-window))'
806 program[firefox] = firefox
807 program[emacs] = emacsclient -c
809 bind[email] = MOD+Control+1
810 bind[irc] = MOD+Control+2
811 bind[rss] = MOD+Control+3
812 bind[calendar] = MOD+Control+4
813 bind[calc] = MOD+Control+5
814 bind[firefox] = MOD+Control+0
815 bind[emacs] = MOD+Control+Return
818 Float some specific programs by default.
819 #+begin_src conf :tangle ~/.spectrwm.conf
820 quirk[Castle Menu] = FLOAT
825 Use the vi editing mode. I still haven't found a good way to show visual feedback of the current mode. Ideally the cursor would change to a beam when in insert mode, and a box when in normal mode.
826 #+begin_src conf :tangle ~/.config/ash/ashrc
831 #+begin_src shell :tangle ~/.config/ash/ashrc
833 user=$(echo "$1" | cut -f 1 -d '@')
834 host=$(echo "$1" | cut -f 2 -d '@')
835 echo $user | nc "$host" 79
838 **** Upload to ftp.armaanb.net
839 #+begin_src shell :tangle ~/.config/ash/ashrc
841 echo "https://l.armaanb.net/$(basename "$1")" | tee /dev/tty | xclip -sel c
845 rsync "$1" "root@armaanb.net:/var/ftp/pub/$2" --chmod 644
855 xclip -o -sel c >> "$tmp"
856 basetmp=$(echo "$tmp" | tail -c +5)
857 _uup "$tmp" "$basetmp"
863 #+begin_src shell :tangle ~/.config/ash/ashrc
864 export EDITOR="emacsclient -c"
865 export VISUAL="$EDITOR"
866 export TERM=xterm-256color # for compatability
868 export GPG_TTY="$(tty)"
869 export MANPAGER='nvim +Man!'
872 export GTK_USE_PORTAL=1
874 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
875 export PATH="/home/armaa/Code/scripts:$PATH" # prioritize my scripts
876 export PATH="/home/armaa/Code/scripts/bin:$PATH" # prioritize my bins
877 export PATH="$PATH:/home/armaa/.cargo/bin"
878 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
879 export PATH="$PATH:/usr/sbin"
880 export PATH="$PATH:/opt/FreeTube/freetube"
882 export LC_ALL="en_US.UTF-8"
883 export LC_CTYPE="en_US.UTF-8"
884 export LANGUAGE="en_US.UTF-8"
886 export KISS_PATH="/home/armaa/Virtual/kiss/home/armaa/kiss-repo"
887 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
888 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
889 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
890 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
891 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
892 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
896 #+begin_src shell :tangle ~/.config/ash/ashrc
897 alias bhoji-drop='ssh -p 23 root@armaanb.net'
898 alias irc='ssh root@armaanb.net -t abduco -A irc catgirl freenode'
899 alias union='ssh 192.168.1.18'
900 alias mine='ssh -p 23 root@pickupserver.cc'
901 alias tcf='ssh root@204.48.23.68'
902 alias ngmun='ssh root@157.245.89.25'
903 alias prox='ssh root@192.168.1.224'
904 alias ncq='ssh root@143.198.123.17'
905 alias envs='ssh acheam@envs.net'
908 #+begin_src shell :tangle ~/.config/ash/ashrc
909 alias ls='ls -lh --group-directories-first'
911 alias df='df -h / /boot'
918 alias grep='grep -in'
919 alias mkdir='mkdir -pv'
920 alias lanex='java -jar ~/.local/share/lxc/lanxchange.jar'
921 emacs() { $EDITOR "$@" & }
924 **** System management
925 #+begin_src shell :tangle ~/.config/ash/ashrc
926 alias crontab='crontab-argh'
928 alias pasu='git -C ~/.password-store push'
929 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
933 #+begin_src shell :tangle ~/.config/ash/ashrc
934 alias ping='ping -c 10'
935 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
936 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
937 alias plan='T=$(mktemp) && \
938 rsync root@armaanb.net:/etc/finger/plan.txt "$T" && \
940 head -n -2 $T > $TT && \
943 echo "Last updated: $(date -R)" >> "$TT" && \
944 fold -sw 72 "$TT" > "$T"| \
945 rsync "$T" root@armaanb.net:/etc/finger/plan.txt && \
948 **** Virtual machines, chroots
949 #+begin_src shell :tangle ~/.config/ash/ashrc
950 alias ckiss="doas chrooter ~/Virtual/kiss"
951 alias cdebian="doas chrooter ~/Virtual/debian bash"
952 alias cwindows='devour qemu-system-x86_64 \
957 -device VGA,vgamem_mb=64 \
961 -net user,smb=/home/armaa/Public \
962 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
965 #+begin_src shell :tangle ~/.config/ash/ashrc
966 alias words='gen-shell -c "words"'
967 alias words-e='gen-shell -c "words ~E"'
970 #+begin_src shell :tangle ~/.config/ash/ashrc
971 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
973 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
975 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
976 --restrict-filenames -o '%(title)s.%(ext)s'"
980 Make MPV play a little bit smoother.
981 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
982 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
986 This file is used for any GNU Readline programs. I use Emacs editing mode mostly because of one annoyance which is that to clear the screen using ^L, you have to be in normal mode which is a pain. If there is a way to rebind this, I'd love to know!.
987 #+begin_src conf :tangle ~/.inputrc
988 set editing-mode emacs
992 #+begin_src conf :tangle ~/.gitconfig
994 name = Armaan Bhojwani
995 email = me@armaanb.net
996 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
999 #+begin_src conf :tangle ~/.gitconfig
1001 defaultBranch = main
1004 #+begin_src conf :tangle ~/.gitconfig
1009 #+begin_src conf :tangle ~/.gitconfig
1011 smtpserver = smtp.mailbox.org
1012 smtpuser = me@armaanb.net
1013 smtpencryption = ssl
1014 smtpserverport = 465
1018 #+begin_src conf :tangle ~/.gitconfig
1023 #+begin_src conf :tangle ~/.gitconfig
1026 sclone = clone --depth 1
1031 quickfix = commit . --amend --no-edit
1033 subup = submodule update --remote
1034 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1035 pushnc = push -o skip-ci
1038 #+begin_src conf :tangle ~/.gitconfig
1044 Lightweight notification daemon. Eventually I'd like to replace this with something dbus-less.
1046 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1048 font = "JetBrains Mono Medium Nerd Font 11"
1050 format = "<b>%s</b>\n%b"
1052 indicate_hidden = yes
1055 show_age_threshold = 60
1058 geometry = "400x5-10+10"
1060 idle_threshold = 120
1062 sticky_history = yes
1064 separator_height = 1
1066 horizontal_padding = 8
1068 separator_color = "#ffffff"
1069 startup_notification = false
1072 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1079 close_all = mod4+shift+c
1080 history = mod4+ctrl+c
1083 background = "#222222"
1084 foreground = "#ffffff"
1085 highlight = "#ffffff"
1089 background = "#222222"
1090 foreground = "#ffffff"
1091 highlight = "#ffffff"
1095 background = "#222222"
1096 foreground = "#a60000"
1097 highlight = "#ffffff"
1101 The best document reader!
1103 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1105 map <A-b> toggle_statusbar
1106 set selection-clipboard clipboard
1109 set window-title-basename "true"
1110 set selection-clipboard "clipboard"
1113 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1114 set default-bg "#000000"
1115 set default-fg "#ffffff"
1116 set render-loading true
1117 set render-loading-bg "#000000"
1118 set render-loading-fg "#ffffff"
1120 set recolor-lightcolor "#000000" # bg
1121 set recolor-darkcolor "#ffffff" # fg
1125 Just some basic Firefox CSS. Will probably have to rewrite for the Proton redesign.
1126 *** Swap tab and URL bars
1127 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1129 -moz-box-ordinal-group: 1 !important;
1133 -moz-box-ordinal-group: 2 !important;
1137 -moz-box-ordinal-group: 3 !important;
1140 *** Hide URL bar when not focused.
1141 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1142 #navigator-toolbox:not(:focus-within):not(:hover) {
1146 #navigator-toolbox {
1147 transition: 0.1s margin-top ease-out;
1150 *** Black screen by default
1152 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1155 #browser vbox#appcontent tabbrowser,
1157 #tabbrowser-tabpanels,
1159 browser[type="content-primary"],
1160 browser[type="content"] > html,
1162 background: black !important;
1163 color: #fff !important;
1168 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css
1169 @-moz-document url("about:home"), url("about:blank"), url("about:newtab") {
1171 background: black !important;
1176 Modus operandi theme. No program I use checks for anything beyond foreground and background, but hey, it can't hurt to have all the colors in there.
1177 #+begin_src conf :tangle ~/.Xresources
1179 ,*.foreground: #ffffff
1180 ,*.background: #000000
1181 ,*.cursorColor: #ffffff
1216 I use tmux in order to keep my st build light. Still learning how it works.
1217 #+begin_src conf :tangle ~/.tmux.conf
1220 set-option -g history-limit 50000
1221 set-window-option -g mode-keys vi
1222 bind-key -T copy-mode-vi 'v' send -X begin-selection
1223 bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
1227 #+begin_src conf :tangle ~/.gnupg/gpg.conf
1228 default-key 3C9ED82FFE788E4A
1232 #+begin_src conf :tangle ~/.gnupg/gpg-agent.conf
1233 pinentry-program /sbin/pinentry-gnome3
1235 default-cache-ttl 600
1236 allow-emacs-pinentry