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 GCCEmacs 28 from the feature/native-comp branch, so some settings may not be available for older versions of Emacs. This is a purely personal configuration, so while I can garuntee that it works on my setup, I can't for anything else.
11 I chose to create a powerful, yet not overly heavy Emacs configuration. Things like LSP mode are important to my workflow and help me be productive, so despite its weight, it is kept. Things like a fancy modeline or icons on the other hand, 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 [[*EmacsOS]]). I use Email, IRC, et cetera, all through Emacs which simplifies my workflow.
15 Lastly, I use Evil mode. I think modal keybindings are simple and more ergonomic than standard Emacs style, and Vim keybindings are what I'm comfortable with and are pervasive throughout computing.
17 *** TODO Turn keybinding and hook declarations into use-package declarations where possible
18 *** TODO Include offlineimap config
20 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 at the snippet.
22 ** Bootstrap straight.el
23 straight.el is really nice for managing package, and it integrates nicely with use-package. It uses the bootstrapping system defined here for installation.
24 #+begin_src emacs-lisp
25 (defvar bootstrap-version)
27 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
28 (bootstrap-version 5))
29 (unless (file-exists-p bootstrap-file)
31 (url-retrieve-synchronously
32 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
33 'silent 'inhibit-cookies)
34 (goto-char (point-max))
35 (eval-print-last-sexp)))
36 (load bootstrap-file nil 'nomessage))
38 ** Replace use-package with straight
39 #+begin_src emacs-lisp
40 (straight-use-package 'use-package)
41 (setq straight-use-package-by-default t)
45 Very nice high contrast theme.
47 Its fine to set this here because I run Emacs in daemon mode, but if I were not, then putting it in early-init.el would be a better choice to eliminate the window being white before the theme is loaded.
48 #+begin_src emacs-lisp
49 (setq modus-themes-slanted-constructs t
50 modus-themes-bold-constructs t
51 modus-themes-mode-line '3d
52 modus-themes-scale-headings t
53 modus-themes-diffs 'desaturated)
54 (load-theme 'modus-vivendi t)
58 Great programming font with ligatures.
59 #+begin_src emacs-lisp
60 (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
63 #+begin_src emacs-lisp
65 :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
67 (ligature-set-ligatures
68 '(prog-mode text-mode)
69 '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "/=" "/=="
70 "/>" "//" "/*" "*>" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
71 "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>"
72 "<-|" "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>"
73 "</" "<*" "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>"
74 ":=" "::=" "=>>" "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!=="
75 "!!" "!=" ">]" ">:" ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&"
76 "&&" "|||>" "||>" "|>" "|]" "|}" "|=>" "|->" "|=" "||-" "|-"
77 "||=" "||" ".." ".?" ".=" ".-" "..<" "..." "+++" "+>" "++"
78 "[||]" "[<" "[|" "{|" "?." "?=" "?:" "##" "###" "####" "#["
79 "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_" "__" "~~"
80 "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
81 (global-ligature-mode t))
84 Display relative line numbers except in some modes
85 #+begin_src emacs-lisp
86 (global-display-line-numbers-mode)
87 (setq display-line-numbers-type 'relative)
88 (dolist (no-line-num '(term-mode-hook
93 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
95 ** Highlight matching parenthesis
96 #+begin_src emacs-lisp
98 :config (show-paren-mode)
99 :custom (show-paren-style 'parenthesis))
102 *** Show current function
103 #+begin_src emacs-lisp
104 (which-function-mode)
106 *** Make position in file more descriptive
107 Show current column and file size.
108 #+begin_src emacs-lisp
110 (size-indication-mode)
113 #+begin_src emacs-lisp
115 :config (minions-mode))
118 Show a ruler at a certain number of chars depending on mode.
119 #+begin_src emacs-lisp
120 (setq display-fill-column-indicator-column 80)
121 (global-display-fill-column-indicator-mode)
124 Whenever starting a key chord, show possible future steps.
125 #+begin_src emacs-lisp
126 (use-package which-key
127 :config (which-key-mode)
128 :custom (which-key-idle-delay 0.3))
130 ** Highlight TODOs in comments
131 #+begin_src emacs-lisp
133 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
134 :config (global-hl-todo-mode 1))
137 #+begin_src emacs-lisp
141 Soft wrap words and do operations by visual lines.
142 #+begin_src emacs-lisp
143 (add-hook 'text-mode-hook 'visual-line-mode 1)
145 ** Display number of matches in search
146 #+begin_src emacs-lisp
148 :config (global-anzu-mode))
151 Inverts modeline instead of audible bell or the standard visual bell.
152 #+begin_src emacs-lisp
153 (setq visible-bell nil
155 (lambda () (invert-face 'mode-line)
156 (run-with-timer 0.1 nil #'invert-face 'mode-line)))
160 #+begin_src emacs-lisp
162 :custom (select-enable-clipboard nil)
165 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
166 ;; Use visual line motions even outside of visual-line-mode buffers
167 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
168 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
169 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
172 #+begin_src emacs-lisp
173 (use-package evil-collection
175 :init (evil-collection-init)
176 :custom (evil-collection-setup-minibuffer t))
180 #+begin_src emacs-lisp
181 (use-package evil-surround
182 :config (global-evil-surround-mode))
185 #+begin_src emacs-lisp
186 (use-package evil-leader
187 :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
189 (evil-leader/set-leader "<SPC>")
190 (global-evil-leader-mode))
193 #+begin_src emacs-lisp
195 (use-package evil-nerd-commenter
196 :bind (:map evil-normal-state-map
197 ("gc" . evilnc-comment-or-uncomment-lines))
198 :custom (evilnc-invert-comment-line-by-line nil))
202 #+begin_src emacs-lisp
203 (evil-set-undo-system 'undo-redo)
205 ** Number incrementing
207 #+begin_src emacs-lisp
208 (use-package evil-numbers
209 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
210 :bind (:map evil-normal-state-map
211 ("C-M-a" . evil-numbers/inc-at-pt)
212 ("C-M-x" . evil-numbers/dec-at-pt)))
216 #+begin_src emacs-lisp
217 (use-package evil-org
219 :hook (org-mode . evil-org-mode)
221 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
222 (use-package evil-org-agenda
223 :straight (:type built-in)
225 :config (evil-org-agenda-set-keys))
228 #+begin_src emacs-lisp
229 (evil-leader/set-key-for-mode 'org-mode
230 "T" 'org-show-todo-tree
232 "c" 'org-archive-subtree)
236 #+begin_src emacs-lisp
238 :straight (:type built-in)
239 :commands (org-capture org-agenda)
242 (org-agenda-start-with-log-mode t)
243 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
245 (org-log-into-drawer t)
246 (org-src-tab-acts-natively t)
247 (org-src-fontify-natively t)
248 (org-startup-indented t)
249 (org-hide-emphasis-markers t)
250 (org-fontify-whole-block-delimiter-line nil)
251 :bind ("C-c a" . org-agenda))
254 #+begin_src emacs-lisp
255 (use-package org-tempo
257 :straight (:type built-in)
259 ;; TODO: There's gotta be a more efficient way to write this
260 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
261 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
262 (add-to-list 'org-structure-template-alist '("ash" . "src shell :tangle ~/.config/ash/ashrc"))
263 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
264 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
265 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
266 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc"))
267 (add-to-list 'org-structure-template-alist '("za" . "src conf :tangle ~/.config/zathura/zathurarc"))
268 (add-to-list 'org-structure-template-alist '("ff1" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css"))
269 (add-to-list 'org-structure-template-alist '("ff2" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css"))
270 (add-to-list 'org-structure-template-alist '("xr" . "src conf :tangle ~/.Xresources"))
271 (add-to-list 'org-structure-template-alist '("tm" . "src conf :tangle ~/.tmux.conf"))
272 (add-to-list 'org-structure-template-alist '("gp" . "src conf :tangle ~/.gnupg/gpg.conf"))
273 (add-to-list 'org-structure-template-alist '("ag" . "src conf :tangle ~/.gnupg/gpg-agent.conf")))
277 Simple, but not too simple autocompletion.
278 #+begin_src emacs-lisp
280 :bind (("C-s" . swiper)
281 :map ivy-minibuffer-map
282 ("TAB" . ivy-alt-done)
283 :map ivy-switch-buffer-map
284 ("M-d" . ivy-switch-buffer-kill))
288 #+begin_src emacs-lisp
289 (use-package ivy-rich
291 :config (ivy-rich-mode))
295 #+begin_src emacs-lisp
297 :bind (("C-M-j" . 'counsel-switch-buffer)
298 :map minibuffer-local-map
299 ("C-r" . 'counsel-minibuffer-history))
300 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
301 :config (counsel-mode))
303 ** Remember frequent commands
304 #+begin_src emacs-lisp
305 (use-package ivy-prescient
307 :custom (ivy-prescient-enable-filtering nil)
309 (prescient-persist-mode)
310 (ivy-prescient-mode))
313 Better search utility.
314 #+begin_src emacs-lisp
319 Use elfeed for RSS. I have another file with all the feeds in it.
320 #+begin_src emacs-lisp
322 :bind (("C-c e" . elfeed))
324 (load "~/.emacs.d/feeds.el")
325 (add-hook 'elfeed-new-entry-hook
326 (elfeed-make-tagger :feed-url "youtube\\.com"
328 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
330 (use-package elfeed-goodies
332 :config (elfeed-goodies/setup))
335 Use mu4e for reading emails.
337 I use `offlineimap` to sync my maildirs. It is slower than mbsync, but is fast enough for me, especially when ran with the =-q= option.
339 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.
340 #+begin_src emacs-lisp
341 (use-package smtpmail
342 :straight (:type built-in))
344 :load-path "/usr/share/emacs/site-lisp/mu4e"
345 :straight (:build nil)
346 :bind (("C-c m" . mu4e))
348 (setq user-full-name "Armaan Bhojwani"
349 smtpmail-local-domain "armaanb.net"
350 smtpmail-stream-type 'ssl
351 smtpmail-smtp-service '465
352 mu4e-change-filenames-when-moving t
353 mu4e-get-mail-command "offlineimap -q"
354 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
355 message-citation-line-function 'message-insert-formatted-citation-line
356 mu4e-completing-read-function 'ivy-completing-read
357 mu4e-confirm-quit nil
359 mail-user-agent 'mu4e-user-agent
360 mail-context-policy 'pick-first
362 `( ,(make-mu4e-context
364 :enter-func (lambda () (mu4e-message "Entering school context"))
365 :leave-func (lambda () (mu4e-message "Leaving school context"))
366 :match-func (lambda (msg)
368 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
369 :vars '((user-mail-address . "abhojwani22@nobles.edu")
370 (mu4e-sent-folder . "/school/Sent")
371 (mu4e-drafts-folder . "/school/Drafts")
372 (mu4e-trash-folder . "/school/Trash")
373 (mu4e-refile-folder . "/school/Archive")
374 (message-cite-reply-position . above)
375 (user-mail-address . "abhojwani22@nobles.edu")
376 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
377 (smtpmail-smtp-server . "smtp.gmail.com")))
380 :enter-func (lambda () (mu4e-message "Entering personal context"))
381 :leave-func (lambda () (mu4e-message "Leaving personal context"))
382 :match-func (lambda (msg)
384 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
385 :vars '((mu4e-sent-folder . "/personal/Sent")
386 (mu4e-drafts-folder . "/personal/Drafts")
387 (mu4e-trash-folder . "/personal/Trash")
388 (mu4e-refile-folder . "/personal/Archive")
389 (user-mail-address . "me@armaanb.net")
390 (message-cite-reply-position . below)
391 (smtpmail-smtp-user . "me@armaanb.net")
392 (smtpmail-smtp-server . "smtp.mailbox.org")))))
393 (add-to-list 'mu4e-bookmarks
394 '(:name "Unified inbox"
395 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
397 :hook ((mu4e-compose-mode . flyspell-mode)
398 (mu4e-compose-mode . auto-fill-mode)
399 (mu4e-view-mode-hook . turn-on-visual-line-mode)
400 (message-send-hook . (lambda () (unless (yes-or-no-p "Ya sure 'bout that?")
401 (signal 'quit nil))))))
403 Discourage Gnus from displaying HTML emails
404 #+begin_src emacs-lisp
405 (with-eval-after-load "mm-decode"
406 (add-to-list 'mm-discouraged-alternatives "text/html")
407 (add-to-list 'mm-discouraged-alternatives "text/richtext"))
410 Set EWW as default browser except for videos.
411 #+begin_src emacs-lisp
412 (defun browse-url-mpv (url &optional new-window)
414 (start-process "mpv" "*mpv*" "mpv" url))
416 (setq browse-url-handlers
418 (("youtu\\.?be" . browse-url-mpv)
419 ("peertube.*" . browse-url-mpv)
420 ("vid.*" . browse-url-mpv)
421 ("vid.*" . browse-url-mpv)
422 ("." . eww-browse-url)
426 Some EWW enhancements.
427 *** Give buffer a useful name
428 #+begin_src emacs-lisp
429 ;; From https://protesilaos.com/dotemacs/
430 (defun prot-eww--rename-buffer ()
431 "Rename EWW buffer using page title or URL.
432 To be used by `eww-after-render-hook'."
433 (let ((name (if (eq "" (plist-get eww-data :title))
434 (plist-get eww-data :url)
435 (plist-get eww-data :title))))
436 (rename-buffer (format "*%s # eww*" name) t)))
439 :straight (:type built-in)
440 :bind (("C-c w" . eww))
441 :hook (eww-after-render-hook prot-eww--rename-buffer))
444 #+begin_src emacs-lisp
445 (global-set-key (kbd "C-c w") 'eww)
448 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.
449 #+begin_src emacs-lisp
450 (defun fetch-password (&rest params)
451 (require 'auth-source)
452 (let ((match (car (apply 'auth-source-search params))))
454 (let ((secret (plist-get match :secret)))
455 (if (functionp secret)
458 (error "Password not found for %S" params))))
463 (enable-circe-color-nicks)
467 (setq circe-networks '(("libera"
468 :host "irc.armaanb.net"
473 :pass (lambda (null) (fetch-password
475 :machine "irc.armaanb.net"
478 :host "irc.armaanb.net"
483 :pass (lambda (null) (fetch-password
485 :machine "irc.armaanb.net"
488 :host "irc.armaanb.net"
493 :pass (lambda (null) (fetch-password
495 :machine "irc.armaanb.net"
498 :custom (circe-default-part-message "goodbye!")
499 :bind (:map circe-mode-map ("C-c C-r" . circe-reconnect-all)))
502 #+begin_src emacs-lisp
503 (defun sync-calendar ()
504 "Sync calendars with vdirsyncer"
506 (shell-command "vdirsyncer -vcritical sync"))
509 :bind (:map cfw:calendar-mode-map ("C-S-u" . sync-calendar)))
510 (use-package calfw-ical)
511 (use-package calfw-org)
513 (defun acheam-calendar ()
516 (cfw:open-calendar-buffer
517 :contents-sources (list
518 (cfw:org-create-source "Green")
519 (cfw:ical-create-source
521 "~/.local/share/vdirsyncer/mailbox/Y2FsOi8vMC8zMQ.ics"
523 (cfw:ical-create-source
525 "~/.local/share/vdirsyncer/mailbox/Y2FsOi8vMC8zMQ.ics"
527 (cfw:ical-create-source
529 "~/.local/share/vdirsyncer/school/abhojwani22@nobles.edu.ics"
533 (global-set-key (kbd "C-c c") 'acheam-calendar)
537 #+begin_src emacs-lisp
539 :hook (python-mode . blacken-mode)
540 :config (setq blacken-line-length 79))
543 (use-package ws-butler
544 :config (ws-butler-global-mode))
547 #+begin_src emacs-lisp
548 (use-package flycheck
549 :config (global-flycheck-mode))
551 ** Project management
552 #+begin_src emacs-lisp
553 (use-package projectile
554 :config (projectile-mode)
555 :custom ((projectile-completion-system 'ivy))
557 ("C-c p" . projectile-command-map)
559 (when (file-directory-p "~/Code")
560 (setq projectile-project-search-path '("~/Code")))
561 (setq projectile-switch-project-action #'projectile-dired))
563 (use-package counsel-projectile
565 :config (counsel-projectile-mode))
568 #+begin_src emacs-lisp
570 :straight (:type built-in)
571 :commands (dired dired-jump)
572 :custom ((dired-listing-switches "-agho --group-directories-first"))
573 :config (evil-collection-define-key 'normal 'dired-mode-map
574 "h" 'dired-single-up-directory
575 "l" 'dired-single-buffer))
577 (use-package dired-single
578 :commands (dired dired-jump))
580 (use-package dired-open
581 :commands (dired dired-jump)
582 :custom (dired-open-extensions '(("png" . "feh")
585 (use-package dired-hide-dotfiles
586 :hook (dired-mode . dired-hide-dotfiles-mode)
588 (evil-collection-define-key 'normal 'dired-mode-map
589 "H" 'dired-hide-dotfiles-mode))
593 # TODO: Write a command that commits hunk, skipping staging step.
594 #+begin_src emacs-lisp
597 *** Colored diff in line number area
598 #+begin_src emacs-lisp
600 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
601 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
602 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
603 :config (global-diff-hl-mode))
606 #+begin_src emacs-lisp
608 (use-package git-email
609 :straight (git-email :repo "https://git.sr.ht/~yoctocell/git-email")
610 :config (git-email-piem-mode))
613 *** Evaluate current buffer
614 Stolen from https://stackoverflow.com/questions/19953924/how-do-you-run-java-codes-in-emacs
615 #+begin_src emacs-lisp
616 (defun java-eval-buffer ()
617 "run current program (that requires no input)"
619 (let* ((source (file-name-nondirectory buffer-file-name))
620 (out (file-name-sans-extension source))
621 (class (concat out ".class")))
623 (shell-command (format "rm -f %s && javac %s" class source))
624 (if (file-exists-p class)
625 (shell-command (format "java %s" out) "*scratch*")
627 (set (make-local-variable 'compile-command)
628 (format "javac %s" source))
629 (command-execute 'compile)))))
631 * General text editing
633 Indent after every change.
634 #+begin_src emacs-lisp
635 (use-package aggressive-indent
636 :config (global-aggressive-indent-mode))
639 Spell check in text mode, and in prog-mode comments.
640 #+begin_src emacs-lisp
641 (dolist (hook '(text-mode-hook))
642 (add-hook hook (lambda () (flyspell-mode))))
643 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
644 (add-hook hook (lambda () (flyspell-mode -1))))
645 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
647 ** Expand tabs to spaces
648 #+begin_src emacs-lisp
649 (setq-default tab-width 2)
651 ** Copy kill ring to clipboard
652 #+begin_src emacs-lisp
653 (setq x-select-enable-clipboard t)
654 (defun copy-kill-ring-to-xorg ()
655 "Copy the current kill ring to the xorg clipboard."
657 (x-select-text (current-kill 0)))
660 Opens file where you left it.
661 #+begin_src emacs-lisp
665 Distraction free writing a la junegunn/goyo.
666 #+begin_src emacs-lisp
667 (use-package olivetti
669 (evil-leader/set-key "o" 'olivetti-mode))
673 #+begin_src emacs-lisp
674 (setq abbrev-file-name "~/.emacs.d/abbrevs.el")
675 (setq save-abbrevs 'silent)
676 (setq-default abbrev-mode t)
679 #+begin_src emacs-lisp
680 (setq tramp-default-method "ssh")
682 ** Don't ask about following symlinks in vc
683 #+begin_src emacs-lisp
684 (setq vc-follow-symlinks t)
686 ** Don't ask to save custom dictionary
687 #+begin_src emacs-lisp
688 (setq ispell-silently-savep t)
691 #+begin_src emacs-lisp
692 (defun doas-edit (&optional arg)
693 "Edit currently visited file as root.
695 With a prefix ARG prompt for a file to visit.
696 Will also prompt for a file to visit if current
697 buffer is not visiting a file.
699 Modified from Emacs Redux."
701 (if (or arg (not buffer-file-name))
702 (find-file (concat "/doas:root@localhost:"
703 (ido-read-file-name "Find file(as root): ")))
704 (find-alternate-file (concat "/doas:root@localhost:" buffer-file-name))))
706 (global-set-key (kbd "C-x C-r") #'doas-edit)
710 #+begin_src emacs-lisp
711 (use-package ace-window
712 :bind ("M-o" . ace-window))
714 ** Kill current buffer
715 Makes "C-x k" binding faster.
716 #+begin_src emacs-lisp
717 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
721 #+begin_src emacs-lisp
722 (use-package scad-mode)
724 ** Control backup files
725 Stop backup files from spewing everywhere.
726 #+begin_src emacs-lisp
727 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
729 ** Make yes/no easier
730 #+begin_src emacs-lisp
731 (defalias 'yes-or-no-p 'y-or-n-p)
733 ** Move customize file
734 No more clogging up init.el.
735 #+begin_src emacs-lisp
736 (setq custom-file "~/.emacs.d/custom.el")
740 #+begin_src emacs-lisp
742 :commands (helpful-callable helpful-variable helpful-command helpful-key)
744 (counsel-describe-function-function #'helpful-callable)
745 (counsel-describe-variable-function #'helpful-variable)
747 ([remap describe-function] . counsel-describe-function)
748 ([remap describe-command] . helpful-command)
749 ([remap describe-variable] . counsel-describe-variable)
750 ([remap describe-key] . helpful-key))
753 #+begin_src emacs-lisp
754 (use-package epa-file
755 :straight (:type built-in)
757 (epa-file-select-keys nil)
758 (epa-file-encrypt-to '("me@armaanb.net"))
759 (password-cache-expiry (* 60 15)))
761 (use-package pinentry
762 :config (pinentry-start))
765 #+begin_src emacs-lisp
767 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
768 :custom (0x0-default-service 'envs)
769 :config (evil-leader/set-key
771 "0f" '0x0-upload-file
772 "0s" '0x0-upload-string
773 "0c" '0x0-upload-kill-ring
774 "0p" '0x0-upload-popup))
776 ** Automatically clean buffers
777 #+begin_src emacs-lisp
778 ;; Don't kill Circe buffers
779 (add-to-list 'clean-buffer-list-kill-never-regexps (lambda (buffer-name)
780 (with-current-buffer buffer-name
781 (derived-mode-p 'lui-mode))))
787 #+begin_src conf :tangle ~/.spectrwm.conf
791 autorun = ws[1]:/home/armaa/Code/scripts/autostart
794 #+begin_src conf :tangle ~/.spectrwm.conf
796 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
800 #+begin_src conf :tangle ~/.spectrwm.conf
801 program[term] = st -e tmux
802 program[screenshot_all] = flameshot gui
803 program[notif] = /home/armaa/Code/scripts/setter status
804 program[pass] = /home/armaa/Code/scripts/passmenu
807 bind[pass] = MOD+Shift+p
810 #+begin_src conf :tangle ~/.spectrwm.conf
811 program[paup] = /home/armaa/Code/scripts/setter audio +5
812 program[padown] = /home/armaa/Code/scripts/setter audio -5
813 program[pamute] = /home/armaa/Code/scripts/setter audio
814 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
815 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
816 program[next] = playerctl next
817 program[prev] = playerctl previous
818 program[pause] = playerctl play-pause
820 bind[padown] = XF86AudioLowerVolume
821 bind[paup] = XF86AudioRaiseVolume
822 bind[pamute] = XF86AudioMute
823 bind[brigdown] = XF86MonBrightnessDown
824 bind[brigup] = XF86MonBrightnessUp
825 bind[pause] = XF86AudioPlay
826 bind[next] = XF86AudioNext
827 bind[prev] = XF86AudioPrev
830 #+begin_src conf :tangle ~/.spectrwm.conf
831 program[h] = xdotool keyup h key --clearmodifiers Left
832 program[j] = xdotool keyup j key --clearmodifiers Down
833 program[k] = xdotool keyup k key --clearmodifiers Up
834 program[l] = xdotool keyup l key --clearmodifiers Right
836 bind[h] = MOD + Control + h
837 bind[j] = MOD + Control + j
838 bind[k] = MOD + Control + k
839 bind[l] = MOD + Control + l
842 #+begin_src conf :tangle ~/.spectrwm.conf
843 program[email] = emacsclient -c --eval "(mu4e)"
844 program[irc] = emacsclient -c --eval '(switch-to-buffer "irc.armaanb.net:6698")'
845 program[rss] = emacsclient -c --eval '(elfeed)'
846 program[emacs] = emacsclient -c
847 program[firefox] = firefox
848 program[calc] = st -e because -l
850 bind[email] = MOD+Control+1
851 bind[irc] = MOD+Control+2
852 bind[rss] = MOD+Control+3
853 bind[firefox] = MOD+Control+4
854 bind[calc] = MOD+Control+5
855 bind[emacs] = MOD+Control+Return
858 #+begin_src conf :tangle ~/.spectrwm.conf
859 quirk[Castle Menu] = FLOAT
864 #+begin_src conf :tangle ~/.config/ash/ashrc
868 **** Update all packages
869 #+begin_src shell :tangle ~/.config/ash/ashrc
870 color=$(tput setaf 5)
874 doas echo "${color}== upgrading with yay ==${reset}"
877 echo "${color}== checking for pacnew files ==${reset}"
880 echo "${color}== upgrading flatpaks ==${reset}"
883 echo "${color}== updating nvim plugins ==${reset}"
884 nvim +PlugUpdate +PlugUpgrade +qall
885 echo "Updated nvim plugins"
887 echo "${color}You are entirely up to date!${reset}"
890 **** Clean all packages
891 #+begin_src shell :tangle ~/.config/ash/ashrc
893 doas echo "${color}== cleaning pacman orphans ==${reset}"
894 (pacman -Qtdq | doas pacman -Rns - 2> /dev/null) || echo "No orphans"
896 echo "${color}== cleaning flatpaks ==${reset}"
897 flatpak remove --unused
899 echo "${color}== cleaning nvim plugins ==${reset}"
900 nvim +PlugClean +qall
901 echo "Cleaned nvim plugins"
903 echo "${color}All orphans cleaned!${reset}"
906 **** Interact with 0x0
907 #+begin_src shell :tangle ~/.config/ash/ashrc
908 zxz="https://envs.sh"
909 ufile() { curl -F"file=@$1" "$zxz" ; }
910 upb() { curl -F"file=@-;" "$zxz" ; }
911 uurl() { curl -F"url=$1" "$zxz" ; }
912 ushort() { curl -F"shorten=$1" "$zxz" ; }
913 uclip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
916 #+begin_src shell :tangle ~/.config/ash/ashrc
918 user=$(echo "$1" | cut -f 1 -d '@')
919 host=$(echo "$1" | cut -f 2 -d '@')
920 echo $user | nc "$host" 79
923 **** Upload to ftp.armaanb.net
924 #+begin_src shell :tangle ~/.config/ash/ashrc
926 rsync "$1" "root@armaanb.net:/var/ftp/pub/${2}"
927 echo "https://ftp.armaanb.net/pub/"$(basename "$1") | tee /dev/tty | xclip -sel c
931 #+begin_src shell :tangle ~/.config/ash/ashrc
932 export EDITOR="emacsclient -c"
933 export VISUAL="$EDITOR"
934 export TERM=xterm-256color # for compatability
936 export GPG_TTY="$(tty)"
937 export MANPAGER='nvim +Man!'
940 export GTK_USE_PORTAL=1
942 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
943 export PATH="/home/armaa/Code/scripts:$PATH" # prioritize my scripts
944 export PATH="/home/armaa/Code/scripts/bin:$PATH" # prioritize my bins
945 export PATH="$PATH:/home/armaa/.cargo/bin"
946 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
947 export PATH="$PATH:/usr/sbin"
948 export PATH="$PATH:/opt/FreeTube/freetube"
950 export LC_ALL="en_US.UTF-8"
951 export LC_CTYPE="en_US.UTF-8"
952 export LANGUAGE="en_US.UTF-8"
954 export KISS_PATH="/home/armaa/Virtual/kiss/home/armaa/kiss-repo"
955 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
956 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
957 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
958 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
959 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
963 #+begin_src shell :tangle ~/.config/ash/ashrc
964 alias bhoji-drop='ssh -p 23 root@armaanb.net'
965 alias irc='ssh root@armaanb.net -t abduco -A irc catgirl freenode'
966 alias union='ssh 192.168.1.18'
967 alias mine='ssh -p 23 root@pickupserver.cc'
968 alias tcf='ssh root@204.48.23.68'
969 alias ngmun='ssh root@157.245.89.25'
970 alias prox='ssh root@192.168.1.224'
971 alias ncq='ssh root@143.198.123.17'
972 alias envs='ssh acheam@envs.net'
975 #+begin_src shell :tangle ~/.config/ash/ashrc
976 alias ls='ls -lh --group-directories-first'
978 alias df='df -h / /boot'
985 alias grep='grep -in --color=auto'
986 alias mkdir='mkdir -pv'
987 alias lanex='java -jar ~/.local/share/lxc/lanxchange.jar'
988 emacs() { $EDITOR "$@" & }
991 **** System management
992 #+begin_src shell :tangle ~/.config/ash/ashrc
993 alias crontab='crontab-argh'
995 alias pasu='git -C ~/.password-store push'
996 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1000 #+begin_src shell :tangle ~/.config/ash/ashrc
1001 alias ping='ping -c 10'
1002 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1003 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1004 alias plan='T=$(mktemp) && \
1005 rsync root@armaanb.net:/etc/finger/plan.txt "$T" && \
1007 head -n -2 $T > $TT && \
1009 echo "\nLast updated: $(date -R)" >> "$TT" && \
1010 fold -sw 72 "$TT" > "$T"| \
1011 rsync "$T" root@armaanb.net:/etc/finger/plan.txt'
1013 **** Virtual machines, chroots
1014 #+begin_src shell :tangle ~/.config/ash/ashrc
1015 alias ckiss="doas chrooter ~/Virtual/kiss"
1016 alias cdebian="doas chrooter ~/Virtual/debian bash"
1017 alias cwindows='devour qemu-system-x86_64 \
1022 -device VGA,vgamem_mb=64 \
1024 -device hda-duplex \
1026 -net user,smb=/home/armaa/Public \
1027 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1030 #+begin_src shell :tangle ~/.config/ash/ashrc
1031 alias pip="python -m pip"
1032 alias black="black -l 79"
1035 #+begin_src shell :tangle ~/.config/ash/ashrc
1036 alias words='gen-shell -c "words"'
1037 alias words-e='gen-shell -c "words ~E"'
1040 #+begin_src shell :tangle ~/.config/ash/ashrc
1041 alias zathura='devour zathura'
1042 alias cad='devour openscad'
1043 alias feh='devour feh'
1046 #+begin_src shell :tangle ~/.config/ash/ashrc
1048 alias api='yay -Syu'
1049 alias apii='doas pacman -S'
1050 alias app='yay -Rns'
1051 alias azf='pacman -Q | fzf'
1052 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1055 #+begin_src shell :tangle ~/.config/ash/ashrc
1056 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1057 iflag=fullblock status=progress'
1058 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1059 iflag=fullblock status=progress'
1060 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1061 --restrict-filenames -o '%(title)s.%(ext)s'"
1062 alias cal="cal -3 --color=auto"
1066 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1067 c.TerminalInteractiveShell.editing_mode = 'vi'
1068 c.InteractiveShell.colors = 'linux'
1069 c.TerminalInteractiveShell.confirm_exit = False
1072 Make MPV play a little bit smoother.
1073 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1074 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1078 For any GNU Readline programs
1079 #+begin_src conf :tangle ~/.inputrc
1080 set editing-mode emacs
1084 #+begin_src conf :tangle ~/.gitconfig
1086 name = Armaan Bhojwani
1087 email = me@armaanb.net
1088 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1091 #+begin_src conf :tangle ~/.gitconfig
1093 defaultBranch = main
1096 #+begin_src conf :tangle ~/.gitconfig
1101 #+begin_src conf :tangle ~/.gitconfig
1103 smtpserver = smtp.mailbox.org
1104 smtpuser = me@armaanb.net
1105 smtpencryption = ssl
1106 smtpserverport = 465
1110 #+begin_src conf :tangle ~/.gitconfig
1115 #+begin_src conf :tangle ~/.gitconfig
1118 sclone = clone --depth 1
1123 quickfix = commit . --amend --no-edit
1125 subup = submodule update --remote
1126 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1127 pushnc = push -o skip-ci
1130 #+begin_src conf :tangle ~/.gitconfig
1136 Lightweight notification daemon.
1138 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1140 font = "JetBrains Mono Medium Nerd Font 11"
1142 format = "<b>%s</b>\n%b"
1144 indicate_hidden = yes
1147 show_age_threshold = 60
1150 geometry = "400x5-10+10"
1152 idle_threshold = 120
1154 sticky_history = yes
1156 separator_height = 1
1158 horizontal_padding = 8
1160 separator_color = "#ffffff"
1161 startup_notification = false
1164 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1171 close_all = mod4+shift+c
1172 history = mod4+ctrl+c
1175 background = "#222222"
1176 foreground = "#ffffff"
1177 highlight = "#ffffff"
1181 background = "#222222"
1182 foreground = "#ffffff"
1183 highlight = "#ffffff"
1187 background = "#222222"
1188 foreground = "#a60000"
1189 highlight = "#ffffff"
1194 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1196 map <A-b> toggle_statusbar
1197 set selection-clipboard clipboard
1200 set window-title-basename "true"
1201 set selection-clipboard "clipboard"
1204 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1205 set default-bg "#000000"
1206 set default-fg "#ffffff"
1207 set render-loading true
1208 set render-loading-bg "#000000"
1209 set render-loading-fg "#ffffff"
1211 set recolor-lightcolor "#000000" # bg
1212 set recolor-darkcolor "#ffffff" # fg
1216 *** Swap tab and URL bars
1217 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1219 -moz-box-ordinal-group: 1 !important;
1223 -moz-box-ordinal-group: 2 !important;
1227 -moz-box-ordinal-group: 3 !important;
1230 *** Hide URL bar when not focused.
1231 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1232 #navigator-toolbox:not(:focus-within):not(:hover) {
1236 #navigator-toolbox {
1237 transition: 0.1s margin-top ease-out;
1240 *** Black screen by default
1242 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1245 #browser vbox#appcontent tabbrowser,
1247 #tabbrowser-tabpanels,
1249 browser[type="content-primary"],
1250 browser[type="content"] > html,
1252 background: black !important;
1253 color: #fff !important;
1258 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css
1259 @-moz-document url("about:home"), url("about:blank"), url("about:newtab") {
1261 background: black !important;
1266 Modus operandi theme.
1267 #+begin_src conf :tangle ~/.Xresources
1269 ,*.foreground: #ffffff
1270 ,*.background: #000000
1271 ,*.cursorColor: #ffffff
1306 #+begin_src conf :tangle ~/.tmux.conf
1309 set-window-option -g mode-keys vi
1310 bind-key -T copy-mode-vi 'v' send -X begin-selection
1311 bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard'
1315 #+begin_src conf :tangle ~/.gnupg/gpg.conf
1316 default-key 3C9ED82FFE788E4A
1320 #+begin_src conf :tangle ~/.gnupg/gpg-agent.conf
1321 pinentry-program /sbin/pinentry-gnome3
1323 default-cache-ttl 600
1324 allow-emacs-pinentry