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 Put configs with passwords in here with some kind of authentication
22 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.
24 ** Bootstrap straight.el
25 straight.el is really nice for managing package, and it integrates nicely with use-package. It uses the bootstrapping system defined here for installation.
26 #+begin_src emacs-lisp
27 (defvar bootstrap-version)
29 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
30 (bootstrap-version 5))
31 (unless (file-exists-p bootstrap-file)
33 (url-retrieve-synchronously
34 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
35 'silent 'inhibit-cookies)
36 (goto-char (point-max))
37 (eval-print-last-sexp)))
38 (load bootstrap-file nil 'nomessage))
40 ** Replace use-package with straight
41 #+begin_src emacs-lisp
42 (straight-use-package 'use-package)
43 (setq straight-use-package-by-default t)
47 Very nice high contrast theme.
49 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.
50 #+begin_src emacs-lisp
51 (setq modus-themes-slanted-constructs t
52 modus-themes-bold-constructs t
53 modus-themes-org-blocks 'grayscale
54 modus-themes-mode-line '3d
55 modus-themes-scale-headings t
56 modus-themes-region 'no-extend
57 modus-themes-diffs 'desaturated)
58 (load-theme 'modus-vivendi t)
61 #+begin_src emacs-lisp
62 (use-package tree-sitter-langs)
63 (use-package tree-sitter
64 :config (global-tree-sitter-mode)
65 :hook (tree-sitter-after-on-hook . tree-sitter-hl-mode))
69 Great programming font with ligatures.
70 #+begin_src emacs-lisp
71 (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
74 #+begin_src emacs-lisp
76 :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
78 (ligature-set-ligatures
79 '(prog-mode text-mode)
80 '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "/=" "/=="
81 "/>" "//" "/*" "*>" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
82 "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>"
83 "<-|" "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>"
84 "</" "<*" "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>"
85 ":=" "::=" "=>>" "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!=="
86 "!!" "!=" ">]" ">:" ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&"
87 "&&" "|||>" "||>" "|>" "|]" "|}" "|=>" "|->" "|=" "||-" "|-"
88 "||=" "||" ".." ".?" ".=" ".-" "..<" "..." "+++" "+>" "++"
89 "[||]" "[<" "[|" "{|" "?." "?=" "?:" "##" "###" "####" "#["
90 "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_" "__" "~~"
91 "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
92 (global-ligature-mode t))
95 #+begin_src emacs-lisp
97 :config (global-emojify-mode))
99 ;; http://ergoemacs.org/emacs/emacs_list_and_set_font.html
104 ((member "Twitter Color Emoji" (font-family-list)) "Twitter Color Emoji")
105 ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
106 ((member "Noto Emoji" (font-family-list)) "Noto Emoji")))
109 Display relative line numbers except in some modes
110 #+begin_src emacs-lisp
111 (global-display-line-numbers-mode)
112 (setq display-line-numbers-type 'relative)
113 (dolist (no-line-num '(term-mode-hook
118 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
120 ** Highlight matching parenthesis
121 #+begin_src emacs-lisp
123 :config (show-paren-mode)
124 :custom (show-paren-style 'parenthesis))
127 *** Show current function
128 #+begin_src emacs-lisp
129 (which-function-mode)
131 *** Make position in file more descriptive
132 Show current column and file size.
133 #+begin_src emacs-lisp
135 (size-indication-mode)
138 #+begin_src emacs-lisp
140 :config (minions-mode))
143 #+begin_src emacs-lisp
145 :straight (wc-mode :type git :host github :repo "bnbeckwith/wc-mode")
146 :hook (text-mode-hook . wc-mode))
149 Show a ruler at a certain number of chars depending on mode.
150 #+begin_src emacs-lisp
151 (global-display-fill-column-indicator-mode)
154 Whenever starting a key chord, show possible future steps.
155 #+begin_src emacs-lisp
156 (use-package which-key
157 :config (which-key-mode)
158 :custom (which-key-idle-delay 0.3))
160 ** Highlight TODOs in comments
161 #+begin_src emacs-lisp
163 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
164 :config (global-hl-todo-mode 1))
167 #+begin_src emacs-lisp
171 Soft wrap words and do operations by visual lines.
172 #+begin_src emacs-lisp
173 (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
175 ** Display number of matches in search
176 #+begin_src emacs-lisp
178 :config (global-anzu-mode))
181 Inverts modeline instead of audible bell or the standard visual bell.
182 #+begin_src emacs-lisp
183 (setq visible-bell nil
184 ring-bell-function 'flash-mode-line)
185 (defun flash-mode-line ()
186 (invert-face 'mode-line)
187 (run-with-timer 0.1 nil #'invert-face 'mode-line))
191 #+begin_src emacs-lisp
193 :custom (select-enable-clipboard nil)
196 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
197 ;; Use visual line motions even outside of visual-line-mode buffers
198 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
199 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
200 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
203 #+begin_src emacs-lisp
204 (use-package evil-collection
206 :init (evil-collection-init)
207 :custom (evil-collection-setup-minibuffer t))
211 #+begin_src emacs-lisp
212 (use-package evil-surround
213 :config (global-evil-surround-mode))
216 #+begin_src emacs-lisp
217 (use-package evil-leader
218 :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
220 (evil-leader/set-leader "<SPC>")
221 (global-evil-leader-mode))
224 #+begin_src emacs-lisp
226 (use-package evil-nerd-commenter
227 :bind (:map evil-normal-state-map
228 ("gc" . evilnc-comment-or-uncomment-lines))
229 :custom (evilnc-invert-comment-line-by-line nil))
233 #+begin_src emacs-lisp
234 (evil-set-undo-system 'undo-redo)
236 ** Number incrementing
238 #+begin_src emacs-lisp
239 (use-package evil-numbers
240 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
241 :bind (:map evil-normal-state-map
242 ("C-M-a" . evil-numbers/inc-at-pt)
243 ("C-M-x" . evil-numbers/dec-at-pt)))
247 #+begin_src emacs-lisp
248 (use-package evil-org
250 :hook (org-mode . evil-org-mode)
252 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
253 (use-package evil-org-agenda
254 :straight (:type built-in)
257 (evil-org-agenda-set-keys))
260 #+begin_src emacs-lisp
261 (evil-leader/set-key-for-mode 'org-mode
262 "T" 'org-show-todo-tree
264 "c" 'org-archive-subtree)
268 #+begin_src emacs-lisp
270 :straight (:type built-in)
271 :commands (org-capture org-agenda)
273 (org-ellipsis " â–¾")
274 (org-agenda-start-with-log-mode t)
275 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
277 (org-log-into-drawer t)
278 (org-src-tab-acts-natively t)
279 (org-src-fontify-natively t)
280 (org-startup-indented t)
281 (org-hide-emphasis-markers t)
282 (org-fontify-whole-block-delimiter-line nil)
283 :bind ("C-c a" . org-agenda))
286 #+begin_src emacs-lisp
287 (use-package org-tempo
289 :straight (:type built-in)
291 ;; TODO: There's gotta be a more efficient way to write this
292 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
293 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
294 (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
295 (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
296 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
297 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
298 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
299 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc"))
300 (add-to-list 'org-structure-template-alist '("za" . "src conf :tangle ~/.config/zathura/zathurarc"))
301 (add-to-list 'org-structure-template-alist '("ff1" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css"))
302 (add-to-list 'org-structure-template-alist '("ff2" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css"))
303 (add-to-list 'org-structure-template-alist '("xr" . "src conf :tangle ~/.Xresources")))
306 #+begin_src emacs-lisp
307 (use-package org-present
308 :straight (org-present :type git :host github :repo "rlister/org-present"))
312 Simple, but not too simple autocompletion.
313 #+begin_src emacs-lisp
315 :bind (("C-s" . swiper)
316 :map ivy-minibuffer-map
317 ("TAB" . ivy-alt-done)
318 :map ivy-switch-buffer-map
319 ("M-d" . ivy-switch-buffer-kill))
323 #+begin_src emacs-lisp
324 (use-package ivy-rich
326 :config (ivy-rich-mode))
330 #+begin_src emacs-lisp
332 :bind (("C-M-j" . 'counsel-switch-buffer)
333 :map minibuffer-local-map
334 ("C-r" . 'counsel-minibuffer-history))
335 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
336 :config (counsel-mode))
338 ** Remember frequent commands
339 #+begin_src emacs-lisp
340 (use-package ivy-prescient
343 (ivy-prescient-enable-filtering nil)
345 (prescient-persist-mode)
346 (ivy-prescient-mode))
349 Better search utility.
350 #+begin_src emacs-lisp
355 Use elfeed for RSS. I have another file with all the feeds in it.
356 #+begin_src emacs-lisp
358 :bind (("C-c e" . elfeed))
360 (load "~/.emacs.d/feeds.el")
361 (add-hook 'elfeed-new-entry-hook
362 (elfeed-make-tagger :feed-url "youtube\\.com"
364 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
366 (use-package elfeed-goodies
368 :config (elfeed-goodies/setup))
371 Use mu4e for reading emails.
373 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.
375 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.
376 #+begin_src emacs-lisp
377 (use-package smtpmail
378 :straight (:type built-in))
380 :load-path "/usr/share/emacs/site-lisp/mu4e"
381 :straight (:build nil)
382 :bind (("C-c m" . mu4e))
384 (setq user-full-name "Armaan Bhojwani"
385 smtpmail-local-domain "armaanb.net"
386 smtpmail-stream-type 'ssl
387 smtpmail-smtp-service '465
388 mu4e-change-filenames-when-moving t
389 mu4e-get-mail-command "offlineimap -q"
390 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
391 message-citation-line-function 'message-insert-formatted-citation-line
392 mu4e-completing-read-function 'ivy-completing-read
393 mu4e-confirm-quit nil
394 mail-user-agent 'mu4e-user-agent
396 `( ,(make-mu4e-context
398 :enter-func (lambda () (mu4e-message "Entering school context"))
399 :leave-func (lambda () (mu4e-message "Leaving school context"))
400 :match-func (lambda (msg)
402 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
403 :vars '((user-mail-address . "abhojwani22@nobles.edu")
404 (mu4e-sent-folder . "/school/Sent")
405 (mu4e-drafts-folder . "/school/Drafts")
406 (mu4e-trash-folder . "/school/Trash")
407 (mu4e-refile-folder . "/school/Archive")
408 (user-mail-address . "abhojwani22@nobles.edu")
409 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
410 (smtpmail-smtp-server . "smtp.gmail.com")))
413 :enter-func (lambda () (mu4e-message "Entering personal context"))
414 :leave-func (lambda () (mu4e-message "Leaving personal context"))
415 :match-func (lambda (msg)
417 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
418 :vars '((mu4e-sent-folder . "/personal/Sent")
419 (mu4e-drafts-folder . "/personal/Drafts")
420 (mu4e-trash-folder . "/personal/Trash")
421 (mu4e-refile-folder . "/personal/Archive")
422 (user-mail-address . "me@armaanb.net")
423 (smtpmail-smtp-user . "me@armaanb.net")
424 (smtpmail-smtp-server "smtp.mailbox.org")
425 (mu4e-drafts-folder . "/school/Drafts")
426 (mu4e-trash-folder . "/school/Trash")))))
427 (add-to-list 'mu4e-bookmarks
428 '(:name "Unified inbox"
429 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
431 :hook ((mu4e-compose-mode . flyspell-mode)
432 (mu4e-view-mode-hook . turn-on-visual-line-mode)))
435 Set EWW as default browser except for videos.
436 #+begin_src emacs-lisp
437 (defun browse-url-mpv (url &optional new-window)
439 (start-process "mpv" "*mpv*" "mpv" url))
441 (setq browse-url-handlers
443 (("youtu\\.?be" . browse-url-mpv)
444 ("peertube.*" . browse-url-mpv)
445 ("vid.*" . browse-url-mpv)
446 ("vid.*" . browse-url-mpv)
447 ("." . eww-browse-url)
451 Some EWW enhancements.
452 *** Give buffer a useful name
453 #+begin_src emacs-lisp
454 ;; From https://protesilaos.com/dotemacs/
455 (defun prot-eww--rename-buffer ()
456 "Rename EWW buffer using page title or URL.
457 To be used by `eww-after-render-hook'."
458 (let ((name (if (eq "" (plist-get eww-data :title))
459 (plist-get eww-data :url)
460 (plist-get eww-data :title))))
461 (rename-buffer (format "*%s # eww*" name) t)))
463 (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
465 *** Better entrypoint
466 #+begin_src emacs-lisp
467 ;; From https://protesilaos.com/dotemacs/
468 (defun prot-eww-browse-dwim (url &optional arg)
469 "Visit a URL, maybe from `eww-prompt-history', with completion.
471 With optional prefix ARG (\\[universal-argument]) open URL in a
474 If URL does not look like a valid link, run a web query using
477 When called from an eww buffer, provide the current link as
481 (completing-read "Query:" eww-prompt-history
482 nil nil (plist-get eww-data :url) 'eww-prompt-history)
484 (eww url (if arg 4 nil)))
486 (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
489 #+begin_src emacs-lisp
491 :straight (:type built-in)
493 (load "~/.emacs.d/irc.el")
495 (erc-notifications-enable)
496 (erc-smiley-disable))
498 (use-package erc-hl-nicks
499 :config (erc-hl-nicks-mode 1))
502 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
503 =emacsclient --eval "(emacs-everywhere)"=.
504 #+begin_src emacs-lisp
505 (use-package emacs-everywhere)
509 #+begin_src emacs-lisp
511 :hook (python-mode . blacken-mode)
513 (setq blacken-line-length 79))
516 (use-package ws-butler
518 (ws-butler-global-mode))
521 #+begin_src emacs-lisp
522 (use-package flycheck
524 (global-flycheck-mode))
526 ** Project management
527 #+begin_src emacs-lisp
528 (use-package projectile
529 :config (projectile-mode)
530 :custom ((projectile-completion-system 'ivy))
532 ("C-c p" . projectile-command-map)
534 (when (file-directory-p "~/Code")
535 (setq projectile-project-search-path '("~/Code")))
536 (setq projectile-switch-project-action #'projectile-dired))
538 (use-package counsel-projectile
540 :config (counsel-projectile-mode))
543 #+begin_src emacs-lisp
545 :straight (:type built-in)
546 :commands (dired dired-jump)
547 :custom ((dired-listing-switches "-agho --group-directories-first"))
549 (evil-collection-define-key 'normal 'dired-mode-map
550 "h" 'dired-single-up-directory
551 "l" 'dired-single-buffer))
553 (use-package dired-single
554 :commands (dired dired-jump))
556 (use-package dired-open
557 :commands (dired dired-jump)
559 (dired-open-extensions '(("png" . "feh")
562 (use-package dired-hide-dotfiles
563 :hook (dired-mode . dired-hide-dotfiles-mode)
565 (evil-collection-define-key 'normal 'dired-mode-map
566 "H" 'dired-hide-dotfiles-mode))
570 # TODO: Write a command that commits hunk, skipping staging step.
571 #+begin_src emacs-lisp
574 *** Colored diff in line number area
575 #+begin_src emacs-lisp
577 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
578 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
579 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
580 :config (global-diff-hl-mode))
582 * General text editing
584 Indent after every change.
585 #+begin_src emacs-lisp
586 (use-package aggressive-indent
587 :config (global-aggressive-indent-mode))
590 Spell check in text mode, and in prog-mode comments.
591 #+begin_src emacs-lisp
592 (dolist (hook '(text-mode-hook))
593 (add-hook hook (lambda () (flyspell-mode))))
594 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
595 (add-hook hook (lambda () (flyspell-mode -1))))
596 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
598 ** Expand tabs to spaces
599 #+begin_src emacs-lisp
600 (setq-default tab-width 2)
602 ** Copy kill ring to clipboard
603 #+begin_src emacs-lisp
604 (setq x-select-enable-clipboard t)
605 (defun copy-kill-ring-to-xorg ()
606 "Copy the current kill ring to the xorg clipboard."
608 (x-select-text (current-kill 0)))
611 #+begin_src emacs-lisp
612 (use-package browse-kill-ring)
615 Opens file where you left it.
616 #+begin_src emacs-lisp
620 Distraction free writing a la junegunn/goyo.
621 #+begin_src emacs-lisp
622 (use-package olivetti
624 (evil-leader/set-key "o" 'olivetti-mode))
628 #+begin_src emacs-lisp
629 (setq abbrev-file-name "~/.emacs.d/abbrevs")
630 (setq save-abbrevs 'silent)
631 (setq-default abbrev-mode t)
634 #+begin_src emacs-lisp
635 (setq tramp-default-method "ssh")
637 ** Don't ask about following symlinks in vc
638 #+begin_src emacs-lisp
639 (setq vc-follow-symlinks t)
642 ** Easily convert splits
643 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
644 #+begin_src emacs-lisp
645 (defun toggle-window-split ()
647 (if (= (count-windows) 2)
648 (let* ((this-win-buffer (window-buffer))
649 (next-win-buffer (window-buffer (next-window)))
650 (this-win-edges (window-edges (selected-window)))
651 (next-win-edges (window-edges (next-window)))
652 (this-win-2nd (not (and (<= (car this-win-edges)
653 (car next-win-edges))
654 (<= (cadr this-win-edges)
655 (cadr next-win-edges)))))
657 (if (= (car this-win-edges)
658 (car (window-edges (next-window))))
659 'split-window-horizontally
660 'split-window-vertically)))
661 (delete-other-windows)
662 (let ((first-win (selected-window)))
664 (if this-win-2nd (other-window 1))
665 (set-window-buffer (selected-window) this-win-buffer)
666 (set-window-buffer (next-window) next-win-buffer)
667 (select-window first-win)
668 (if this-win-2nd (other-window 1))))))
670 (define-key ctl-x-4-map "t" 'toggle-window-split)
673 #+begin_src emacs-lisp
674 (defun insert-date ()
676 (insert (format-time-string "%Y-%m-%d")))
680 #+begin_src emacs-lisp
681 (use-package ace-window
682 :bind ("M-o" . ace-window))
684 ** Kill current buffer
685 Makes "C-x k" binding faster.
686 #+begin_src emacs-lisp
687 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
691 Render OpenSCAD files, and add a preview window.
693 Personal fork just merges a PR.
694 #+begin_src emacs-lisp
695 (use-package scad-mode)
696 (use-package scad-preview
697 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
699 ** Control backup files
700 Stop backup files from spewing everywhere.
701 #+begin_src emacs-lisp
702 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
704 ** Make yes/no easier
705 #+begin_src emacs-lisp
706 (defalias 'yes-or-no-p 'y-or-n-p)
708 ** Move customize file
709 No more clogging up init.el.
710 #+begin_src emacs-lisp
711 (setq custom-file "~/.emacs.d/custom.el")
715 #+begin_src emacs-lisp
717 :commands (helpful-callable helpful-variable helpful-command helpful-key)
719 (counsel-describe-function-function #'helpful-callable)
720 (counsel-describe-variable-function #'helpful-variable)
722 ([remap describe-function] . counsel-describe-function)
723 ([remap describe-command] . helpful-command)
724 ([remap describe-variable] . counsel-describe-variable)
725 ([remap describe-key] . helpful-key))
728 #+begin_src emacs-lisp
729 (use-package epa-file
730 :straight (:type built-in)
732 (epa-file-select-keys nil)
733 (epa-file-encrypt-to '("me@armaanb.net"))
734 (password-cache-expiry (* 60 15)))
736 (use-package pinentry
737 :config (pinentry-start))
740 #+begin_src emacs-lisp
742 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
743 :custom (0x0-default-service 'envs)
744 :config (evil-leader/set-key
746 "0f" '0x0-upload-file
747 "0s" '0x0-upload-string
748 "0c" '0x0-upload-kill-ring
749 "0p" '0x0-upload-popup))
754 #+begin_src conf :tangle ~/.spectrwm.conf
758 autorun = ws[1]:/home/armaa/Code/scripts/autostart
761 #+begin_src conf :tangle ~/.spectrwm.conf
763 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
767 #+begin_src conf :tangle ~/.spectrwm.conf
768 program[term] = alacritty
769 program[screenshot_all] = flameshot gui
770 program[notif] = /home/armaa/Code/scripts/setter status
775 #+begin_src conf :tangle ~/.spectrwm.conf
776 program[paup] = /home/armaa/Code/scripts/setter audio +5
777 program[padown] = /home/armaa/Code/scripts/setter audio -5
778 program[pamute] = /home/armaa/Code/scripts/setter audio
779 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
780 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
781 program[next] = playerctl next
782 program[prev] = playerctl previous
783 program[pause] = playerctl play-pause
785 bind[padown] = XF86AudioLowerVolume
786 bind[paup] = XF86AudioRaiseVolume
787 bind[pamute] = XF86AudioMute
788 bind[brigdown] = XF86MonBrightnessDown
789 bind[brigup] = XF86MonBrightnessUp
790 bind[pause] = XF86AudioPlay
791 bind[next] = XF86AudioNext
792 bind[prev] = XF86AudioPrev
795 #+begin_src conf :tangle ~/.spectrwm.conf
796 program[h] = xdotool keyup h key --clearmodifiers Left
797 program[j] = xdotool keyup j key --clearmodifiers Down
798 program[k] = xdotool keyup k key --clearmodifiers Up
799 program[l] = xdotool keyup l key --clearmodifiers Right
801 bind[h] = MOD + Control + h
802 bind[j] = MOD + Control + j
803 bind[k] = MOD + Control + k
804 bind[l] = MOD + Control + l
807 #+begin_src conf :tangle ~/.spectrwm.conf
808 program[aerc] = alacritty -e aerc
809 program[catgirl] = alacritty --hold -e sh -c "while : ; do ssh root@armaanb.net -t abduco -A irc catgirl freenode; sleep 2; done"
810 program[emacs] = emacsclient -c
811 program[firefox] = firefox
812 program[calc] = alacritty -e bc
813 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
815 bind[aerc] = MOD+Control+1
816 bind[catgirl] = MOD+Control+2
817 bind[firefox] = MOD+Control+3
818 bind[emacs-anywhere] = MOD+Control+4
819 bind[calc] = MOD+Control+5
820 bind[emacs] = MOD+Control+Return
825 #+begin_src shell :tangle ~/.config/zsh/zshrc
826 autoload -Uz compinit
830 unsetopt glob_complete
832 # Fragment completions
833 zstyle ':completion:*' list-suffixes
zstyle ':completion:*' expand prefix suffix
836 zstyle ':completion:*' menu select
837 zmodload zsh/complist
838 bindkey -M menuselect '^n' expand-or-complete
839 bindkey -M menuselect '^p' reverse-menu-complete
843 #+begin_src shell :tangle ~/.config/zsh/zshrc
847 bindkey -M vicmd "^[[3~" delete-char
848 bindkey "^[[3~" delete-char
850 autoload edit-command-line
851 zle -N edit-command-line
852 bindkey -M vicmd ^e edit-command-line
853 bindkey ^e edit-command-line
856 #+begin_src shell :tangle ~/.config/zsh/zshrc
857 setopt extended_history
859 setopt inc_append_history
860 setopt hist_ignore_dups
861 setopt hist_reduce_blanks
865 HISTFILE=~/.local/share/zsh/history
868 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
870 Right now, I'm only using fast-syntax-highlighting. It's a really nice visual addition.
872 #+begin_src conf :tangle ~/.config/zpe/repositories
873 https://github.com/zdharma/fast-syntax-highlighting
876 #+begin_src shell :tangle ~/.config/zsh/zshrc
877 source ~/Code/zpe/zpe.sh
878 source ~/Code/admone/admone.zsh
879 source ~/.config/zsh/fzf-bindings.zsh
881 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
884 **** Time Zsh startup
885 #+begin_src shell :tangle ~/.config/zsh/zshrc
887 for i in $(seq 1 10); do time "$1" -i -c exit; done
890 **** Update all packages
891 #+begin_src shell :tangle ~/.config/zsh/zshrc
892 color=$(tput setaf 5)
896 sudo echo "${color}== upgrading with yay ==${reset}"
899 echo "${color}== checking for pacnew files ==${reset}"
902 echo "${color}== upgrading flatpaks ==${reset}"
905 echo "${color}== upgrading zsh plugins ==${reset}"
908 echo "${color}== updating nvim plugins ==${reset}"
909 nvim +PlugUpdate +PlugUpgrade +qall
910 echo "Updated nvim plugins"
912 echo "${color}You are entirely up to date!${reset}"
915 **** Clean all packages
916 #+begin_src shell :tangle ~/.config/zsh/zshrc
918 sudo echo "${color}== cleaning pacman orphans ==${reset}"
919 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
921 echo "${color}== cleaning flatpaks ==${reset}"
922 flatpak remove --unused
924 echo "${color}== cleaning zsh plugins ==${reset}"
927 echo "${color}== cleaning nvim plugins ==${reset}"
928 nvim +PlugClean +qall
929 echo "Cleaned nvim plugins"
931 echo "${color}All orphans cleaned!${reset}"
935 #+begin_src shell :tangle ~/.config/zsh/zshrc
937 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
938 if [ $? -eq 0 ]; then
939 eval "$__conda_setup"
941 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
942 . "/opt/anaconda/etc/profile.d/conda.sh"
944 export PATH="/opt/anaconda/bin:$PATH"
950 **** Interact with 0x0
951 #+begin_src shell :tangle ~/.config/zsh/zshrc
952 zxz="https://envs.sh"
953 0file() { curl -F"file=@$1" "$zxz" ; }
954 0pb() { curl -F"file=@-;" "$zxz" ; }
955 0url() { curl -F"url=$1" "$zxz" ; }
956 0short() { curl -F"shorten=$1" "$zxz" ; }
957 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
960 #+begin_src shell :tangle ~/.config/zsh/zshrc
962 user=$(echo "$1" | cut -f 1 -d '@')
963 host=$(echo "$1" | cut -f 2 -d '@')
964 echo $user | nc "$host" 79 -N
967 **** Upload to ftp.armaanb.net
968 #+begin_src shell :tangle ~/.config/zsh/zshrc
970 rsync "$1" "root@armaanb.net:/var/ftp/pub/${2}"
971 echo "https://ftp.armaanb.net/pub/"$(basename "$1") | tee /dev/tty | xclip -sel c
976 #+begin_src shell :tangle ~/.config/zsh/zshrc
977 alias bhoji-drop='ssh -p 23 root@armaanb.net'
978 alias catgirl='ssh root@armaanb.net -t abduco -A irc catgirl freenode'
979 alias union='ssh 192.168.1.18'
980 alias mine='ssh -p 23 root@pickupserver.cc'
981 alias tcf='ssh root@204.48.23.68'
982 alias ngmun='ssh root@157.245.89.25'
983 alias prox='ssh root@192.168.1.224'
984 alias ncq='ssh root@143.198.123.17'
985 alias dock='ssh root@192.168.1.225'
986 alias jenkins='ssh root@192.168.1.226'
987 alias envs='ssh acheam@envs.net'
990 #+begin_src shell :tangle ~/.config/zsh/zshrc
991 alias ls='exa -lh --icons --git --group-directories-first'
992 alias la='exa -lha --icons --git --group-directories-first'
993 alias df='df -h / /boot'
1000 alias grep='grep -in --exclude-dir=.git --color=auto'
1001 alias fname='find -name'
1002 alias mkdir='mkdir -pv'
1003 alias unar='atool -x'
1004 alias wget='wget -e robots=off'
1005 alias lanex='~/.local/share/lxc/lxc'
1008 #+begin_src shell :tangle ~/.config/zsh/zshrc
1011 alias vw="nvim ~/Documents/vimwiki/index.md"
1013 **** System management
1014 #+begin_src shell :tangle ~/.config/zsh/zshrc
1015 alias jctl='journalctl -p 3 -xb'
1016 alias pkill='pkill -i'
1018 alias redoas='doas $(fc -ln -1)'
1019 alias crontab='crontab-argh'
1020 alias sudo='doas ' # allows aliases to be run with doas
1021 alias pasc='pass -c'
1022 alias pasu='\pass git push'
1023 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1027 #+begin_src shell :tangle ~/.config/zsh/zshrc
1028 alias ping='ping -c 10'
1029 alias speed='speedtest-cli'
1030 alias ip='ip --color=auto'
1031 alias cip='curl https://armaanb.net/ip'
1032 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1033 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1034 alias plan='T=$(mktemp) && \
1035 rsync root@armaanb.net:/etc/finger/plan.txt "$T" && \
1037 head -n -2 $T > $TT && \
1039 echo "\nLast updated: $(date -R)" >> "$TT" && \
1040 rsync "$TT" root@armaanb.net:/etc/finger/plan.txt'
1041 alias wttr='curl -s "wttr.in/02445?n" | head -n -3'
1044 #+begin_src shell :tangle ~/.config/zsh/zshrc
1045 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1046 iflag=fullblock status=progress'
1047 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1048 iflag=fullblock status=progress'
1049 alias ts='gen-shell -c task'
1050 alias ts='gen-shell -c task'
1051 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1052 alias news='newsboat'
1053 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1054 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1055 --restrict-filenames -o '%(title)s.%(ext)s'"
1056 alias cal="cal -3 --color=auto"
1059 **** Virtual machines, chroots
1060 #+begin_src shell :tangle ~/.config/zsh/zshrc
1061 alias ckiss="sudo chrooter ~/Virtual/kiss"
1062 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1063 alias cwindows='devour qemu-system-x86_64 \
1068 -device VGA,vgamem_mb=64 \
1070 -device hda-duplex \
1072 -net user,smb=/home/armaa/Public \
1073 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1076 #+begin_src shell :tangle ~/.config/zsh/zshrc
1078 alias zpy="zconda && ipython"
1079 alias math="ipython --profile=math"
1080 alias pypi="python setup.py sdist && twine upload dist/*"
1081 alias pip="python -m pip"
1082 alias black="black -l 79"
1085 #+begin_src shell :tangle ~/.config/zsh/zshrc
1086 alias words='gen-shell -c "words"'
1087 alias words-e='gen-shell -c "words ~E"'
1090 #+begin_src shell :tangle ~/.config/zsh/zshrc
1091 alias zathura='devour zathura'
1092 alias mpv='devour mpv'
1093 alias sql='devour sqlitebrowser'
1094 alias cad='devour openscad'
1095 alias feh='devour feh'
1097 **** Package management (Pacman)
1098 #+begin_src shell :tangle ~/.config/zsh/zshrc
1100 alias api='yay -Syu'
1101 alias apii='sudo pacman -S'
1102 alias app='yay -Rns'
1104 alias apo='yay -Qttd'
1105 alias azf='pacman -Q | fzf'
1106 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1107 alias ufetch='ufetch-arch'
1108 alias reflect='reflector --verbose --sort rate --save \
1109 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1111 **** Package management (KISS)
1112 #+begin_src shell :tangle ~/.config/zsh/zshrc
1113 alias kzf="kiss s \* | xargs -l basename | \
1114 fzf --preview 'kiss search {} | xargs -l dirname'"
1117 #+begin_src shell :tangle ~/.config/zsh/zshrc
1118 export EDITOR="emacsclient -c"
1119 export VISUAL="$EDITOR"
1120 export TERM=xterm-256color # for compatability
1122 export GPG_TTY="$(tty)"
1123 export MANPAGER='nvim +Man!'
1126 export GTK_USE_PORTAL=1
1128 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1129 export PATH="/home/armaa/Code/scripts:$PATH" # prioritize my scripts
1130 export PATH="/home/armaa/Code/scripts/bin:$PATH" # prioritize my bins
1131 export PATH="$PATH:/home/armaa/.cargo/bin"
1132 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1133 export PATH="$PATH:/usr/sbin"
1134 export PATH="$PATH:/opt/FreeTube/freetube"
1136 export LC_ALL="en_US.UTF-8"
1137 export LC_CTYPE="en_US.UTF-8"
1138 export LANGUAGE="en_US.UTF-8"
1140 export KISS_PATH="/home/armaa/Virtual/kiss/home/armaa/kiss-repo"
1141 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1142 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1143 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1144 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1145 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1149 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1152 family: JetBrains Mono Nerd Font
1159 ligatures: true # Requires ligature patch
1166 background_opacity: 1
1169 Modus vivendi. Source: https://github.com/ishan9299/Nixos/blob/d4bbb7536be95b59466bb9cca4d671be46e04e81/user/alacritty/alacritty.yml#L30-L118
1170 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1174 background: '#000000'
1175 foreground: '#ffffff'
1179 background: '#ffffff'
1181 # Normal colors (except green it is from intense colors)
1192 # Bright colors [all the faint colors in the modus theme]
1203 # dim [all the intense colors in modus theme]
1216 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1217 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1218 c.TerminalInteractiveShell.editing_mode = 'vi'
1219 c.InteractiveShell.colors = 'linux'
1220 c.TerminalInteractiveShell.confirm_exit = False
1223 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1227 return x * (180 / pi)
1230 return x * (pi / 180)
1233 return (x * (pi / 180)) / unit
1245 Make MPV play a little bit smoother.
1246 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1247 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1251 For any GNU Readline programs
1252 #+begin_src conf :tangle ~/.inputrc
1257 #+begin_src conf :tangle ~/.gitconfig
1259 name = Armaan Bhojwani
1260 email = me@armaanb.net
1261 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1264 #+begin_src conf :tangle ~/.gitconfig
1266 defaultBranch = main
1269 #+begin_src conf :tangle ~/.gitconfig
1274 #+begin_src conf :tangle ~/.gitconfig
1276 smtpserver = smtp.mailbox.org
1277 smtpuser = me@armaanb.net
1278 smtpencryption = ssl
1279 smtpserverport = 465
1283 #+begin_src conf :tangle ~/.gitconfig
1288 #+begin_src conf :tangle ~/.gitconfig
1291 sclone = clone --depth 1
1297 subup = submodule update --remote
1298 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1299 mirror = git config --global alias.mirrormirror
1302 #+begin_src conf :tangle ~/.gitconfig
1308 Lightweight notification daemon.
1310 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1312 font = "JetBrains Mono Medium Nerd Font 11"
1314 format = "<b>%s</b>\n%b"
1316 indicate_hidden = yes
1319 show_age_threshold = 60
1322 geometry = "400x5-10+10"
1324 idle_threshold = 120
1326 sticky_history = yes
1328 separator_height = 1
1330 horizontal_padding = 8
1332 separator_color = "#ffffff"
1333 startup_notification = false
1336 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1343 close_all = mod4+shift+c
1344 history = mod4+ctrl+c
1347 background = "#222222"
1348 foreground = "#ffffff"
1349 highlight = "#ffffff"
1353 background = "#222222"
1354 foreground = "#ffffff"
1355 highlight = "#ffffff"
1359 background = "#222222"
1360 foreground = "#a60000"
1361 highlight = "#ffffff"
1366 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1368 map <A-b> toggle_statusbar
1369 set selection-clipboard clipboard
1372 set window-title-basename "true"
1373 set selection-clipboard "clipboard"
1376 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1377 set default-bg "#000000"
1378 set default-fg "#ffffff"
1379 set render-loading true
1380 set render-loading-bg "#000000"
1381 set render-loading-fg "#ffffff"
1383 set recolor-lightcolor "#000000" # bg
1384 set recolor-darkcolor "#ffffff" # fg
1388 *** Swap tab and URL bars
1389 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1391 -moz-box-ordinal-group: 1 !important;
1395 -moz-box-ordinal-group: 2 !important;
1399 -moz-box-ordinal-group: 3 !important;
1402 *** Hide URL bar when not focused.
1403 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1404 #navigator-toolbox:not(:focus-within):not(:hover) {
1408 #navigator-toolbox {
1409 transition: 0.1s margin-top ease-out;
1412 ** Black screen by default
1413 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1416 #browser vbox#appcontent tabbrowser,
1418 #tabbrowser-tabpanels,
1420 browser[type="content-primary"],
1421 browser[type="content"] > html,
1423 background: black !important;
1424 color: #fff !important;
1427 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css
1428 @-moz-document url("about:home"), url("about:blank"), url("about:newtab") {
1430 background: black !important;
1436 #+begin_src conf :tangle ~/.Xresources
1437 XTerm.vt100.translations: #override \n\
1438 Ctrl <Key> minus: smaller-vt-font() \n\
1439 Ctrl <Key> plus: larger-vt-font()
1443 #+begin_src conf :tangle ~/.Xresources
1445 ,*.foreground: #ffffff
1446 ,*.background: #000000
1447 ,*.cursorColor: #ffffff
1482 #+begin_src conf :tangle ~/.Xresources
1483 xterm*VT100.Translations: #override \
1484 Shift <KeyPress> Insert: insert-selection(CLIPBOARD) \n\
1485 Ctrl Shift <Key>V: insert-selection(CLIPBOARD) \n\
1486 Ctrl Shift <Key>C: copy-selection(CLIPBOARD) \n\
1487 Ctrl <Btn1Up>: exec-formatted("xdg-open '%t'", PRIMARY)
1490 #+begin_src conf :tangle ~/.Xresources
1491 xterm*cursorBlink: true
1494 #+begin_src conf :tangle ~/.Xresources
1495 XTerm*eightBitInput: false
1496 XTerm*eightBitOutput: true