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 ** Highlight TODOs in comments
154 #+begin_src emacs-lisp
156 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
157 :config (global-hl-todo-mode 1))
160 #+begin_src emacs-lisp
164 Soft wrap words and do operations by visual lines.
165 #+begin_src emacs-lisp
166 (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
168 ** Display number of matches in search
169 #+begin_src emacs-lisp
171 :config (global-anzu-mode))
174 Inverts modeline instead of audible bell or the standard visual bell.
175 #+begin_src emacs-lisp
176 (setq visible-bell nil
177 ring-bell-function 'flash-mode-line)
178 (defun flash-mode-line ()
179 (invert-face 'mode-line)
180 (run-with-timer 0.1 nil #'invert-face 'mode-line))
184 #+begin_src emacs-lisp
186 :custom (select-enable-clipboard nil)
189 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
190 ;; Use visual line motions even outside of visual-line-mode buffers
191 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
192 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
193 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
196 #+begin_src emacs-lisp
197 (use-package evil-collection
199 :init (evil-collection-init)
200 :custom (evil-collection-setup-minibuffer t))
204 #+begin_src emacs-lisp
205 (use-package evil-surround
206 :config (global-evil-surround-mode))
209 #+begin_src emacs-lisp
210 (use-package evil-leader
211 :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
213 (evil-leader/set-leader "<SPC>")
214 (global-evil-leader-mode))
217 #+begin_src emacs-lisp
219 (use-package evil-nerd-commenter
220 :bind (:map evil-normal-state-map
221 ("gc" . evilnc-comment-or-uncomment-lines))
222 :custom (evilnc-invert-comment-line-by-line nil))
226 #+begin_src emacs-lisp
227 (evil-set-undo-system 'undo-redo)
229 ** Number incrementing
231 #+begin_src emacs-lisp
232 (use-package evil-numbers
233 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
234 :bind (:map evil-normal-state-map
235 ("C-M-a" . evil-numbers/inc-at-pt)
236 ("C-M-x" . evil-numbers/dec-at-pt)))
240 #+begin_src emacs-lisp
241 (use-package evil-org
243 :hook (org-mode . evil-org-mode)
245 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
246 (use-package evil-org-agenda
247 :straight (:type built-in)
250 (evil-org-agenda-set-keys))
253 #+begin_src emacs-lisp
254 (evil-leader/set-key-for-mode 'org-mode
255 "T" 'org-show-todo-tree
257 "c" 'org-archive-subtree)
261 #+begin_src emacs-lisp
263 :straight (:type built-in)
264 :commands (org-capture org-agenda)
267 (org-agenda-start-with-log-mode t)
268 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
270 (org-log-into-drawer t)
271 (org-src-tab-acts-natively t)
272 (org-src-fontify-natively t)
273 (org-startup-indented t)
274 (org-hide-emphasis-markers t)
275 (org-fontify-whole-block-delimiter-line nil)
276 :bind ("C-c a" . org-agenda))
279 #+begin_src emacs-lisp
280 (use-package org-tempo
282 :straight (:type built-in)
284 ;; TODO: There's gotta be a more efficient way to write this
285 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
286 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
287 (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
288 (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
289 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
290 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
291 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
292 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc"))
293 (add-to-list 'org-structure-template-alist '("ro" . "src javascript :tangle ~/.config/rofi/config.rasi"))
294 (add-to-list 'org-structure-template-alist '("za" . "src conf :tangle ~/.config/zathura/zathurarc")))
297 #+begin_src emacs-lisp
298 (use-package org-present
299 :straight (org-present :type git :host github :repo "rlister/org-present"))
303 Simple, but not too simple autocompletion.
304 #+begin_src emacs-lisp
306 :bind (("C-s" . swiper)
307 :map ivy-minibuffer-map
308 ("TAB" . ivy-alt-done)
309 :map ivy-switch-buffer-map
310 ("M-d" . ivy-switch-buffer-kill))
314 #+begin_src emacs-lisp
315 (use-package ivy-rich
317 :config (ivy-rich-mode))
321 #+begin_src emacs-lisp
323 :bind (("C-M-j" . 'counsel-switch-buffer)
324 :map minibuffer-local-map
325 ("C-r" . 'counsel-minibuffer-history))
326 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
327 :config (counsel-mode))
329 ** Remember frequent commands
330 #+begin_src emacs-lisp
331 (use-package ivy-prescient
334 (ivy-prescient-enable-filtering nil)
336 (prescient-persist-mode)
337 (ivy-prescient-mode))
340 Better search utility.
341 #+begin_src emacs-lisp
346 Use elfeed for RSS. I have another file with all the feeds in it.
347 #+begin_src emacs-lisp
349 :bind (("C-c e" . elfeed))
351 (load "~/.emacs.d/feeds.el")
352 (add-hook 'elfeed-new-entry-hook
353 (elfeed-make-tagger :feed-url "youtube\\.com"
355 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
357 (use-package elfeed-goodies
359 :config (elfeed-goodies/setup))
362 Use mu4e for reading emails.
364 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.
366 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.
367 #+begin_src emacs-lisp
368 (use-package smtpmail
369 :straight (:type built-in))
371 :load-path "/usr/share/emacs/site-lisp/mu4e"
372 :bind (("C-c m" . mu4e))
374 (setq user-full-name "Armaan Bhojwani"
375 smtpmail-local-domain "armaanb.net"
376 smtpmail-stream-type 'ssl
377 smtpmail-smtp-service '465
378 mu4e-change-filenames-when-moving t
379 mu4e-get-mail-command "offlineimap -q"
380 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
381 message-citation-line-function 'message-insert-formatted-citation-line
382 mu4e-completing-read-function 'ivy-completing-read
383 mu4e-confirm-quit nil
384 mail-user-agent 'mu4e-user-agent
386 `( ,(make-mu4e-context
388 :enter-func (lambda () (mu4e-message "Entering school context"))
389 :leave-func (lambda () (mu4e-message "Leaving school context"))
390 :match-func (lambda (msg)
392 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
393 :vars '((user-mail-address . "abhojwani22@nobles.edu")
394 (mu4e-sent-folder . "/school/Sent")
395 (mu4e-drafts-folder . "/school/Drafts")
396 (mu4e-trash-folder . "/school/Trash")
397 (mu4e-refile-folder . "/school/Archive")
398 (user-mail-address . "abhojwani22@nobles.edu")
399 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
400 (smtpmail-smtp-server . "smtp.gmail.com")))
403 :enter-func (lambda () (mu4e-message "Entering personal context"))
404 :leave-func (lambda () (mu4e-message "Leaving personal context"))
405 :match-func (lambda (msg)
407 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
408 :vars '((mu4e-sent-folder . "/personal/Sent")
409 (mu4e-drafts-folder . "/personal/Drafts")
410 (mu4e-trash-folder . "/personal/Trash")
411 (mu4e-refile-folder . "/personal/Archive")
412 (user-mail-address . "me@armaanb.net")
413 (smtpmail-smtp-user . "me@armaanb.net")
414 (smtpmail-smtp-server "smtp.mailbox.org")
415 (mu4e-drafts-folder . "/school/Drafts")
416 (mu4e-trash-folder . "/school/Trash")))))
417 (add-to-list 'mu4e-bookmarks
418 '(:name "Unified inbox"
419 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
421 :hook ((mu4e-compose-mode . flyspell-mode)
422 (mu4e-view-mode-hook . turn-on-visual-line-mode)))
425 #+begin_src emacs-lisp
427 (use-package calfw-org)
428 (use-package calfw-ical)
430 (defun acheam-calendar ()
433 (shell-command "vdirsyncer sync")
434 (let ((default-directory "~/.local/share/vdirsyncer/"))
435 (cfw:open-calendar-buffer
438 (cfw:ical-create-source "School" (expand-file-name "school/abhojwani22@nobles.edu.ics") "Green")
439 (cfw:ical-create-source "Personal" (expand-file-name "mailbox/Y2FsOi8vMC8zMQ.ics") "Blue")
440 (cfw:ical-create-source "Birthdays" (expand-file-name "mailbox/Y2FsOi8vMS8w.ics") "Gray")
444 Another file has more specific network configuration.
445 #+begin_src emacs-lisp
447 :config (load-file "~/.emacs.d/irc.el"))
449 (use-package circe-chanop
450 :straight (:type built-in)
453 (use-package circe-color-nicks
454 :straight (:type built-in)
458 Set EWW as default browser except for videos.
459 #+begin_src emacs-lisp
460 (defun browse-url-mpv (url &optional new-window)
462 (start-process "mpv" "*mpv*" "mpv" url))
464 (setq browse-url-handlers
466 (("youtu\\.?be" . browse-url-mpv)
467 ("." . eww-browse-url)
471 Some EWW enhancements.
472 *** Give buffer a useful name
473 #+begin_src emacs-lisp
474 ;; From https://protesilaos.com/dotemacs/
475 (defun prot-eww--rename-buffer ()
476 "Rename EWW buffer using page title or URL.
477 To be used by `eww-after-render-hook'."
478 (let ((name (if (eq "" (plist-get eww-data :title))
479 (plist-get eww-data :url)
480 (plist-get eww-data :title))))
481 (rename-buffer (format "*%s # eww*" name) t)))
483 (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
485 *** Better entrypoint
486 #+begin_src emacs-lisp
487 ;; From https://protesilaos.com/dotemacs/
488 (defun prot-eww-browse-dwim (url &optional arg)
489 "Visit a URL, maybe from `eww-prompt-history', with completion.
491 With optional prefix ARG (\\[universal-argument]) open URL in a
494 If URL does not look like a valid link, run a web query using
497 When called from an eww buffer, provide the current link as
501 (completing-read "Query:" eww-prompt-history
502 nil nil (plist-get eww-data :url) 'eww-prompt-history)
504 (eww url (if arg 4 nil)))
506 (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
509 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
510 =emacsclient --eval "(emacs-everywhere)"=.
511 #+begin_src emacs-lisp
512 (use-package emacs-everywhere)
515 #+begin_src emacs-lisp
516 (setq eshell-prompt-function
519 "\n" (eshell/pwd) " ➤ ")
520 'face '(:foreground "cyan")))
521 eshell-highlight-prompt nil)
525 #+begin_src emacs-lisp
527 :hook (python-mode . blacken-mode)
529 (setq blacken-line-length 79))
532 (use-package ws-butler
534 (ws-butler-global-mode))
537 #+begin_src emacs-lisp
538 (use-package flycheck
540 (global-flycheck-mode))
542 ** Project management
543 #+begin_src emacs-lisp
544 (use-package projectile
545 :config (projectile-mode)
546 :custom ((projectile-completion-system 'ivy))
548 ("C-c p" . projectile-command-map)
550 (when (file-directory-p "~/Code")
551 (setq projectile-project-search-path '("~/Code")))
552 (setq projectile-switch-project-action #'projectile-dired))
554 (use-package counsel-projectile
556 :config (counsel-projectile-mode))
559 #+begin_src emacs-lisp
561 :straight (:type built-in)
562 :commands (dired dired-jump)
563 :custom ((dired-listing-switches "-agho --group-directories-first"))
565 (evil-collection-define-key 'normal 'dired-mode-map
566 "h" 'dired-single-up-directory
567 "l" 'dired-single-buffer))
569 (use-package dired-single
570 :commands (dired dired-jump))
572 (use-package dired-open
573 :commands (dired dired-jump)
575 (dired-open-extensions '(("png" . "feh")
578 (use-package dired-hide-dotfiles
579 :hook (dired-mode . dired-hide-dotfiles-mode)
581 (evil-collection-define-key 'normal 'dired-mode-map
582 "H" 'dired-hide-dotfiles-mode))
586 # TODO: Write a command that commits hunk, skipping staging step.
587 #+begin_src emacs-lisp
590 *** Colored diff in line number area
591 #+begin_src emacs-lisp
593 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
594 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
595 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
596 :config (global-diff-hl-mode))
598 * General text editing
600 Indent after every change.
601 #+begin_src emacs-lisp
602 (use-package aggressive-indent
603 :config (global-aggressive-indent-mode))
606 Spell check in text mode, and in prog-mode comments.
607 #+begin_src emacs-lisp
608 (dolist (hook '(text-mode-hook))
609 (add-hook hook (lambda () (flyspell-mode))))
610 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
611 (add-hook hook (lambda () (flyspell-mode -1))))
612 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
614 ** Expand tabs to spaces
615 #+begin_src emacs-lisp
616 (setq-default tab-width 2)
618 ** Copy kill ring to clipboard
619 #+begin_src emacs-lisp
620 (setq x-select-enable-clipboard t)
621 (defun copy-kill-ring-to-xorg ()
622 "Copy the current kill ring to the xorg clipboard."
624 (x-select-text (current-kill 0)))
627 #+begin_src emacs-lisp
628 (use-package browse-kill-ring)
631 Opens file where you left it.
632 #+begin_src emacs-lisp
636 Distraction free writing a la junegunn/goyo.
637 #+begin_src emacs-lisp
638 (use-package olivetti
640 (evil-leader/set-key "o" 'olivetti-mode))
644 #+begin_src emacs-lisp
645 (setq abbrev-file-name "~/.emacs.d/abbrevs")
646 (setq save-abbrevs 'silent)
647 (setq-default abbrev-mode t)
650 #+begin_src emacs-lisp
651 (setq tramp-default-method "ssh")
653 ** Don't ask about following symlinks in vc
654 #+begin_src emacs-lisp
655 (setq vc-follow-symlinks t)
658 ** Easily convert splits
659 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
660 #+begin_src emacs-lisp
661 (defun toggle-window-split ()
663 (if (= (count-windows) 2)
664 (let* ((this-win-buffer (window-buffer))
665 (next-win-buffer (window-buffer (next-window)))
666 (this-win-edges (window-edges (selected-window)))
667 (next-win-edges (window-edges (next-window)))
668 (this-win-2nd (not (and (<= (car this-win-edges)
669 (car next-win-edges))
670 (<= (cadr this-win-edges)
671 (cadr next-win-edges)))))
673 (if (= (car this-win-edges)
674 (car (window-edges (next-window))))
675 'split-window-horizontally
676 'split-window-vertically)))
677 (delete-other-windows)
678 (let ((first-win (selected-window)))
680 (if this-win-2nd (other-window 1))
681 (set-window-buffer (selected-window) this-win-buffer)
682 (set-window-buffer (next-window) next-win-buffer)
683 (select-window first-win)
684 (if this-win-2nd (other-window 1))))))
686 (define-key ctl-x-4-map "t" 'toggle-window-split)
689 #+begin_src emacs-lisp
690 (defun insert-date ()
692 (insert (format-time-string "%Y-%m-%d")))
696 #+begin_src emacs-lisp
697 (use-package ace-window
698 :bind ("M-o" . ace-window))
700 ** Kill current buffer
701 Makes "C-x k" binding faster.
702 #+begin_src emacs-lisp
703 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
707 Render OpenSCAD files, and add a preview window.
709 Personal fork just merges a PR.
710 #+begin_src emacs-lisp
711 (use-package scad-mode)
712 (use-package scad-preview
713 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
715 ** Control backup files
716 Stop backup files from spewing everywhere.
717 #+begin_src emacs-lisp
718 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
720 ** Make yes/no easier
721 #+begin_src emacs-lisp
722 (defalias 'yes-or-no-p 'y-or-n-p)
724 ** Move customize file
725 No more clogging up init.el.
726 #+begin_src emacs-lisp
727 (setq custom-file "~/.emacs.d/custom.el")
731 #+begin_src emacs-lisp
733 :commands (helpful-callable helpful-variable helpful-command helpful-key)
735 (counsel-describe-function-function #'helpful-callable)
736 (counsel-describe-variable-function #'helpful-variable)
738 ([remap describe-function] . counsel-describe-function)
739 ([remap describe-command] . helpful-command)
740 ([remap describe-variable] . counsel-describe-variable)
741 ([remap describe-key] . helpful-key))
744 #+begin_src emacs-lisp
745 (use-package epa-file
746 :straight (:type built-in)
748 (epa-file-select-keys nil)
749 (epa-file-encrypt-to '("me@armaanb.net"))
750 (password-cache-expiry (* 60 15)))
752 (use-package pinentry
753 :config (pinentry-start))
756 #+begin_src emacs-lisp
758 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
759 :custom (0x0-default-service 'envs)
760 :config (evil-leader/set-key
762 "0f" '0x0-upload-file
763 "0s" '0x0-upload-string
764 "0c" '0x0-upload-kill-ring
765 "0p" '0x0-upload-popup))
770 #+begin_src conf :tangle ~/.spectrwm.conf
775 autorun = ws[1]:/home/armaa/Code/scripts/autostart
778 #+begin_src conf :tangle ~/.spectrwm.conf
779 color_focus = rgb:ff/ff/ff
780 color_focus_maximized = rgb:ee/cc/00
781 color_unfocus = rgb:55/55/55
784 #+begin_src conf :tangle ~/.spectrwm.conf
786 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
790 #+begin_src conf :tangle ~/.spectrwm.conf
791 program[lock] = i3lock -c 000000 -ef
792 program[term] = alacritty
793 program[screenshot_all] = flameshot gui
794 program[menu] = rofi -show run # `rofi-dmenu` handles the rest
795 program[switcher] = rofi -show window
796 program[notif] = /home/armaa/Code/scripts/setter status
799 bind[switcher] = MOD+Tab
802 #+begin_src conf :tangle ~/.spectrwm.conf
803 program[paup] = /home/armaa/Code/scripts/setter audio +5
804 program[padown] = /home/armaa/Code/scripts/setter audio -5
805 program[pamute] = /home/armaa/Code/scripts/setter audio
806 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
807 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
808 program[next] = playerctl next
809 program[prev] = playerctl previous
810 program[pause] = playerctl play-pause
812 bind[padown] = XF86AudioLowerVolume
813 bind[paup] = XF86AudioRaiseVolume
814 bind[pamute] = XF86AudioMute
815 bind[brigdown] = XF86MonBrightnessDown
816 bind[brigup] = XF86MonBrightnessUp
817 bind[pause] = XF86AudioPlay
818 bind[next] = XF86AudioNext
819 bind[prev] = XF86AudioPrev
822 #+begin_src conf :tangle ~/.spectrwm.conf
823 program[h] = xdotool keyup h key --clearmodifiers Left
824 program[j] = xdotool keyup j key --clearmodifiers Down
825 program[k] = xdotool keyup k key --clearmodifiers Up
826 program[l] = xdotool keyup l key --clearmodifiers Right
828 bind[h] = MOD + Control + h
829 bind[j] = MOD + Control + j
830 bind[k] = MOD + Control + k
831 bind[l] = MOD + Control + l
834 #+begin_src conf :tangle ~/.spectrwm.conf
835 program[aerc] = alacritty -e aerc
836 program[weechat] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat; sleep 2; done"
837 program[catgirl] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t catgirl; sleep 2; done"
838 program[emacs] = emacsclient -c
839 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
840 program[firefox] = firefox
842 bind[aerc] = MOD+Control+1
843 # bind[weechat] = MOD+Control+2
844 bind[catgirl] = MOD+Control+2
845 bind[emacs-anywhere] = MOD+Control+3
846 bind[firefox] = MOD+Control+4
847 bind[emacs] = MOD+Control+Return
852 #+begin_src shell :tangle ~/.config/zsh/zshrc
853 autoload -Uz compinit
857 unsetopt glob_complete
860 #+begin_src shell :tangle ~/.config/zsh/zshrc
864 bindkey -M vicmd "^[[3~" delete-char
865 bindkey "^[[3~" delete-char
867 autoload edit-command-line
868 zle -N edit-command-line
869 bindkey -M vicmd ^e edit-command-line
870 bindkey ^e edit-command-line
873 #+begin_src shell :tangle ~/.config/zsh/zshrc
874 setopt extended_history
876 setopt inc_append_history
877 setopt hist_ignore_dups
878 setopt hist_reduce_blanks
882 HISTFILE=~/.local/share/zsh/history
885 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
887 #+begin_src conf :tangle ~/.config/zpe/repositories
888 https://github.com/Aloxaf/fzf-tab
889 https://github.com/zdharma/fast-syntax-highlighting
890 https://github.com/rupa/z
893 #+begin_src shell :tangle ~/.config/zsh/zshrc
894 source ~/Code/zpe/zpe.sh
895 source ~/Code/admone/admone.zsh
896 source ~/.config/zsh/fzf-bindings.zsh
898 zpe-source fzf-tab/fzf-tab.zsh
899 zstyle ':completion:*:descriptions' format '[%d]'
900 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
901 zstyle ':completion:*' completer _complete
902 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' \
903 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
905 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
906 export _Z_DATA="/home/armaa/.local/share/z"
910 **** Alert after long command
911 #+begin_src shell :tangle ~/.config/zsh/zshrc
913 notify-send --urgency=low -i ${(%):-%(?.terminal.error)} \
914 ${history[$HISTCMD]%[;&|][[:space:]]##alert}
917 **** Time Zsh startup
918 #+begin_src shell :tangle ~/.config/zsh/zshrc
920 for i in $(seq 1 10); do
921 time "zsh" -i -c exit;
925 **** Update all packages
926 #+begin_src shell :tangle ~/.config/zsh/zshrc
927 color=$(tput setaf 5)
931 sudo echo "${color}== upgrading with yay ==${reset}"
934 echo "${color}== checking for pacnew files ==${reset}"
937 echo "${color}== upgrading flatpaks ==${reset}"
940 echo "${color}== upgrading zsh plugins ==${reset}"
943 echo "${color}== updating nvim plugins ==${reset}"
944 nvim +PlugUpdate +PlugUpgrade +qall
945 echo "Updated nvim plugins"
947 echo "${color}You are entirely up to date!${reset}"
950 **** Clean all packages
951 #+begin_src shell :tangle ~/.config/zsh/zshrc
953 sudo echo "${color}== cleaning pacman orphans ==${reset}"
954 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
956 echo "${color}== cleaning flatpaks ==${reset}"
957 flatpak remove --unused
959 echo "${color}== cleaning zsh plugins ==${reset}"
962 echo "${color}== cleaning nvim plugins ==${reset}"
963 nvim +PlugClean +qall
964 echo "Cleaned nvim plugins"
966 echo "${color}All orphans cleaned!${reset}"
970 #+begin_src shell :tangle ~/.config/zsh/zshrc
973 exa -lh --icons --git --group-directories-first
976 **** Change default enter behavior
977 If no command given, =ls=, if in a Git repo, =git status= as well.
978 #+begin_src shell :tangle ~/.config/zsh/zshrc
979 acheam-accept-line () {
981 if [ ${#${(z)BUFFER}} -eq 0 ]; then
983 exa -lh --icons --git --group-directories-first
984 [ -d ".git" ] && git status
987 zle -N acheam-accept-line
988 bindkey '^M' acheam-accept-line
991 #+begin_src shell :tangle ~/.config/zsh/zshrc
993 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
994 if [ $? -eq 0 ]; then
995 eval "$__conda_setup"
997 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
998 . "/opt/anaconda/etc/profile.d/conda.sh"
1000 export PATH="/opt/anaconda/bin:$PATH"
1006 **** Interact with 0x0
1007 #+begin_src shell :tangle ~/.config/zsh/zshrc
1008 zxz="https://envs.sh"
1009 0file() { curl -F"file=@$1" "$zxz" ; }
1010 0pb() { curl -F"file=@-;" "$zxz" ; }
1011 0url() { curl -F"url=$1" "$zxz" ; }
1012 0short() { curl -F"shorten=$1" "$zxz" ; }
1013 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
1016 #+begin_src shell :tangle ~/.config/zsh/zshrc
1025 #+begin_src shell :tangle ~/.config/zsh/zshrc
1026 alias bhoji-drop='ssh -p 23 root@armaanb.net'
1027 alias weechat='ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat'
1028 alias catgirl='ssh -p 23 -t root@armaanb.net tmux attach-session -t catgirl'
1029 alias tcf='ssh root@204.48.23.68'
1030 alias ngmun='ssh root@157.245.89.25'
1031 alias prox='ssh root@192.168.1.224'
1032 alias ncq='ssh root@143.198.123.17'
1033 alias dock='ssh root@192.168.1.225'
1034 alias jenkins='ssh root@192.168.1.226'
1035 alias envs='ssh acheam@envs.net'
1037 **** File management
1038 #+begin_src shell :tangle ~/.config/zsh/zshrc
1039 alias ls='exa -lh --icons --git --group-directories-first'
1040 alias la='exa -lha --icons --git --group-directories-first'
1041 alias df='df -h / /boot'
1043 alias free='free -h'
1048 alias grep='grep -in --exclude-dir=.git --color=auto'
1049 alias fname='find -name'
1050 alias mkdir='mkdir -pv'
1051 alias unar='atool -x'
1052 alias wget='wget -e robots=off'
1053 alias lanex='~/.local/share/lxc/lxc'
1056 #+begin_src shell :tangle ~/.config/zsh/zshrc
1057 alias padm='yadm --yadm-repo ~/Code/dotfiles/repo.git'
1058 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1060 alias padu='padm add -u && padm commit && padm push && yadu'
1063 #+begin_src shell :tangle ~/.config/zsh/zshrc
1066 alias vw="nvim ~/Documents/vimwiki/index.md"
1068 **** System management
1069 #+begin_src shell :tangle ~/.config/zsh/zshrc
1070 alias jctl='journalctl -p 3 -xb'
1071 alias pkill='pkill -i'
1073 alias redoas='doas $(fc -ln -1)'
1074 alias crontab='crontab-argh'
1075 alias sudo='doas ' # allows aliases to be run with doas
1078 #+begin_src shell :tangle ~/.config/zsh/zshrc
1079 alias ping='ping -c 10'
1080 alias speed='speedtest-cli'
1081 alias ip='ip --color=auto'
1082 alias cip='curl https://armaanb.net/ip'
1083 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1084 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1087 #+begin_src shell :tangle ~/.config/zsh/zshrc
1088 alias dc='docker-compose'
1089 alias dcdu='docker-compose down && docker-compose up -d'
1092 #+begin_src shell :tangle ~/.config/zsh/zshrc
1093 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1094 iflag=fullblock status=progress'
1095 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1096 iflag=fullblock status=progress'
1097 alias ts='gen-shell -c task'
1098 alias ts='gen-shell -c task'
1099 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1100 alias news='newsboat'
1101 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1102 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1103 --restrict-filenames -o '%(title)s.%(ext)s'"
1104 alias cal="cal -3 --color=auto"
1106 **** Virtual machines, chroots
1107 #+begin_src shell :tangle ~/.config/zsh/zshrc
1108 alias ckiss="sudo chrooter ~/Virtual/kiss"
1109 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1110 alias cwindows='devour qemu-system-x86_64 \
1115 -device VGA,vgamem_mb=64 \
1117 -device hda-duplex \
1119 -net user,smb=/home/armaa/Public \
1120 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1123 #+begin_src shell :tangle ~/.config/zsh/zshrc
1125 alias zpy="zconda && ipython"
1126 alias math="ipython --profile=math"
1127 alias pypi="python setup.py sdist && twine upload dist/*"
1128 alias pip="python -m pip"
1129 alias black="black -l 79"
1132 #+begin_src shell :tangle ~/.config/zsh/zshrc
1133 alias words='gen-shell -c "words"'
1134 alias words-e='gen-shell -c "words ~E"'
1137 #+begin_src shell :tangle ~/.config/zsh/zshrc
1138 alias zathura='devour zathura'
1139 alias mpv='devour mpv'
1140 alias sql='devour sqlitebrowser'
1141 alias cad='devour openscad'
1142 alias feh='devour feh'
1144 **** Package management (Pacman)
1145 #+begin_src shell :tangle ~/.config/zsh/zshrc
1147 alias api='yay -Syu'
1148 alias apii='sudo pacman -S'
1149 alias app='yay -Rns'
1151 alias apo='yay -Qttd'
1152 alias azf='pacman -Q | fzf'
1153 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1154 alias ufetch='ufetch-arch'
1155 alias reflect='reflector --verbose --sort rate --save \
1156 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1159 #+begin_src shell :tangle ~/.config/zsh/zshrc
1160 export EDITOR="emacsclient -c"
1161 export VISUAL="$EDITOR"
1162 export TERM=xterm-256color # for compatability
1164 export GPG_TTY="$(tty)"
1165 export MANPAGER='nvim +Man!'
1168 export GTK_USE_PORTAL=1
1170 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1171 export PATH="/home/armaa/Code/scripts:$PATH" # prioritize my scripts
1172 export PATH="/home/armaa/Code/scripts/bin:$PATH" # prioritize my bins
1173 export PATH="$PATH:/home/armaa/.cargo/bin"
1174 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1175 export PATH="$PATH:/usr/sbin"
1176 export PATH="$PATH:/opt/FreeTube/freetube"
1178 export LC_ALL="en_US.UTF-8"
1179 export LC_CTYPE="en_US.UTF-8"
1180 export LANGUAGE="en_US.UTF-8"
1182 export KISS_PATH="/home/armaa/Virtual/kiss/home/armaa/kiss-repo"
1183 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1184 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1185 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1186 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1187 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1191 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1194 family: JetBrains Mono Nerd Font
1201 ligatures: true # Requires ligature patch
1208 background_opacity: 1
1211 Modus vivendi. Source: https://github.com/ishan9299/Nixos/blob/d4bbb7536be95b59466bb9cca4d671be46e04e81/user/alacritty/alacritty.yml#L30-L118
1212 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1216 background: '#000000'
1217 foreground: '#ffffff'
1221 background: '#ffffff'
1223 # Normal colors (except green it is from intense colors)
1234 # Bright colors [all the faint colors in the modus theme]
1245 # dim [all the intense colors in modus theme]
1258 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1259 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1260 c.TerminalInteractiveShell.editing_mode = 'vi'
1261 c.InteractiveShell.colors = 'linux'
1262 c.TerminalInteractiveShell.confirm_exit = False
1265 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1269 return x * (180 / pi)
1272 return x * (pi / 180)
1275 return (x * (pi / 180)) / unit
1287 Make MPV play a little bit smoother.
1288 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1289 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1293 For any GNU Readline programs
1294 #+begin_src conf :tangle ~/.inputrc
1299 #+begin_src conf :tangle ~/.gitconfig
1301 name = Armaan Bhojwani
1302 email = me@armaanb.net
1303 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1306 #+begin_src conf :tangle ~/.gitconfig
1308 defaultBranch = main
1311 #+begin_src conf :tangle ~/.gitconfig
1316 #+begin_src conf :tangle ~/.gitconfig
1318 smtpserver = smtp.mailbox.org
1319 smtpuser = me@armaanb.net
1320 smtpencryption = ssl
1321 smtpserverport = 465
1325 #+begin_src conf :tangle ~/.gitconfig
1330 #+begin_src conf :tangle ~/.gitconfig
1333 sclone = clone --depth 1
1339 subup = submodule update --remote
1340 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1341 mirror = git config --global alias.mirrormirror
1344 #+begin_src conf :tangle ~/.gitconfig
1350 Lightweight notification daemon.
1352 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1354 font = "JetBrains Mono Medium Nerd Font 11"
1356 format = "<b>%s</b>\n%b"
1358 indicate_hidden = yes
1361 show_age_threshold = 60
1364 geometry = "400x5-10+10"
1366 idle_threshold = 120
1368 sticky_history = yes
1370 separator_height = 4
1372 horizontal_padding = 8
1374 separator_color = "#ffffff"
1375 startup_notification = false
1378 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1385 close_all = mod4+shift+c
1386 history = mod4+ctrl+c
1389 background = "#222222"
1390 foreground = "#ffffff"
1391 highlight = "#ffffff"
1395 background = "#222222"
1396 foreground = "#ffffff"
1397 highlight = "#ffffff"
1401 background = "#222222"
1402 foreground = "#a60000"
1403 highlight = "#ffffff"
1407 Modus vivendi theme that extends DarkBlue.
1408 #+begin_src javascript :tangle ~/.config/rofi/config.rasi
1409 @import "/usr/share/rofi/themes/DarkBlue.rasi"
1411 white: rgba ( 255, 255, 255, 100 % );
1413 selected-normal-background: @white;
1414 separatorcolor: @white;
1415 background: rgba ( 34, 34, 34, 100 % );
1424 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1426 map <A-b> toggle_statusbar
1427 set selection-clipboard clipboard
1430 set window-title-basename "true"
1431 set selection-clipboard "clipboard"
1434 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1435 set default-bg "#000000"
1436 set default-fg "#ffffff"
1437 set render-loading true
1438 set render-loading-bg "#000000"
1439 set render-loading-fg "#ffffff"
1441 set recolor-lightcolor "#000000" # bg
1442 set recolor-darkcolor "#ffffff" # fg