1 #+TITLE: System Configuration
2 #+DESCRIPTION: Armaan's system configuration.
5 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!
7 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.
9 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.
11 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.
13 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.
15 *** TODO Turn keybinding and hook declarations into use-package declarations where possible
16 *** TODO Put configs with passwords in here with some kind of authentication
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-org-blocks 'grayscale
52 modus-themes-mode-line '3d
53 modus-themes-scale-headings t
54 modus-themes-region 'no-extend
55 modus-themes-diffs 'desaturated)
56 (load-theme 'modus-vivendi t)
60 Great programming font with ligatures.
61 #+begin_src emacs-lisp
62 (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
65 #+begin_src emacs-lisp
67 :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
69 (ligature-set-ligatures
70 '(prog-mode text-mode)
71 '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "///" "/=" "/=="
72 "/>" "//" "/*" "*>" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
73 "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>" "<-|"
74 "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>" "</" "<*"
75 "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>" ":=" "::=" "=>>"
76 "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!==" "!!" "!=" ">]" ">:"
77 ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&" "&&" "|||>" "||>" "|>" "|]"
78 "|}" "|=>" "|->" "|=" "||-" "|-" "||=" "||" ".." ".?" ".=" ".-" "..<"
79 "..." "+++" "+>" "++" "[||]" "[<" "[|" "{|" "??" "?." "?=" "?:" "##"
80 "###" "####" "#[" "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_"
81 "__" "~~" "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
82 (global-ligature-mode t))
85 #+begin_src emacs-lisp
87 :config (global-emojify-mode))
89 ;; http://ergoemacs.org/emacs/emacs_list_and_set_font.html
94 ((member "Twitter Color Emoji" (font-family-list)) "Twitter Color Emoji")
95 ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
96 ((member "Noto Emoji" (font-family-list)) "Noto Emoji")))
99 Display relative line numbers except in some modes
100 #+begin_src emacs-lisp
101 (global-display-line-numbers-mode)
102 (setq display-line-numbers-type 'relative)
103 (dolist (no-line-num '(term-mode-hook
108 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
110 ** Highlight matching parenthesis
111 #+begin_src emacs-lisp
113 :config (show-paren-mode)
114 :custom (show-paren-style 'parenthesis))
117 *** Show current function
118 #+begin_src emacs-lisp
119 (which-function-mode)
121 *** Make position in file more descriptive
122 Show current column and file size.
123 #+begin_src emacs-lisp
125 (size-indication-mode)
128 #+begin_src emacs-lisp
130 :config (minions-mode))
133 Show a ruler at a certain number of chars depending on mode.
134 #+begin_src emacs-lisp
135 (global-display-fill-column-indicator-mode)
138 Whenever starting a key chord, show possible future steps.
139 #+begin_src emacs-lisp
140 (use-package which-key
141 :config (which-key-mode)
142 :custom (which-key-idle-delay 0.3))
144 ** Visual highlights of changes
145 Highlight when changes are made.
146 #+begin_src emacs-lisp
147 (use-package evil-goggles
148 :config (evil-goggles-mode)
149 (evil-goggles-use-diff-faces))
151 ** Highlight TODOs in comments
152 #+begin_src emacs-lisp
154 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
155 :config (global-hl-todo-mode 1))
158 #+begin_src emacs-lisp
162 Soft wrap words and do operations by visual lines.
163 #+begin_src emacs-lisp
164 (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
166 ** Display number of matches in search
167 #+begin_src emacs-lisp
169 :config (global-anzu-mode))
172 Inverts modeline instead of audible bell or the standard visual bell.
173 #+begin_src emacs-lisp
174 (setq visible-bell nil
175 ring-bell-function 'flash-mode-line)
176 (defun flash-mode-line ()
177 (invert-face 'mode-line)
178 (run-with-timer 0.1 nil #'invert-face 'mode-line))
182 #+begin_src emacs-lisp
184 :custom (select-enable-clipboard nil)
187 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
188 ;; Use visual line motions even outside of visual-line-mode buffers
189 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
190 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
191 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
194 #+begin_src emacs-lisp
195 (use-package evil-collection
197 :init (evil-collection-init)
198 :custom (evil-collection-setup-minibuffer t))
202 #+begin_src emacs-lisp
203 (use-package evil-surround
204 :config (global-evil-surround-mode))
207 #+begin_src emacs-lisp
208 (use-package evil-leader
209 :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
211 (evil-leader/set-leader "<SPC>")
212 (global-evil-leader-mode))
215 #+begin_src emacs-lisp
217 (use-package evil-nerd-commenter
218 :bind (:map evil-normal-state-map
219 ("gc" . evilnc-comment-or-uncomment-lines))
220 :custom (evilnc-invert-comment-line-by-line nil))
223 Fix the oopsies! Maybe replace with undo-fu or Emacs 28 built in undo-redo.
224 #+begin_src emacs-lisp
225 (use-package undo-tree
227 (undo-tree-auto-save-history t)
228 (undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo-tree")))
230 (global-undo-tree-mode)
231 (evil-set-undo-system 'undo-tree))
233 ** Number incrementing
235 #+begin_src emacs-lisp
236 (use-package evil-numbers
237 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
238 :bind (:map evil-normal-state-map
239 ("C-M-a" . evil-numbers/inc-at-pt)
240 ("C-M-x" . evil-numbers/dec-at-pt)))
244 #+begin_src emacs-lisp
245 (use-package evil-org
247 :hook (org-mode . evil-org-mode)
249 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
250 (use-package evil-org-agenda
251 :straight (:type built-in)
254 (evil-org-agenda-set-keys))
257 #+begin_src emacs-lisp
258 (evil-leader/set-key-for-mode 'org-mode
259 "T" 'org-show-todo-tree
261 "c" 'org-archive-subtree)
265 #+begin_src emacs-lisp
267 :straight (:type built-in)
268 :commands (org-capture org-agenda)
271 (org-agenda-start-with-log-mode t)
272 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
274 (org-log-into-drawer t)
275 (org-src-tab-acts-natively t)
276 (org-src-fontify-natively t)
277 (org-startup-indented t)
278 (org-hide-emphasis-markers t)
279 (org-fontify-whole-block-delimiter-line nil)
280 :bind ("C-c a" . org-agenda))
283 #+begin_src emacs-lisp
284 (use-package org-tempo
286 :straight (:type built-in)
288 ;; TODO: There's gotta be a more efficient way to write this
289 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
290 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
291 (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
292 (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
293 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
294 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
295 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
296 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc")))
300 Simple, but not too simple autocompletion.
301 #+begin_src emacs-lisp
303 :bind (("C-s" . swiper)
304 :map ivy-minibuffer-map
305 ("TAB" . ivy-alt-done)
306 :map ivy-switch-buffer-map
307 ("M-d" . ivy-switch-buffer-kill))
311 #+begin_src emacs-lisp
312 (use-package ivy-rich
314 :config (ivy-rich-mode))
318 #+begin_src emacs-lisp
320 :bind (("C-M-j" . 'counsel-switch-buffer)
321 :map minibuffer-local-map
322 ("C-r" . 'counsel-minibuffer-history))
323 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
324 :config (counsel-mode))
326 ** Remember frequent commands
327 #+begin_src emacs-lisp
328 (use-package ivy-prescient
331 (ivy-prescient-enable-filtering nil)
333 (prescient-persist-mode)
334 (ivy-prescient-mode))
337 Better search utility.
338 #+begin_src emacs-lisp
343 Use elfeed for RSS. I have another file with all the feeds in it.
344 #+begin_src emacs-lisp
346 :bind (("C-c e" . elfeed))
348 (load "~/.emacs.d/feeds.el")
349 (add-hook 'elfeed-new-entry-hook
350 (elfeed-make-tagger :feed-url "youtube\\.com"
352 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
354 (use-package elfeed-goodies
356 :config (elfeed-goodies/setup))
359 Use mu4e for reading emails.
361 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.
363 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.
364 #+begin_src emacs-lisp
365 (use-package smtpmail
366 :straight (:type built-in))
368 :load-path "/usr/share/emacs/site-lisp/mu4e"
369 :bind (("C-c m" . mu4e))
371 (setq user-full-name "Armaan Bhojwani"
372 smtpmail-local-domain "armaanb.net"
373 smtpmail-stream-type 'ssl
374 smtpmail-smtp-service '465
375 mu4e-change-filenames-when-moving t
376 message-kill-buffer-on-exit t
377 mu4e-get-mail-command "offlineimap -q"
378 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
379 message-citation-line-function 'message-insert-formatted-citation-line
380 mu4e-context-policy "pick-first"
382 `( ,(make-mu4e-context
384 :enter-func (lambda () (mu4e-message "Entering school context"))
385 :leave-func (lambda () (mu4e-message "Leaving school context"))
386 :match-func (lambda (msg)
388 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
389 :vars '( (user-mail-address . "abhojwani22@nobles.edu")
390 (mu4e-sent-folder . "/school/Sent")
391 (mu4e-drafts-folder . "/school/Drafts")
392 (mu4e-trash-folder . "/school/Trash")
393 (mu4e-refile-folder . "/school/Archive")
394 (user-mail-address . "abhojwani22@nobles.edu")
395 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
396 (smtpmail-smtp-server . "smtp.gmail.com")))
399 :enter-func (lambda () (mu4e-message "Entering personal context"))
400 :leave-func (lambda () (mu4e-message "Leaving personal context"))
401 :match-func (lambda (msg)
403 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
405 (mu4e-sent-folder . "/personal/Sent")
406 (mu4e-drafts-folder . "/personal/Drafts")
407 (mu4e-trash-folder . "/personal/Trash")
408 (mu4e-refile-folder . "/personal/Archive")
409 (user-mail-address . "me@armaanb.net")
410 (smtpmail-smtp-user . "me@armaanb.net")
411 (smtpmail-smtp-server "smtp.mailbox.org")
412 (mu4e-drafts-folder . "/school/Drafts")
413 (mu4e-trash-folder . "/school/Trash")))))
414 (add-to-list 'mu4e-bookmarks
415 '(:name "Unified inbox"
416 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
420 #+begin_src emacs-lisp
422 (use-package calfw-org)
423 (use-package calfw-ical)
425 (defun acheam-calendar ()
428 (shell-command "vdirsyncer sync")
429 (let ((default-directory "~/.local/share/vdirsyncer/"))
430 (cfw:open-calendar-buffer
433 (cfw:ical-create-source "School" (expand-file-name "school/abhojwani22@nobles.edu.ics") "Green")
434 (cfw:ical-create-source "Personal" (expand-file-name "mailbox/Y2FsOi8vMC8zMQ.ics") "Blue")
435 (cfw:ical-create-source "Birthdays" (expand-file-name "mailbox/Y2FsOi8vMS8w.ics") "Gray")
439 Another file has more specific network configuration.
440 #+begin_src emacs-lisp
442 :config (load-file "~/.emacs.d/irc.el"))
444 (use-package circe-chanop
445 :straight (:type built-in)
448 (use-package circe-color-nicks
449 :straight (:type built-in)
453 Set EWW as default browser except for videos.
454 #+begin_src emacs-lisp
455 (defun browse-url-mpv (url &optional new-window)
457 (start-process "mpv" "*mpv*" "mpv" url))
459 (setq browse-url-handlers
461 (("youtu\\.?be" . browse-url-mpv)
462 ("." . eww-browse-url)
466 Some EWW enhancements.
467 *** Give buffer a useful name
468 #+begin_src emacs-lisp
469 ;; From https://protesilaos.com/dotemacs/
470 (defun prot-eww--rename-buffer ()
471 "Rename EWW buffer using page title or URL.
472 To be used by `eww-after-render-hook'."
473 (let ((name (if (eq "" (plist-get eww-data :title))
474 (plist-get eww-data :url)
475 (plist-get eww-data :title))))
476 (rename-buffer (format "*%s # eww*" name) t)))
478 (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
480 *** Better entrypoint
481 #+begin_src emacs-lisp
482 ;; From https://protesilaos.com/dotemacs/
483 (defun prot-eww-browse-dwim (url &optional arg)
484 "Visit a URL, maybe from `eww-prompt-history', with completion.
486 With optional prefix ARG (\\[universal-argument]) open URL in a
489 If URL does not look like a valid link, run a web query using
492 When called from an eww buffer, provide the current link as
496 (completing-read "Query:" eww-prompt-history
497 nil nil (plist-get eww-data :url) 'eww-prompt-history)
499 (eww url (if arg 4 nil)))
501 (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
504 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
505 "emacsclient --eval "(emacs-everywhere)".
506 #+begin_src emacs-lisp
507 (use-package emacs-everywhere)
512 #+begin_src emacs-lisp
513 (use-package lsp-mode
514 :commands (lsp lsp-deferred)
515 :custom (lsp-keymap-prefix "C-c l")
516 :hook ((lsp-mode . lsp-enable-which-key-integration)))
518 (use-package lsp-ivy)
521 :commands lsp-ui-mode
522 :custom (lsp-ui-doc-position 'bottom))
523 (use-package lsp-ui-flycheck
525 :straight (:type built-in))
528 Company-box adds icons.
529 #+begin_src emacs-lisp
532 :hook (lsp-mode . company-mode)
533 :bind (:map company-active-map
534 ("<tab>" . company-complete-selection))
536 ("<tab>" . company-indent-or-complete-common))
538 (company-minimum-prefix-length 1)
539 (setq company-dabbrev-downcase 0)
540 (company-idle-delay 0.0))
542 (use-package company-box
543 :hook (company-mode . company-box-mode))
547 #+begin_src emacs-lisp
548 (use-package lsp-pyright
549 :hook (python-mode . (lambda ()
550 (use-package lsp-pyright
551 :straight (:type built-in))
555 #+begin_src emacs-lisp
557 :hook (python-mode . blacken-mode)
559 (setq blacken-line-length 79))
562 (use-package ws-butler
564 (ws-butler-global-mode))
567 #+begin_src emacs-lisp
568 (use-package flycheck
570 (global-flycheck-mode))
572 ** Project management
573 #+begin_src emacs-lisp
574 (use-package projectile
575 :config (projectile-mode)
576 :custom ((projectile-completion-system 'ivy))
578 ("C-c p" . projectile-command-map)
580 (when (file-directory-p "~/Code")
581 (setq projectile-project-search-path '("~/Code")))
582 (setq projectile-switch-project-action #'projectile-dired))
584 (use-package counsel-projectile
586 :config (counsel-projectile-mode))
589 #+begin_src emacs-lisp
591 :straight (:type built-in)
592 :commands (dired dired-jump)
593 :custom ((dired-listing-switches "-agho --group-directories-first"))
595 (evil-collection-define-key 'normal 'dired-mode-map
596 "h" 'dired-single-up-directory
597 "l" 'dired-single-buffer))
599 (use-package dired-single
600 :commands (dired dired-jump))
602 (use-package dired-open
603 :commands (dired dired-jump)
605 (dired-open-extensions '(("png" . "feh")
608 (use-package dired-hide-dotfiles
609 :hook (dired-mode . dired-hide-dotfiles-mode)
611 (evil-collection-define-key 'normal 'dired-mode-map
612 "H" 'dired-hide-dotfiles-mode))
616 # TODO: Write a command that commits hunk, skipping staging step.
617 #+begin_src emacs-lisp
619 :hook (magit-mode-hook. pinentry-start))
621 *** Colored diff in line number area
622 #+begin_src emacs-lisp
624 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
625 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
626 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
627 :config (global-diff-hl-mode))
629 * General text editing
631 Indent after every change.
632 #+begin_src emacs-lisp
633 (use-package aggressive-indent
634 :config (global-aggressive-indent-mode))
637 Spell check in text mode, and in prog-mode comments.
638 #+begin_src emacs-lisp
639 (dolist (hook '(text-mode-hook))
640 (add-hook hook (lambda () (flyspell-mode))))
641 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
642 (add-hook hook (lambda () (flyspell-mode -1))))
643 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
645 ** Expand tabs to spaces
646 #+begin_src emacs-lisp
647 (setq-default tab-width 2)
649 ** Copy kill ring to clipboard
650 #+begin_src emacs-lisp
651 (setq x-select-enable-clipboard t)
652 (defun copy-kill-ring-to-xorg ()
653 "Copy the current kill ring to the xorg clipboard."
655 (x-select-text (current-kill 0)))
658 #+begin_src emacs-lisp
659 (use-package browse-kill-ring)
662 Opens file where you left it.
663 #+begin_src emacs-lisp
667 Distraction free writing a la junegunn/goyo.
668 #+begin_src emacs-lisp
669 (use-package olivetti
671 (evil-leader/set-key "o" 'olivetti-mode))
675 #+begin_src emacs-lisp
676 (setq abbrev-file-name "~/.emacs.d/abbrevs")
677 (setq save-abbrevs 'silent)
678 (setq-default abbrev-mode t)
681 #+begin_src emacs-lisp
682 (setq tramp-default-method "ssh")
685 ** Easily convert splits
686 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
687 #+begin_src emacs-lisp
688 (defun toggle-window-split ()
690 (if (= (count-windows) 2)
691 (let* ((this-win-buffer (window-buffer))
692 (next-win-buffer (window-buffer (next-window)))
693 (this-win-edges (window-edges (selected-window)))
694 (next-win-edges (window-edges (next-window)))
695 (this-win-2nd (not (and (<= (car this-win-edges)
696 (car next-win-edges))
697 (<= (cadr this-win-edges)
698 (cadr next-win-edges)))))
700 (if (= (car this-win-edges)
701 (car (window-edges (next-window))))
702 'split-window-horizontally
703 'split-window-vertically)))
704 (delete-other-windows)
705 (let ((first-win (selected-window)))
707 (if this-win-2nd (other-window 1))
708 (set-window-buffer (selected-window) this-win-buffer)
709 (set-window-buffer (next-window) next-win-buffer)
710 (select-window first-win)
711 (if this-win-2nd (other-window 1))))))
713 (define-key ctl-x-4-map "t" 'toggle-window-split)
716 #+begin_src emacs-lisp
717 (defun insert-date ()
719 (insert (format-time-string "%Y-%m-%d")))
723 #+begin_src emacs-lisp
724 (use-package ace-window
725 :bind ("M-o" . ace-window))
727 ** Kill current buffer
728 Makes "C-x k" binding faster.
729 #+begin_src emacs-lisp
730 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
734 Render OpenSCAD files, and add a preview window.
736 Personal fork just merges a PR.
737 #+begin_src emacs-lisp
738 (use-package scad-mode)
739 (use-package scad-preview
740 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
742 ** Control backup files
743 Stop backup files from spewing everywhere.
744 #+begin_src emacs-lisp
745 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
747 ** Make yes/no easier
748 #+begin_src emacs-lisp
749 (defalias 'yes-or-no-p 'y-or-n-p)
751 ** Move customize file
752 No more clogging up init.el.
753 #+begin_src emacs-lisp
754 (setq custom-file "~/.emacs.d/custom.el")
758 #+begin_src emacs-lisp
760 :commands (helpful-callable helpful-variable helpful-command helpful-key)
762 (counsel-describe-function-function #'helpful-callable)
763 (counsel-describe-variable-function #'helpful-variable)
765 ([remap describe-function] . counsel-describe-function)
766 ([remap describe-command] . helpful-command)
767 ([remap describe-variable] . counsel-describe-variable)
768 ([remap describe-key] . helpful-key))
771 #+begin_src emacs-lisp
772 (use-package epa-file
773 :straight (:type built-in))
774 (setq epa-file-select-keys nil
775 epa-file-encrypt-to '("me@armaanb.net")
776 password-cache-expiry (* 60 15))
778 (use-package pinentry)
781 #+begin_src emacs-lisp
783 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
784 :custom (0x0-default-service 'envs)
785 :config (evil-leader/set-key
787 "0f" '0x0-upload-file
788 "0s" '0x0-upload-string
789 "0c" '0x0-upload-kill-ring
790 "0p" '0x0-upload-popup))
795 #+begin_src conf :tangle ~/.spectrwm.conf
801 autorun = ws[1]:/home/armaa/Code/scripts/autostart
805 #+begin_src conf :tangle ~/.spectrwm.conf
806 color_focus = rgb:83/a5/98
807 color_focus_maximized = rgb:d6/5d/0e
808 color_unfocus = rgb:58/58/58
811 #+begin_src conf :tangle ~/.spectrwm.conf
813 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
817 #+begin_src conf :tangle ~/.spectrwm.conf
818 program[lock] = i3lock -c 000000 -ef
819 program[term] = alacritty
820 program[screenshot_all] = flameshot gui
821 program[menu] = rofi -show run # `rofi-dmenu` handles the rest
822 program[switcher] = rofi -show window
823 program[notif] = /home/armaa/Code/scripts/setter status
826 bind[switcher] = MOD+Tab
829 #+begin_src conf :tangle ~/.spectrwm.conf
830 program[paup] = /home/armaa/Code/scripts/setter audio +5
831 program[padown] = /home/armaa/Code/scripts/setter audio -5
832 program[pamute] = /home/armaa/Code/scripts/setter audio
833 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
834 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
835 program[next] = playerctl next
836 program[prev] = playerctl previous
837 program[pause] = playerctl play-pause
839 bind[padown] = XF86AudioLowerVolume
840 bind[paup] = XF86AudioRaiseVolume
841 bind[pamute] = XF86AudioMute
842 bind[brigdown] = XF86MonBrightnessDown
843 bind[brigup] = XF86MonBrightnessUp
844 bind[pause] = XF86AudioPlay
845 bind[next] = XF86AudioNext
846 bind[prev] = XF86AudioPrev
849 #+begin_src conf :tangle ~/.spectrwm.conf
850 program[h] = xdotool keyup h key --clearmodifiers Left
851 program[j] = xdotool keyup j key --clearmodifiers Down
852 program[k] = xdotool keyup k key --clearmodifiers Up
853 program[l] = xdotool keyup l key --clearmodifiers Right
855 bind[h] = MOD + Control + h
856 bind[j] = MOD + Control + j
857 bind[k] = MOD + Control + k
858 bind[l] = MOD + Control + l
861 #+begin_src conf :tangle ~/.spectrwm.conf
862 program[aerc] = alacritty -e aerc
863 program[weechat] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat; sleep 2; done"
864 program[emacs] = emacsclient -c
865 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
866 program[firefox] = firefox
867 program[thunderbird] = thunderbird
868 program[slack] = slack
870 bind[aerc] = MOD+Control+s
871 bind[weechat] = MOD+Control+d
872 bind[emacs] = MOD+Control+f
873 bind[emacs-anywhere] = MOD+f
874 bind[firefox] = MOD+Control+u
875 bind[thunderbird] = MOD+Control+i
876 bind[slack] = MOD+Control+o
881 #+begin_src shell :tangle ~/.config/zsh/zshrc
882 autoload -Uz compinit
886 unsetopt glob_complete
889 #+begin_src shell :tangle ~/.config/zsh/zshrc
893 bindkey -M vicmd "^[[3~" delete-char
894 bindkey "^[[3~" delete-char
896 autoload edit-command-line
897 zle -N edit-command-line
898 bindkey -M vicmd ^e edit-command-line
899 bindkey ^e edit-command-line
902 #+begin_src shell :tangle ~/.config/zsh/zshrc
903 setopt extended_history
905 setopt inc_append_history
906 setopt hist_ignore_dups
907 setopt hist_reduce_blanks
911 HISTFILE=~/.local/share/zsh/history
914 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
916 #+begin_src plain :tangle ~/.config/zpe/repositories
917 https://github.com/Aloxaf/fzf-tab
918 https://github.com/zdharma/fast-syntax-highlighting
919 https://github.com/rupa/z
922 #+begin_src shell :tangle ~/.config/zsh/zshrc
923 source ~/Code/zpe/zpe.sh
924 source ~/Code/admone/admone.zsh
925 source ~/.config/zsh/fzf-bindings.zsh
927 zpe-source fzf-tab/fzf-tab.zsh
928 zstyle ':completion:*:descriptions' format '[%d]'
929 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
930 zstyle ':completion:*' completer _complete
931 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' \
932 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
934 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
935 export _Z_DATA="/home/armaa/.local/share/z"
939 **** Alert after long command
940 #+begin_src shell :tangle ~/.config/zsh/zshrc
942 notify-send --urgency=low -i ${(%):-%(?.terminal.error)} \
943 ${history[$HISTCMD]%[;&|][[:space:]]##alert}
946 **** Time Zsh startup
947 #+begin_src shell :tangle ~/.config/zsh/zshrc
949 for i in $(seq 1 10); do
950 time "zsh" -i -c exit;
954 **** Update all packages
955 #+begin_src shell :tangle ~/.config/zsh/zshrc
956 color=$(tput setaf 5)
960 sudo echo "${color}== upgrading with yay ==${reset}"
963 echo "${color}== checking for pacnew files ==${reset}"
966 echo "${color}== upgrading flatpaks ==${reset}"
969 echo "${color}== upgrading zsh plugins ==${reset}"
972 echo "${color}== updating nvim plugins ==${reset}"
973 nvim +PlugUpdate +PlugUpgrade +qall
974 echo "Updated nvim plugins"
976 echo "${color}You are entirely up to date!${reset}"
979 **** Clean all packages
980 #+begin_src shell :tangle ~/.config/zsh/zshrc
982 sudo echo "${color}== cleaning pacman orphans ==${reset}"
983 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
985 echo "${color}== cleaning flatpaks ==${reset}"
986 flatpak remove --unused
988 echo "${color}== cleaning zsh plugins ==${reset}"
991 echo "${color}== cleaning nvim plugins ==${reset}"
992 nvim +PlugClean +qall
993 echo "Cleaned nvim plugins"
995 echo "${color}All orphans cleaned!${reset}"
999 #+begin_src shell :tangle ~/.config/zsh/zshrc
1002 exa -lh --icons --git --group-directories-first
1006 #+begin_src shell :tangle ~/.config/zsh/zshrc
1008 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
1009 if [ $? -eq 0 ]; then
1010 eval "$__conda_setup"
1012 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
1013 . "/opt/anaconda/etc/profile.d/conda.sh"
1015 export PATH="/opt/anaconda/bin:$PATH"
1021 **** Interact with 0x0
1022 #+begin_src shell :tangle ~/.config/zsh/zshrc
1023 zxz="https://envs.sh"
1024 0file() { curl -F"file=@$1" "$zxz" ; }
1025 0pb() { curl -F"file=@-;" "$zxz" ; }
1026 0url() { curl -F"url=$1" "$zxz" ; }
1027 0short() { curl -F"shorten=$1" "$zxz" ; }
1028 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
1031 #+begin_src shell :tangle ~/.config/zsh/zshrc
1040 #+begin_src shell :tangle ~/.config/zsh/zshrc
1041 alias bhoji-drop='ssh -p 23 root@armaanb.net'
1042 alias weechat='ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat'
1043 alias tcf='ssh root@204.48.23.68'
1044 alias ngmun='ssh root@157.245.89.25'
1045 alias prox='ssh root@192.168.1.224'
1046 alias dock='ssh root@192.168.1.225'
1047 alias jenkins='ssh root@192.168.1.226'
1048 alias envs='ssh acheam@envs.net'
1050 **** File management
1051 #+begin_src shell :tangle ~/.config/zsh/zshrc
1052 alias ls='exa -lh --icons --git --group-directories-first'
1053 alias la='exa -lha --icons --git --group-directories-first'
1054 alias df='df -h / /boot'
1056 alias free='free -h'
1061 alias grep='grep -in --exclude-dir=.git --color=auto'
1062 alias mkdir='mkdir -pv'
1063 alias unar='atool -x'
1064 alias wget='wget -e robots=off'
1065 alias lanex='~/.local/share/lxc/lxc'
1068 #+begin_src shell :tangle ~/.config/zsh/zshrc
1069 alias padm='yadm --yadm-repo ~/Code/dotfiles/repo.git'
1070 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1072 alias padu='padm add -u && padm commit && padm push && yadu'
1075 #+begin_src shell :tangle ~/.config/zsh/zshrc
1078 alias vw="nvim ~/Documents/vimwiki/index.md"
1080 **** System management
1081 #+begin_src shell :tangle ~/.config/zsh/zshrc
1082 alias jctl='journalctl -p 3 -xb'
1083 alias pkill='pkill -i'
1085 alias please='sudo $(fc -ln -1)'
1086 alias sudo='sudo ' # allows aliases to be run with sudo
1089 #+begin_src shell :tangle ~/.config/zsh/zshrc
1090 alias ping='ping -c 10'
1091 alias speed='speedtest-cli'
1092 alias ip='ip --color=auto'
1093 alias cip='curl https://armaanb.net/ip'
1094 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1095 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1098 #+begin_src shell :tangle ~/.config/zsh/zshrc
1099 alias dc='docker-compose'
1100 alias dcdu='docker-compose down && docker-compose up -d'
1103 #+begin_src shell :tangle ~/.config/zsh/zshrc
1104 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1105 iflag=fullblock status=progress'
1106 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1107 iflag=fullblock status=progress'
1108 alias ts='gen-shell -c task'
1109 alias ts='gen-shell -c task'
1110 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1111 alias news='newsboat'
1112 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1113 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1114 --restrict-filenames -o '%(title)s.%(ext)s'"
1115 alias cal="cal -3 --color=auto"
1117 **** Virtual machines, chroots
1118 #+begin_src shell :tangle ~/.config/zsh/zshrc
1119 alias ckiss="sudo chrooter ~/Virtual/kiss"
1120 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1121 alias cwindows='devour qemu-system-x86_64 \
1126 -device VGA,vgamem_mb=64 \
1128 -device hda-duplex \
1130 -net user,smb=/home/armaa/Public \
1131 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1134 #+begin_src shell :tangle ~/.config/zsh/zshrc
1136 alias zpy="zconda && ipython"
1137 alias math="ipython --profile=math"
1138 alias pypi="python setup.py sdist && twine upload dist/*"
1139 alias pip="python -m pip"
1140 alias black="black -l 79"
1143 #+begin_src shell :tangle ~/.config/zsh/zshrc
1144 alias words='gen-shell -c "words"'
1145 alias words-e='gen-shell -c "words ~E"'
1148 #+begin_src shell :tangle ~/.config/zsh/zshrc
1149 alias zathura='devour zathura'
1150 alias mpv='devour mpv'
1151 alias sql='devour sqlitebrowser'
1152 alias cad='devour openscad'
1153 alias feh='devour feh'
1155 **** Package management (Pacman)
1156 #+begin_src shell :tangle ~/.config/zsh/zshrc
1158 alias api='yay -Syu'
1159 alias app='yay -Rns'
1161 alias apo='yay -Qttd'
1162 alias azf='pacman -Q | fzf'
1163 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1164 alias ufetch='ufetch-arch'
1165 alias reflect='reflector --verbose --sort rate --save \
1166 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1169 #+begin_src shell :tangle ~/.config/zsh/zshrc
1170 export EDITOR="emacsclient -c" # $EDITOR opens in terminal
1171 export VISUAL="emacsclient -c -a emacs" # $VISUAL opens in GUI mode
1172 export TERM=xterm-256color # for compatability
1174 export GPG_TTY="$(tty)"
1175 export MANPAGER='nvim +Man!'
1178 # generated with "vivid generate gruvbox"
1179 export LS_COLORS="$(cat ~/.local/share/zsh/gruvbox)"
1181 export GTK_USE_PORTAL=1
1183 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1184 export PATH="$PATH:/home/armaa/Code/scripts"
1185 export PATH="$PATH:/home/armaa/.cargo/bin"
1186 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1187 export PATH="$PATH:/usr/sbin"
1188 export PATH="$PATH:/opt/FreeTube/freetube"
1190 export LC_ALL="en_US.UTF-8"
1191 export LC_CTYPE="en_US.UTF-8"
1192 export LANGUAGE="en_US.UTF-8"
1194 export KISS_PATH="/home/armaa/kiss/home/armaa/kiss-repo"
1195 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1196 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1197 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1198 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1199 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1203 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1206 family: JetBrains Mono Nerd Font
1213 ligatures: true # Requires ligature patch
1220 background_opacity: 0.6
1223 Send <RET> + modifier through
1224 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1239 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1243 background: '#000000'
1244 foreground: '#ebdbb2'
1270 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1271 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1272 c.TerminalInteractiveShell.editing_mode = 'vi'
1273 c.InteractiveShell.colors = 'linux'
1274 c.TerminalInteractiveShell.confirm_exit = False
1277 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1281 return x * (180 / pi)
1284 return x * (pi / 180)
1287 return (x * (pi / 180)) / unit
1299 Make MPV play a little bit smoother.
1300 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1301 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1306 #+begin_src conf :tangle ~/.config/picom/picom.conf
1309 shadow-offset-x = -5;
1310 shadow-offset-y = -5;
1313 #+begin_src conf :tangle ~/.config/picom/picom.conf
1318 #+begin_src conf :tangle ~/.config/picom/picom.conf
1321 method = "gaussian";
1327 Needs picom to be run with "--experimental-backends"
1328 #+begin_src conf :tangle ~/.config/picom/picom.conf
1332 For any GNU Readline programs
1333 #+begin_src plain :tangle ~/.inputrc
1337 https://github.com/sharkdp/vivid
1339 #+begin_src yml :tangle ~/.config/vivid/gruvbox.yml
1341 background_color: '282A36'
1353 #+begin_src yml :tangle ~/.config/vivid/gruvbox.yml
1370 missing_symlink_target:
1396 sticky_other_writable:
1429 continuous-integration:
1440 font-style: underline
1451 #+begin_src plain :tangle ~/.gitconfig
1453 name = Armaan Bhojwani
1454 email = me@armaanb.net
1455 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1458 #+begin_src plain :tangle ~/.gitconfig
1460 defaultBranch = main
1463 #+begin_src plain :tangle ~/.gitconfig
1468 #+begin_src plain :tangle ~/.gitconfig
1470 smtpserver = smtp.mailbox.org
1471 smtpuser = me@armaanb.net
1472 smtpencryption = ssl
1473 smtpserverport = 465
1477 #+begin_src plain :tangle ~/.gitconfig
1482 #+begin_src plain :tangle ~/.gitconfig
1485 sclone = clone --depth 1
1491 subup = submodule update --remote
1492 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1493 mirror = git config --global alias.mirrormirror
1496 #+begin_src plain :tangle ~/.gitconfig
1501 Lightweight notification daemon. Gruvbox colors, based on https://github.com/a-schaefers/i3-wm-gruvbox-theme/
1503 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1505 font = "JetBrains Mono Medium Nerd Font 11"
1507 format = "<b>%s</b>\n%b"
1509 indicate_hidden = yes
1512 show_age_threshold = 60
1515 geometry = "400x5-20+20"
1517 idle_threshold = 120
1519 sticky_history = yes
1521 separator_height = 4
1523 horizontal_padding = 8
1525 separator_color = "#585858"
1526 startup_notification = false
1529 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1536 close_all = mod4+shift+c
1537 history = mod4+ctrl+c
1540 background = "#282828"
1541 foreground = "#ebdbb2"
1542 highlight = "#ebdbb2"
1546 background = "#282828"
1547 foreground = "#ebdbb2"
1548 highlight = "#ebdbb2"
1552 background = "#282828"
1553 foreground = "#cc241d"
1554 highlight = "#ebdbb2"