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)
62 Great programming font with ligatures.
63 #+begin_src emacs-lisp
64 (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
67 #+begin_src emacs-lisp
69 :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
71 (ligature-set-ligatures
72 '(prog-mode text-mode)
73 '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "/=" "/=="
74 "/>" "//" "/*" "*>" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
75 "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>"
76 "<-|" "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>"
77 "</" "<*" "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>"
78 ":=" "::=" "=>>" "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!=="
79 "!!" "!=" ">]" ">:" ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&"
80 "&&" "|||>" "||>" "|>" "|]" "|}" "|=>" "|->" "|=" "||-" "|-"
81 "||=" "||" ".." ".?" ".=" ".-" "..<" "..." "+++" "+>" "++"
82 "[||]" "[<" "[|" "{|" "??" "?." "?=" "?:" "##" "###" "####"
83 "#[" "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_" "__"
84 "~~" "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
85 (global-ligature-mode t))
88 #+begin_src emacs-lisp
90 :config (global-emojify-mode))
92 ;; http://ergoemacs.org/emacs/emacs_list_and_set_font.html
97 ((member "Twitter Color Emoji" (font-family-list)) "Twitter Color Emoji")
98 ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
99 ((member "Noto Emoji" (font-family-list)) "Noto Emoji")))
102 Display relative line numbers except in some modes
103 #+begin_src emacs-lisp
104 (global-display-line-numbers-mode)
105 (setq display-line-numbers-type 'relative)
106 (dolist (no-line-num '(term-mode-hook
111 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
113 ** Highlight matching parenthesis
114 #+begin_src emacs-lisp
116 :config (show-paren-mode)
117 :custom (show-paren-style 'parenthesis))
120 *** Show current function
121 #+begin_src emacs-lisp
122 (which-function-mode)
124 *** Make position in file more descriptive
125 Show current column and file size.
126 #+begin_src emacs-lisp
128 (size-indication-mode)
131 #+begin_src emacs-lisp
133 :config (minions-mode))
136 #+begin_src emacs-lisp
138 :straight (wc-mode :type git :host github :repo "bnbeckwith/wc-mode")
139 :hook (text-mode-hook . wc-mode))
142 Show a ruler at a certain number of chars depending on mode.
143 #+begin_src emacs-lisp
144 (global-display-fill-column-indicator-mode)
147 Whenever starting a key chord, show possible future steps.
148 #+begin_src emacs-lisp
149 (use-package which-key
150 :config (which-key-mode)
151 :custom (which-key-idle-delay 0.3))
153 ** Visual highlights of changes
154 Highlight when changes are made.
155 #+begin_src emacs-lisp
156 (use-package evil-goggles
157 :config (evil-goggles-mode)
158 (evil-goggles-use-diff-faces))
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)
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 '("ro" . "src plain :tangle ~/.config/rofi/config.rasi"))
301 (add-to-list 'org-structure-template-alist '("za" . "src plain :tangle ~/.config/zathura/zathurarc")))
304 #+begin_src emacs-lisp
305 (use-package org-present
306 :straight (org-present :type git :host github :repo "rlister/org-present"))
310 Simple, but not too simple autocompletion.
311 #+begin_src emacs-lisp
313 :bind (("C-s" . swiper)
314 :map ivy-minibuffer-map
315 ("TAB" . ivy-alt-done)
316 :map ivy-switch-buffer-map
317 ("M-d" . ivy-switch-buffer-kill))
321 #+begin_src emacs-lisp
322 (use-package ivy-rich
324 :config (ivy-rich-mode))
328 #+begin_src emacs-lisp
330 :bind (("C-M-j" . 'counsel-switch-buffer)
331 :map minibuffer-local-map
332 ("C-r" . 'counsel-minibuffer-history))
333 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
334 :config (counsel-mode))
336 ** Remember frequent commands
337 #+begin_src emacs-lisp
338 (use-package ivy-prescient
341 (ivy-prescient-enable-filtering nil)
343 (prescient-persist-mode)
344 (ivy-prescient-mode))
347 Better search utility.
348 #+begin_src emacs-lisp
353 Use elfeed for RSS. I have another file with all the feeds in it.
354 #+begin_src emacs-lisp
356 :bind (("C-c e" . elfeed))
358 (load "~/.emacs.d/feeds.el")
359 (add-hook 'elfeed-new-entry-hook
360 (elfeed-make-tagger :feed-url "youtube\\.com"
362 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
364 (use-package elfeed-goodies
366 :config (elfeed-goodies/setup))
369 Use mu4e for reading emails.
371 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.
373 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.
374 #+begin_src emacs-lisp
375 (use-package smtpmail
376 :straight (:type built-in))
378 :load-path "/usr/share/emacs/site-lisp/mu4e"
379 :bind (("C-c m" . mu4e))
381 (setq user-full-name "Armaan Bhojwani"
382 smtpmail-local-domain "armaanb.net"
383 smtpmail-stream-type 'ssl
384 smtpmail-smtp-service '465
385 mu4e-change-filenames-when-moving t
386 mu4e-get-mail-command "offlineimap -q"
387 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
388 message-citation-line-function 'message-insert-formatted-citation-line
389 mu4e-completing-read-function 'ivy-completing-read
390 mu4e-confirm-quit nil
391 mail-user-agent 'mu4e-user-agent
393 `( ,(make-mu4e-context
395 :enter-func (lambda () (mu4e-message "Entering school context"))
396 :leave-func (lambda () (mu4e-message "Leaving school context"))
397 :match-func (lambda (msg)
399 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
400 :vars '((user-mail-address . "abhojwani22@nobles.edu")
401 (mu4e-sent-folder . "/school/Sent")
402 (mu4e-drafts-folder . "/school/Drafts")
403 (mu4e-trash-folder . "/school/Trash")
404 (mu4e-refile-folder . "/school/Archive")
405 (user-mail-address . "abhojwani22@nobles.edu")
406 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
407 (smtpmail-smtp-server . "smtp.gmail.com")))
410 :enter-func (lambda () (mu4e-message "Entering personal context"))
411 :leave-func (lambda () (mu4e-message "Leaving personal context"))
412 :match-func (lambda (msg)
414 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
415 :vars '((mu4e-sent-folder . "/personal/Sent")
416 (mu4e-drafts-folder . "/personal/Drafts")
417 (mu4e-trash-folder . "/personal/Trash")
418 (mu4e-refile-folder . "/personal/Archive")
419 (user-mail-address . "me@armaanb.net")
420 (smtpmail-smtp-user . "me@armaanb.net")
421 (smtpmail-smtp-server "smtp.mailbox.org")
422 (mu4e-drafts-folder . "/school/Drafts")
423 (mu4e-trash-folder . "/school/Trash")))))
424 (add-to-list 'mu4e-bookmarks
425 '(:name "Unified inbox"
426 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
428 :hook ((mu4e-compose-mode . flyspell-mode)
429 (mu4e-view-mode-hook . turn-on-visual-line-mode)))
432 #+begin_src emacs-lisp
434 (use-package calfw-org)
435 (use-package calfw-ical)
437 (defun acheam-calendar ()
440 (shell-command "vdirsyncer sync")
441 (let ((default-directory "~/.local/share/vdirsyncer/"))
442 (cfw:open-calendar-buffer
445 (cfw:ical-create-source "School" (expand-file-name "school/abhojwani22@nobles.edu.ics") "Green")
446 (cfw:ical-create-source "Personal" (expand-file-name "mailbox/Y2FsOi8vMC8zMQ.ics") "Blue")
447 (cfw:ical-create-source "Birthdays" (expand-file-name "mailbox/Y2FsOi8vMS8w.ics") "Gray")
451 Another file has more specific network configuration.
452 #+begin_src emacs-lisp
454 :config (load-file "~/.emacs.d/irc.el"))
456 (use-package circe-chanop
457 :straight (:type built-in)
460 (use-package circe-color-nicks
461 :straight (:type built-in)
465 Set EWW as default browser except for videos.
466 #+begin_src emacs-lisp
467 (defun browse-url-mpv (url &optional new-window)
469 (start-process "mpv" "*mpv*" "mpv" url))
471 (setq browse-url-handlers
473 (("youtu\\.?be" . browse-url-mpv)
474 ("." . eww-browse-url)
478 Some EWW enhancements.
479 *** Give buffer a useful name
480 #+begin_src emacs-lisp
481 ;; From https://protesilaos.com/dotemacs/
482 (defun prot-eww--rename-buffer ()
483 "Rename EWW buffer using page title or URL.
484 To be used by `eww-after-render-hook'."
485 (let ((name (if (eq "" (plist-get eww-data :title))
486 (plist-get eww-data :url)
487 (plist-get eww-data :title))))
488 (rename-buffer (format "*%s # eww*" name) t)))
490 (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
492 *** Better entrypoint
493 #+begin_src emacs-lisp
494 ;; From https://protesilaos.com/dotemacs/
495 (defun prot-eww-browse-dwim (url &optional arg)
496 "Visit a URL, maybe from `eww-prompt-history', with completion.
498 With optional prefix ARG (\\[universal-argument]) open URL in a
501 If URL does not look like a valid link, run a web query using
504 When called from an eww buffer, provide the current link as
508 (completing-read "Query:" eww-prompt-history
509 nil nil (plist-get eww-data :url) 'eww-prompt-history)
511 (eww url (if arg 4 nil)))
513 (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
516 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
517 =emacsclient --eval "(emacs-everywhere)"=.
518 #+begin_src emacs-lisp
519 (use-package emacs-everywhere)
522 #+begin_src emacs-lisp
523 (setq eshell-prompt-function
526 "\n" (eshell/pwd) " ➤ ")
527 'face '(:foreground "cyan")))
528 eshell-highlight-prompt nil)
532 #+begin_src emacs-lisp
534 :hook (python-mode . blacken-mode)
536 (setq blacken-line-length 79))
539 (use-package ws-butler
541 (ws-butler-global-mode))
544 #+begin_src emacs-lisp
545 (use-package flycheck
547 (global-flycheck-mode))
549 ** Project management
550 #+begin_src emacs-lisp
551 (use-package projectile
552 :config (projectile-mode)
553 :custom ((projectile-completion-system 'ivy))
555 ("C-c p" . projectile-command-map)
557 (when (file-directory-p "~/Code")
558 (setq projectile-project-search-path '("~/Code")))
559 (setq projectile-switch-project-action #'projectile-dired))
561 (use-package counsel-projectile
563 :config (counsel-projectile-mode))
566 #+begin_src emacs-lisp
568 :straight (:type built-in)
569 :commands (dired dired-jump)
570 :custom ((dired-listing-switches "-agho --group-directories-first"))
572 (evil-collection-define-key 'normal 'dired-mode-map
573 "h" 'dired-single-up-directory
574 "l" 'dired-single-buffer))
576 (use-package dired-single
577 :commands (dired dired-jump))
579 (use-package dired-open
580 :commands (dired dired-jump)
582 (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))
605 * General text editing
607 Indent after every change.
608 #+begin_src emacs-lisp
609 (use-package aggressive-indent
610 :config (global-aggressive-indent-mode))
613 Spell check in text mode, and in prog-mode comments.
614 #+begin_src emacs-lisp
615 (dolist (hook '(text-mode-hook))
616 (add-hook hook (lambda () (flyspell-mode))))
617 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
618 (add-hook hook (lambda () (flyspell-mode -1))))
619 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
621 ** Expand tabs to spaces
622 #+begin_src emacs-lisp
623 (setq-default tab-width 2)
625 ** Copy kill ring to clipboard
626 #+begin_src emacs-lisp
627 (setq x-select-enable-clipboard t)
628 (defun copy-kill-ring-to-xorg ()
629 "Copy the current kill ring to the xorg clipboard."
631 (x-select-text (current-kill 0)))
634 #+begin_src emacs-lisp
635 (use-package browse-kill-ring)
638 Opens file where you left it.
639 #+begin_src emacs-lisp
643 Distraction free writing a la junegunn/goyo.
644 #+begin_src emacs-lisp
645 (use-package olivetti
647 (evil-leader/set-key "o" 'olivetti-mode))
651 #+begin_src emacs-lisp
652 (setq abbrev-file-name "~/.emacs.d/abbrevs")
653 (setq save-abbrevs 'silent)
654 (setq-default abbrev-mode t)
657 #+begin_src emacs-lisp
658 (setq tramp-default-method "ssh")
660 ** Don't ask about following symlinks in vc
661 #+begin_src emacs-lisp
662 (setq vc-follow-symlinks t)
665 ** Easily convert splits
666 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
667 #+begin_src emacs-lisp
668 (defun toggle-window-split ()
670 (if (= (count-windows) 2)
671 (let* ((this-win-buffer (window-buffer))
672 (next-win-buffer (window-buffer (next-window)))
673 (this-win-edges (window-edges (selected-window)))
674 (next-win-edges (window-edges (next-window)))
675 (this-win-2nd (not (and (<= (car this-win-edges)
676 (car next-win-edges))
677 (<= (cadr this-win-edges)
678 (cadr next-win-edges)))))
680 (if (= (car this-win-edges)
681 (car (window-edges (next-window))))
682 'split-window-horizontally
683 'split-window-vertically)))
684 (delete-other-windows)
685 (let ((first-win (selected-window)))
687 (if this-win-2nd (other-window 1))
688 (set-window-buffer (selected-window) this-win-buffer)
689 (set-window-buffer (next-window) next-win-buffer)
690 (select-window first-win)
691 (if this-win-2nd (other-window 1))))))
693 (define-key ctl-x-4-map "t" 'toggle-window-split)
696 #+begin_src emacs-lisp
697 (defun insert-date ()
699 (insert (format-time-string "%Y-%m-%d")))
703 #+begin_src emacs-lisp
704 (use-package ace-window
705 :bind ("M-o" . ace-window))
707 ** Kill current buffer
708 Makes "C-x k" binding faster.
709 #+begin_src emacs-lisp
710 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
714 Render OpenSCAD files, and add a preview window.
716 Personal fork just merges a PR.
717 #+begin_src emacs-lisp
718 (use-package scad-mode)
719 (use-package scad-preview
720 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
722 ** Control backup files
723 Stop backup files from spewing everywhere.
724 #+begin_src emacs-lisp
725 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
727 ** Make yes/no easier
728 #+begin_src emacs-lisp
729 (defalias 'yes-or-no-p 'y-or-n-p)
731 ** Move customize file
732 No more clogging up init.el.
733 #+begin_src emacs-lisp
734 (setq custom-file "~/.emacs.d/custom.el")
738 #+begin_src emacs-lisp
740 :commands (helpful-callable helpful-variable helpful-command helpful-key)
742 (counsel-describe-function-function #'helpful-callable)
743 (counsel-describe-variable-function #'helpful-variable)
745 ([remap describe-function] . counsel-describe-function)
746 ([remap describe-command] . helpful-command)
747 ([remap describe-variable] . counsel-describe-variable)
748 ([remap describe-key] . helpful-key))
751 #+begin_src emacs-lisp
752 (use-package epa-file
753 :straight (:type built-in)
755 (epa-file-select-keys nil)
756 (epa-file-encrypt-to '("me@armaanb.net"))
757 (password-cache-expiry (* 60 15)))
759 (use-package pinentry
760 :config (pinentry-start))
763 #+begin_src emacs-lisp
765 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
766 :custom (0x0-default-service 'envs)
767 :config (evil-leader/set-key
769 "0f" '0x0-upload-file
770 "0s" '0x0-upload-string
771 "0c" '0x0-upload-kill-ring
772 "0p" '0x0-upload-popup))
777 #+begin_src conf :tangle ~/.spectrwm.conf
782 autorun = ws[1]:/home/armaa/Code/scripts/autostart
785 #+begin_src conf :tangle ~/.spectrwm.conf
786 color_focus = rgb:ff/ff/ff
787 color_focus_maximized = rgb:ee/cc/00
788 color_unfocus = rgb:55/55/55
791 #+begin_src conf :tangle ~/.spectrwm.conf
793 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
797 #+begin_src conf :tangle ~/.spectrwm.conf
798 program[lock] = i3lock -c 000000 -ef
799 program[term] = alacritty
800 program[screenshot_all] = flameshot gui
801 program[menu] = rofi -show run # `rofi-dmenu` handles the rest
802 program[switcher] = rofi -show window
803 program[notif] = /home/armaa/Code/scripts/setter status
806 bind[switcher] = MOD+Tab
809 #+begin_src conf :tangle ~/.spectrwm.conf
810 program[paup] = /home/armaa/Code/scripts/setter audio +5
811 program[padown] = /home/armaa/Code/scripts/setter audio -5
812 program[pamute] = /home/armaa/Code/scripts/setter audio
813 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
814 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
815 program[next] = playerctl next
816 program[prev] = playerctl previous
817 program[pause] = playerctl play-pause
819 bind[padown] = XF86AudioLowerVolume
820 bind[paup] = XF86AudioRaiseVolume
821 bind[pamute] = XF86AudioMute
822 bind[brigdown] = XF86MonBrightnessDown
823 bind[brigup] = XF86MonBrightnessUp
824 bind[pause] = XF86AudioPlay
825 bind[next] = XF86AudioNext
826 bind[prev] = XF86AudioPrev
829 #+begin_src conf :tangle ~/.spectrwm.conf
830 program[h] = xdotool keyup h key --clearmodifiers Left
831 program[j] = xdotool keyup j key --clearmodifiers Down
832 program[k] = xdotool keyup k key --clearmodifiers Up
833 program[l] = xdotool keyup l key --clearmodifiers Right
835 bind[h] = MOD + Control + h
836 bind[j] = MOD + Control + j
837 bind[k] = MOD + Control + k
838 bind[l] = MOD + Control + l
841 #+begin_src conf :tangle ~/.spectrwm.conf
842 program[aerc] = alacritty -e aerc
843 program[weechat] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat; sleep 2; done"
844 program[catgirl] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t catgirl; sleep 2; done"
845 program[emacs] = emacsclient -c
846 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
847 program[firefox] = firefox
848 program[thunderbird] = thunderbird
849 program[slack] = slack
851 bind[aerc] = MOD+Control+1
852 # bind[weechat] = MOD+Control+2
853 bind[catgirl] = MOD+Control+2
854 bind[emacs-anywhere] = MOD+Control+3
855 bind[firefox] = MOD+Control+4
856 bind[thunderbird] = MOD+Control+5
857 bind[slack] = MOD+Control+6
858 bind[emacs] = MOD+Control+Return
863 #+begin_src shell :tangle ~/.config/zsh/zshrc
864 autoload -Uz compinit
868 unsetopt glob_complete
871 #+begin_src shell :tangle ~/.config/zsh/zshrc
875 bindkey -M vicmd "^[[3~" delete-char
876 bindkey "^[[3~" delete-char
878 autoload edit-command-line
879 zle -N edit-command-line
880 bindkey -M vicmd ^e edit-command-line
881 bindkey ^e edit-command-line
884 #+begin_src shell :tangle ~/.config/zsh/zshrc
885 setopt extended_history
887 setopt inc_append_history
888 setopt hist_ignore_dups
889 setopt hist_reduce_blanks
893 HISTFILE=~/.local/share/zsh/history
896 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
898 #+begin_src plain :tangle ~/.config/zpe/repositories
899 https://github.com/Aloxaf/fzf-tab
900 https://github.com/zdharma/fast-syntax-highlighting
901 https://github.com/rupa/z
904 #+begin_src shell :tangle ~/.config/zsh/zshrc
905 source ~/Code/zpe/zpe.sh
906 source ~/Code/admone/admone.zsh
907 source ~/.config/zsh/fzf-bindings.zsh
909 zpe-source fzf-tab/fzf-tab.zsh
910 zstyle ':completion:*:descriptions' format '[%d]'
911 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
912 zstyle ':completion:*' completer _complete
913 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' \
914 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
916 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
917 export _Z_DATA="/home/armaa/.local/share/z"
921 **** Alert after long command
922 #+begin_src shell :tangle ~/.config/zsh/zshrc
924 notify-send --urgency=low -i ${(%):-%(?.terminal.error)} \
925 ${history[$HISTCMD]%[;&|][[:space:]]##alert}
928 **** Time Zsh startup
929 #+begin_src shell :tangle ~/.config/zsh/zshrc
931 for i in $(seq 1 10); do
932 time "zsh" -i -c exit;
936 **** Update all packages
937 #+begin_src shell :tangle ~/.config/zsh/zshrc
938 color=$(tput setaf 5)
942 sudo echo "${color}== upgrading with yay ==${reset}"
945 echo "${color}== checking for pacnew files ==${reset}"
948 echo "${color}== upgrading flatpaks ==${reset}"
951 echo "${color}== upgrading zsh plugins ==${reset}"
954 echo "${color}== updating nvim plugins ==${reset}"
955 nvim +PlugUpdate +PlugUpgrade +qall
956 echo "Updated nvim plugins"
958 echo "${color}You are entirely up to date!${reset}"
961 **** Clean all packages
962 #+begin_src shell :tangle ~/.config/zsh/zshrc
964 sudo echo "${color}== cleaning pacman orphans ==${reset}"
965 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
967 echo "${color}== cleaning flatpaks ==${reset}"
968 flatpak remove --unused
970 echo "${color}== cleaning zsh plugins ==${reset}"
973 echo "${color}== cleaning nvim plugins ==${reset}"
974 nvim +PlugClean +qall
975 echo "Cleaned nvim plugins"
977 echo "${color}All orphans cleaned!${reset}"
981 #+begin_src shell :tangle ~/.config/zsh/zshrc
984 exa -lh --icons --git --group-directories-first
988 #+begin_src shell :tangle ~/.config/zsh/zshrc
990 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
991 if [ $? -eq 0 ]; then
992 eval "$__conda_setup"
994 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
995 . "/opt/anaconda/etc/profile.d/conda.sh"
997 export PATH="/opt/anaconda/bin:$PATH"
1003 **** Interact with 0x0
1004 #+begin_src shell :tangle ~/.config/zsh/zshrc
1005 zxz="https://envs.sh"
1006 0file() { curl -F"file=@$1" "$zxz" ; }
1007 0pb() { curl -F"file=@-;" "$zxz" ; }
1008 0url() { curl -F"url=$1" "$zxz" ; }
1009 0short() { curl -F"shorten=$1" "$zxz" ; }
1010 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
1013 #+begin_src shell :tangle ~/.config/zsh/zshrc
1022 #+begin_src shell :tangle ~/.config/zsh/zshrc
1023 alias bhoji-drop='ssh -p 23 root@armaanb.net'
1024 alias weechat='ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat'
1025 alias catgirl='ssh -p 23 -t root@armaanb.net tmux attach-session -t catgirl'
1026 alias tcf='ssh root@204.48.23.68'
1027 alias ngmun='ssh root@157.245.89.25'
1028 alias prox='ssh root@192.168.1.224'
1029 alias ncq='ssh root@143.198.123.17'
1030 alias dock='ssh root@192.168.1.225'
1031 alias jenkins='ssh root@192.168.1.226'
1032 alias envs='ssh acheam@envs.net'
1034 **** File management
1035 #+begin_src shell :tangle ~/.config/zsh/zshrc
1036 alias ls='exa -lh --icons --git --group-directories-first'
1037 alias la='exa -lha --icons --git --group-directories-first'
1038 alias df='df -h / /boot'
1040 alias free='free -h'
1045 alias grep='grep -in --exclude-dir=.git --color=auto'
1046 alias mkdir='mkdir -pv'
1047 alias unar='atool -x'
1048 alias wget='wget -e robots=off'
1049 alias lanex='~/.local/share/lxc/lxc'
1052 #+begin_src shell :tangle ~/.config/zsh/zshrc
1053 alias padm='yadm --yadm-repo ~/Code/dotfiles/repo.git'
1054 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1056 alias padu='padm add -u && padm commit && padm push && yadu'
1059 #+begin_src shell :tangle ~/.config/zsh/zshrc
1062 alias vw="nvim ~/Documents/vimwiki/index.md"
1064 **** System management
1065 #+begin_src shell :tangle ~/.config/zsh/zshrc
1066 alias jctl='journalctl -p 3 -xb'
1067 alias pkill='pkill -i'
1069 alias redoas='doas $(fc -ln -1)'
1070 alias crontab='crontab-argh'
1071 alias sudo='doas ' # allows aliases to be run with doas
1074 #+begin_src shell :tangle ~/.config/zsh/zshrc
1075 alias ping='ping -c 10'
1076 alias speed='speedtest-cli'
1077 alias ip='ip --color=auto'
1078 alias cip='curl https://armaanb.net/ip'
1079 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1080 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1083 #+begin_src shell :tangle ~/.config/zsh/zshrc
1084 alias dc='docker-compose'
1085 alias dcdu='docker-compose down && docker-compose up -d'
1088 #+begin_src shell :tangle ~/.config/zsh/zshrc
1089 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1090 iflag=fullblock status=progress'
1091 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1092 iflag=fullblock status=progress'
1093 alias ts='gen-shell -c task'
1094 alias ts='gen-shell -c task'
1095 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1096 alias news='newsboat'
1097 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1098 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1099 --restrict-filenames -o '%(title)s.%(ext)s'"
1100 alias cal="cal -3 --color=auto"
1102 **** Virtual machines, chroots
1103 #+begin_src shell :tangle ~/.config/zsh/zshrc
1104 alias ckiss="sudo chrooter ~/Virtual/kiss"
1105 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1106 alias cwindows='devour qemu-system-x86_64 \
1111 -device VGA,vgamem_mb=64 \
1113 -device hda-duplex \
1115 -net user,smb=/home/armaa/Public \
1116 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1119 #+begin_src shell :tangle ~/.config/zsh/zshrc
1121 alias zpy="zconda && ipython"
1122 alias math="ipython --profile=math"
1123 alias pypi="python setup.py sdist && twine upload dist/*"
1124 alias pip="python -m pip"
1125 alias black="black -l 79"
1128 #+begin_src shell :tangle ~/.config/zsh/zshrc
1129 alias words='gen-shell -c "words"'
1130 alias words-e='gen-shell -c "words ~E"'
1133 #+begin_src shell :tangle ~/.config/zsh/zshrc
1134 alias zathura='devour zathura'
1135 alias mpv='devour mpv'
1136 alias sql='devour sqlitebrowser'
1137 alias cad='devour openscad'
1138 alias feh='devour feh'
1140 **** Package management (Pacman)
1141 #+begin_src shell :tangle ~/.config/zsh/zshrc
1143 alias api='yay -Syu'
1144 alias apii='sudo pacman -S'
1145 alias app='yay -Rns'
1147 alias apo='yay -Qttd'
1148 alias azf='pacman -Q | fzf'
1149 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1150 alias ufetch='ufetch-arch'
1151 alias reflect='reflector --verbose --sort rate --save \
1152 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1155 #+begin_src shell :tangle ~/.config/zsh/zshrc
1156 export EDITOR="emacsclient -c"
1157 export VISUAL="$EDITOR"
1158 export TERM=xterm-256color # for compatability
1160 export GPG_TTY="$(tty)"
1161 export MANPAGER='nvim +Man!'
1164 export GTK_USE_PORTAL=1
1166 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1167 export PATH="/home/armaa/Code/scripts:$PATH" # prioritize my scripts
1168 export PATH="/home/armaa/Code/scripts/bin:$PATH" # prioritize my bins
1169 export PATH="$PATH:/home/armaa/.cargo/bin"
1170 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1171 export PATH="$PATH:/usr/sbin"
1172 export PATH="$PATH:/opt/FreeTube/freetube"
1174 export LC_ALL="en_US.UTF-8"
1175 export LC_CTYPE="en_US.UTF-8"
1176 export LANGUAGE="en_US.UTF-8"
1178 export KISS_PATH="/home/armaa/kiss/home/armaa/kiss-repo"
1179 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1180 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1181 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1182 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1183 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1187 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1190 family: JetBrains Mono Nerd Font
1197 ligatures: true # Requires ligature patch
1204 background_opacity: 1
1207 Modus vivendi. Source: https://github.com/ishan9299/Nixos/blob/d4bbb7536be95b59466bb9cca4d671be46e04e81/user/alacritty/alacritty.yml#L30-L118
1208 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1212 background: '#000000'
1213 foreground: '#ffffff'
1217 background: '#ffffff'
1219 # Normal colors (except green it is from intense colors)
1230 # Bright colors [all the faint colors in the modus theme]
1241 # dim [all the intense colors in modus theme]
1254 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1255 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1256 c.TerminalInteractiveShell.editing_mode = 'vi'
1257 c.InteractiveShell.colors = 'linux'
1258 c.TerminalInteractiveShell.confirm_exit = False
1261 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1265 return x * (180 / pi)
1268 return x * (pi / 180)
1271 return (x * (pi / 180)) / unit
1283 Make MPV play a little bit smoother.
1284 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1285 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1289 For any GNU Readline programs
1290 #+begin_src plain :tangle ~/.inputrc
1295 #+begin_src conf :tangle ~/.gitconfig
1297 name = Armaan Bhojwani
1298 email = me@armaanb.net
1299 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1302 #+begin_src conf :tangle ~/.gitconfig
1304 defaultBranch = main
1307 #+begin_src conf :tangle ~/.gitconfig
1312 #+begin_src conf :tangle ~/.gitconfig
1314 smtpserver = smtp.mailbox.org
1315 smtpuser = me@armaanb.net
1316 smtpencryption = ssl
1317 smtpserverport = 465
1321 #+begin_src conf :tangle ~/.gitconfig
1326 #+begin_src conf :tangle ~/.gitconfig
1329 sclone = clone --depth 1
1335 subup = submodule update --remote
1336 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1337 mirror = git config --global alias.mirrormirror
1340 #+begin_src conf :tangle ~/.gitconfig
1346 Lightweight notification daemon.
1348 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1350 font = "JetBrains Mono Medium Nerd Font 11"
1352 format = "<b>%s</b>\n%b"
1354 indicate_hidden = yes
1357 show_age_threshold = 60
1360 geometry = "400x5-10+10"
1362 idle_threshold = 120
1364 sticky_history = yes
1366 separator_height = 4
1368 horizontal_padding = 8
1370 separator_color = "#ffffff"
1371 startup_notification = false
1374 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1381 close_all = mod4+shift+c
1382 history = mod4+ctrl+c
1385 background = "#222222"
1386 foreground = "#ffffff"
1387 highlight = "#ffffff"
1391 background = "#222222"
1392 foreground = "#ffffff"
1393 highlight = "#ffffff"
1397 background = "#222222"
1398 foreground = "#a60000"
1399 highlight = "#ffffff"
1403 Modus vivendi theme that extends DarkBlue.
1404 #+begin_src plain :tangle ~/.config/rofi/config.rasi
1405 @import "/usr/share/rofi/themes/DarkBlue.rasi"
1407 white: rgba ( 255, 255, 255, 100 % );
1409 selected-normal-background: @white;
1410 separatorcolor: @white;
1411 background: rgba ( 34, 34, 34, 100 % );
1420 #+begin_src plain :tangle ~/.config/zathura/zathurarc
1422 map <A-b> toggle_statusbar
1423 set selection-clipboard clipboard
1426 set window-title-basename "true"
1427 set selection-clipboard "clipboard"
1430 #+begin_src plain :tangle ~/.config/zathura/zathurarc
1431 set default-bg "#000000"
1432 set default-fg "#ffffff"
1433 set render-loading true
1434 set render-loading-bg "#000000"
1435 set render-loading-fg "#ffffff"
1437 set recolor-lightcolor "#000000" # bg
1438 set recolor-darkcolor "#ffffff" # fg