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 "~~" "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
83 (global-ligature-mode t))
86 #+begin_src emacs-lisp
88 :config (global-emojify-mode))
90 ;; http://ergoemacs.org/emacs/emacs_list_and_set_font.html
95 ((member "Twitter Color Emoji" (font-family-list)) "Twitter Color Emoji")
96 ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
97 ((member "Noto Emoji" (font-family-list)) "Noto Emoji")))
100 Display relative line numbers except in some modes
101 #+begin_src emacs-lisp
102 (global-display-line-numbers-mode)
103 (setq display-line-numbers-type 'relative)
104 (dolist (no-line-num '(term-mode-hook
109 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
111 ** Highlight matching parenthesis
112 #+begin_src emacs-lisp
114 :config (show-paren-mode)
115 :custom (show-paren-style 'parenthesis))
118 *** Show current function
119 #+begin_src emacs-lisp
120 (which-function-mode)
122 *** Make position in file more descriptive
123 Show current column and file size.
124 #+begin_src emacs-lisp
126 (size-indication-mode)
129 #+begin_src emacs-lisp
131 :config (minions-mode))
134 #+begin_src emacs-lisp
136 :straight (wc-mode :type git :host github :repo "bnbeckwith/wc-mode")
137 :hook (text-mode-hook . wc-mode))
140 Show a ruler at a certain number of chars depending on mode.
141 #+begin_src emacs-lisp
142 (global-display-fill-column-indicator-mode)
145 Whenever starting a key chord, show possible future steps.
146 #+begin_src emacs-lisp
147 (use-package which-key
148 :config (which-key-mode)
149 :custom (which-key-idle-delay 0.3))
151 ** Visual highlights of changes
152 Highlight when changes are made.
153 #+begin_src emacs-lisp
154 (use-package evil-goggles
155 :config (evil-goggles-mode)
156 (evil-goggles-use-diff-faces))
158 ** Highlight TODOs in comments
159 #+begin_src emacs-lisp
161 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
162 :config (global-hl-todo-mode 1))
165 #+begin_src emacs-lisp
169 Soft wrap words and do operations by visual lines.
170 #+begin_src emacs-lisp
171 (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
173 ** Display number of matches in search
174 #+begin_src emacs-lisp
176 :config (global-anzu-mode))
179 Inverts modeline instead of audible bell or the standard visual bell.
180 #+begin_src emacs-lisp
181 (setq visible-bell nil
182 ring-bell-function 'flash-mode-line)
183 (defun flash-mode-line ()
184 (invert-face 'mode-line)
185 (run-with-timer 0.1 nil #'invert-face 'mode-line))
189 #+begin_src emacs-lisp
191 :custom (select-enable-clipboard nil)
194 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
195 ;; Use visual line motions even outside of visual-line-mode buffers
196 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
197 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
198 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
201 #+begin_src emacs-lisp
202 (use-package evil-collection
204 :init (evil-collection-init)
205 :custom (evil-collection-setup-minibuffer t))
209 #+begin_src emacs-lisp
210 (use-package evil-surround
211 :config (global-evil-surround-mode))
214 #+begin_src emacs-lisp
215 (use-package evil-leader
216 :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
218 (evil-leader/set-leader "<SPC>")
219 (global-evil-leader-mode))
222 #+begin_src emacs-lisp
224 (use-package evil-nerd-commenter
225 :bind (:map evil-normal-state-map
226 ("gc" . evilnc-comment-or-uncomment-lines))
227 :custom (evilnc-invert-comment-line-by-line nil))
231 #+begin_src emacs-lisp
232 (evil-set-undo-system 'undo-redo)
234 ** Number incrementing
236 #+begin_src emacs-lisp
237 (use-package evil-numbers
238 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
239 :bind (:map evil-normal-state-map
240 ("C-M-a" . evil-numbers/inc-at-pt)
241 ("C-M-x" . evil-numbers/dec-at-pt)))
245 #+begin_src emacs-lisp
246 (use-package evil-org
248 :hook (org-mode . evil-org-mode)
250 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
251 (use-package evil-org-agenda
252 :straight (:type built-in)
255 (evil-org-agenda-set-keys))
258 #+begin_src emacs-lisp
259 (evil-leader/set-key-for-mode 'org-mode
260 "T" 'org-show-todo-tree
262 "c" 'org-archive-subtree)
266 #+begin_src emacs-lisp
268 :straight (:type built-in)
269 :commands (org-capture org-agenda)
271 (org-ellipsis " â–¾")
272 (org-agenda-start-with-log-mode t)
273 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
275 (org-log-into-drawer t)
276 (org-src-tab-acts-natively t)
277 (org-src-fontify-natively t)
278 (org-startup-indented t)
279 (org-hide-emphasis-markers t)
280 (org-fontify-whole-block-delimiter-line nil)
281 :bind ("C-c a" . org-agenda))
284 #+begin_src emacs-lisp
285 (use-package org-tempo
287 :straight (:type built-in)
289 ;; TODO: There's gotta be a more efficient way to write this
290 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
291 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
292 (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
293 (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
294 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
295 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
296 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
297 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc"))
298 (add-to-list 'org-structure-template-alist '("ro" . "src plain :tangle ~/.config/rofi/config.rasi"))
299 (add-to-list 'org-structure-template-alist '("za" . "src plain :tangle ~/.config/zathura/zathurarc")))
302 #+begin_src emacs-lisp
303 (use-package org-present
304 :straight (org-present :type git :host github :repo "rlister/org-present"))
308 Simple, but not too simple autocompletion.
309 #+begin_src emacs-lisp
311 :bind (("C-s" . swiper)
312 :map ivy-minibuffer-map
313 ("TAB" . ivy-alt-done)
314 :map ivy-switch-buffer-map
315 ("M-d" . ivy-switch-buffer-kill))
319 #+begin_src emacs-lisp
320 (use-package ivy-rich
322 :config (ivy-rich-mode))
326 #+begin_src emacs-lisp
328 :bind (("C-M-j" . 'counsel-switch-buffer)
329 :map minibuffer-local-map
330 ("C-r" . 'counsel-minibuffer-history))
331 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
332 :config (counsel-mode))
334 ** Remember frequent commands
335 #+begin_src emacs-lisp
336 (use-package ivy-prescient
339 (ivy-prescient-enable-filtering nil)
341 (prescient-persist-mode)
342 (ivy-prescient-mode))
345 Better search utility.
346 #+begin_src emacs-lisp
351 Use elfeed for RSS. I have another file with all the feeds in it.
352 #+begin_src emacs-lisp
354 :bind (("C-c e" . elfeed))
356 (load "~/.emacs.d/feeds.el")
357 (add-hook 'elfeed-new-entry-hook
358 (elfeed-make-tagger :feed-url "youtube\\.com"
360 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
362 (use-package elfeed-goodies
364 :config (elfeed-goodies/setup))
367 Use mu4e for reading emails.
369 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.
371 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.
372 #+begin_src emacs-lisp
373 (use-package smtpmail
374 :straight (:type built-in))
376 :load-path "/usr/share/emacs/site-lisp/mu4e"
377 :bind (("C-c m" . mu4e))
379 (setq user-full-name "Armaan Bhojwani"
380 smtpmail-local-domain "armaanb.net"
381 smtpmail-stream-type 'ssl
382 smtpmail-smtp-service '465
383 mu4e-change-filenames-when-moving t
384 mu4e-get-mail-command "offlineimap -q"
385 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
386 message-citation-line-function 'message-insert-formatted-citation-line
387 mu4e-completing-read-function 'ivy-completing-read
388 mu4e-confirm-quit nil
389 mail-user-agent 'mu4e-user-agent
391 `( ,(make-mu4e-context
393 :enter-func (lambda () (mu4e-message "Entering school context"))
394 :leave-func (lambda () (mu4e-message "Leaving school context"))
395 :match-func (lambda (msg)
397 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
398 :vars '((user-mail-address . "abhojwani22@nobles.edu")
399 (mu4e-sent-folder . "/school/Sent")
400 (mu4e-drafts-folder . "/school/Drafts")
401 (mu4e-trash-folder . "/school/Trash")
402 (mu4e-refile-folder . "/school/Archive")
403 (user-mail-address . "abhojwani22@nobles.edu")
404 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
405 (smtpmail-smtp-server . "smtp.gmail.com")))
408 :enter-func (lambda () (mu4e-message "Entering personal context"))
409 :leave-func (lambda () (mu4e-message "Leaving personal context"))
410 :match-func (lambda (msg)
412 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
413 :vars '((mu4e-sent-folder . "/personal/Sent")
414 (mu4e-drafts-folder . "/personal/Drafts")
415 (mu4e-trash-folder . "/personal/Trash")
416 (mu4e-refile-folder . "/personal/Archive")
417 (user-mail-address . "me@armaanb.net")
418 (smtpmail-smtp-user . "me@armaanb.net")
419 (smtpmail-smtp-server "smtp.mailbox.org")
420 (mu4e-drafts-folder . "/school/Drafts")
421 (mu4e-trash-folder . "/school/Trash")))))
422 (add-to-list 'mu4e-bookmarks
423 '(:name "Unified inbox"
424 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
426 :hook ((mu4e-compose-mode . flyspell-mode)
427 (mu4e-view-mode-hook . turn-on-visual-line-mode)))
430 #+begin_src emacs-lisp
432 (use-package calfw-org)
433 (use-package calfw-ical)
435 (defun acheam-calendar ()
438 (shell-command "vdirsyncer sync")
439 (let ((default-directory "~/.local/share/vdirsyncer/"))
440 (cfw:open-calendar-buffer
443 (cfw:ical-create-source "School" (expand-file-name "school/abhojwani22@nobles.edu.ics") "Green")
444 (cfw:ical-create-source "Personal" (expand-file-name "mailbox/Y2FsOi8vMC8zMQ.ics") "Blue")
445 (cfw:ical-create-source "Birthdays" (expand-file-name "mailbox/Y2FsOi8vMS8w.ics") "Gray")
449 Another file has more specific network configuration.
450 #+begin_src emacs-lisp
452 :config (load-file "~/.emacs.d/irc.el"))
454 (use-package circe-chanop
455 :straight (:type built-in)
458 (use-package circe-color-nicks
459 :straight (:type built-in)
463 Set EWW as default browser except for videos.
464 #+begin_src emacs-lisp
465 (defun browse-url-mpv (url &optional new-window)
467 (start-process "mpv" "*mpv*" "mpv" url))
469 (setq browse-url-handlers
471 (("youtu\\.?be" . browse-url-mpv)
472 ("." . eww-browse-url)
476 Some EWW enhancements.
477 *** Give buffer a useful name
478 #+begin_src emacs-lisp
479 ;; From https://protesilaos.com/dotemacs/
480 (defun prot-eww--rename-buffer ()
481 "Rename EWW buffer using page title or URL.
482 To be used by `eww-after-render-hook'."
483 (let ((name (if (eq "" (plist-get eww-data :title))
484 (plist-get eww-data :url)
485 (plist-get eww-data :title))))
486 (rename-buffer (format "*%s # eww*" name) t)))
488 (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
490 *** Better entrypoint
491 #+begin_src emacs-lisp
492 ;; From https://protesilaos.com/dotemacs/
493 (defun prot-eww-browse-dwim (url &optional arg)
494 "Visit a URL, maybe from `eww-prompt-history', with completion.
496 With optional prefix ARG (\\[universal-argument]) open URL in a
499 If URL does not look like a valid link, run a web query using
502 When called from an eww buffer, provide the current link as
506 (completing-read "Query:" eww-prompt-history
507 nil nil (plist-get eww-data :url) 'eww-prompt-history)
509 (eww url (if arg 4 nil)))
511 (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
514 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
515 =emacsclient --eval "(emacs-everywhere)"=.
516 #+begin_src emacs-lisp
517 (use-package emacs-everywhere)
520 #+begin_src emacs-lisp
521 (setq eshell-prompt-function
524 "\n" (eshell/pwd) " ➤ ")
525 'face '(:foreground "cyan")))
526 eshell-highlight-prompt nil)
531 #+begin_src emacs-lisp
532 (use-package lsp-mode
533 :commands (lsp lsp-deferred)
534 :custom (lsp-keymap-prefix "C-c l")
535 :hook ((lsp-mode . lsp-enable-which-key-integration)))
537 (use-package lsp-ivy)
540 :commands lsp-ui-mode
541 :custom (lsp-ui-doc-position 'bottom))
542 (use-package lsp-ui-flycheck
544 :straight (:type built-in))
547 Company-box adds icons.
548 #+begin_src emacs-lisp
551 :hook (lsp-mode . company-mode)
552 :bind (:map company-active-map
553 ("<tab>" . company-complete-selection))
555 ("<tab>" . company-indent-or-complete-common))
557 (company-minimum-prefix-length 1)
558 (setq company-dabbrev-downcase 0)
559 (company-idle-delay 0.0))
561 (use-package company-box
562 :hook (company-mode . company-box-mode))
566 #+begin_src emacs-lisp
567 (use-package lsp-pyright
568 :hook (python-mode . (lambda ()
569 (use-package lsp-pyright
570 :straight (:type built-in))
574 #+begin_src emacs-lisp
576 :hook (python-mode . blacken-mode)
578 (setq blacken-line-length 79))
581 (use-package ws-butler
583 (ws-butler-global-mode))
586 #+begin_src emacs-lisp
587 (use-package flycheck
589 (global-flycheck-mode))
591 ** Project management
592 #+begin_src emacs-lisp
593 (use-package projectile
594 :config (projectile-mode)
595 :custom ((projectile-completion-system 'ivy))
597 ("C-c p" . projectile-command-map)
599 (when (file-directory-p "~/Code")
600 (setq projectile-project-search-path '("~/Code")))
601 (setq projectile-switch-project-action #'projectile-dired))
603 (use-package counsel-projectile
605 :config (counsel-projectile-mode))
608 #+begin_src emacs-lisp
610 :straight (:type built-in)
611 :commands (dired dired-jump)
612 :custom ((dired-listing-switches "-agho --group-directories-first"))
614 (evil-collection-define-key 'normal 'dired-mode-map
615 "h" 'dired-single-up-directory
616 "l" 'dired-single-buffer))
618 (use-package dired-single
619 :commands (dired dired-jump))
621 (use-package dired-open
622 :commands (dired dired-jump)
624 (dired-open-extensions '(("png" . "feh")
627 (use-package dired-hide-dotfiles
628 :hook (dired-mode . dired-hide-dotfiles-mode)
630 (evil-collection-define-key 'normal 'dired-mode-map
631 "H" 'dired-hide-dotfiles-mode))
635 # TODO: Write a command that commits hunk, skipping staging step.
636 #+begin_src emacs-lisp
639 *** Colored diff in line number area
640 #+begin_src emacs-lisp
642 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
643 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
644 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
645 :config (global-diff-hl-mode))
647 * General text editing
649 Indent after every change.
650 #+begin_src emacs-lisp
651 (use-package aggressive-indent
652 :config (global-aggressive-indent-mode))
655 Spell check in text mode, and in prog-mode comments.
656 #+begin_src emacs-lisp
657 (dolist (hook '(text-mode-hook))
658 (add-hook hook (lambda () (flyspell-mode))))
659 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
660 (add-hook hook (lambda () (flyspell-mode -1))))
661 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
663 ** Expand tabs to spaces
664 #+begin_src emacs-lisp
665 (setq-default tab-width 2)
667 ** Copy kill ring to clipboard
668 #+begin_src emacs-lisp
669 (setq x-select-enable-clipboard t)
670 (defun copy-kill-ring-to-xorg ()
671 "Copy the current kill ring to the xorg clipboard."
673 (x-select-text (current-kill 0)))
676 #+begin_src emacs-lisp
677 (use-package browse-kill-ring)
680 Opens file where you left it.
681 #+begin_src emacs-lisp
685 Distraction free writing a la junegunn/goyo.
686 #+begin_src emacs-lisp
687 (use-package olivetti
689 (evil-leader/set-key "o" 'olivetti-mode))
693 #+begin_src emacs-lisp
694 (setq abbrev-file-name "~/.emacs.d/abbrevs")
695 (setq save-abbrevs 'silent)
696 (setq-default abbrev-mode t)
699 #+begin_src emacs-lisp
700 (setq tramp-default-method "ssh")
702 ** Don't ask about following symlinks in vc
703 #+begin_src emacs-lisp
704 (setq vc-follow-symlinks t)
707 ** Easily convert splits
708 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
709 #+begin_src emacs-lisp
710 (defun toggle-window-split ()
712 (if (= (count-windows) 2)
713 (let* ((this-win-buffer (window-buffer))
714 (next-win-buffer (window-buffer (next-window)))
715 (this-win-edges (window-edges (selected-window)))
716 (next-win-edges (window-edges (next-window)))
717 (this-win-2nd (not (and (<= (car this-win-edges)
718 (car next-win-edges))
719 (<= (cadr this-win-edges)
720 (cadr next-win-edges)))))
722 (if (= (car this-win-edges)
723 (car (window-edges (next-window))))
724 'split-window-horizontally
725 'split-window-vertically)))
726 (delete-other-windows)
727 (let ((first-win (selected-window)))
729 (if this-win-2nd (other-window 1))
730 (set-window-buffer (selected-window) this-win-buffer)
731 (set-window-buffer (next-window) next-win-buffer)
732 (select-window first-win)
733 (if this-win-2nd (other-window 1))))))
735 (define-key ctl-x-4-map "t" 'toggle-window-split)
738 #+begin_src emacs-lisp
739 (defun insert-date ()
741 (insert (format-time-string "%Y-%m-%d")))
745 #+begin_src emacs-lisp
746 (use-package ace-window
747 :bind ("M-o" . ace-window))
749 ** Kill current buffer
750 Makes "C-x k" binding faster.
751 #+begin_src emacs-lisp
752 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
756 Render OpenSCAD files, and add a preview window.
758 Personal fork just merges a PR.
759 #+begin_src emacs-lisp
760 (use-package scad-mode)
761 (use-package scad-preview
762 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
764 ** Control backup files
765 Stop backup files from spewing everywhere.
766 #+begin_src emacs-lisp
767 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
769 ** Make yes/no easier
770 #+begin_src emacs-lisp
771 (defalias 'yes-or-no-p 'y-or-n-p)
773 ** Move customize file
774 No more clogging up init.el.
775 #+begin_src emacs-lisp
776 (setq custom-file "~/.emacs.d/custom.el")
780 #+begin_src emacs-lisp
782 :commands (helpful-callable helpful-variable helpful-command helpful-key)
784 (counsel-describe-function-function #'helpful-callable)
785 (counsel-describe-variable-function #'helpful-variable)
787 ([remap describe-function] . counsel-describe-function)
788 ([remap describe-command] . helpful-command)
789 ([remap describe-variable] . counsel-describe-variable)
790 ([remap describe-key] . helpful-key))
793 #+begin_src emacs-lisp
794 (use-package epa-file
795 :straight (:type built-in)
797 (epa-file-select-keys nil)
798 (epa-file-encrypt-to '("me@armaanb.net"))
799 (password-cache-expiry (* 60 15)))
801 (use-package pinentry
802 :config (pinentry-start))
805 #+begin_src emacs-lisp
807 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
808 :custom (0x0-default-service 'envs)
809 :config (evil-leader/set-key
811 "0f" '0x0-upload-file
812 "0s" '0x0-upload-string
813 "0c" '0x0-upload-kill-ring
814 "0p" '0x0-upload-popup))
819 #+begin_src conf :tangle ~/.spectrwm.conf
824 autorun = ws[1]:/home/armaa/Code/scripts/autostart
827 #+begin_src conf :tangle ~/.spectrwm.conf
828 color_focus = rgb:ff/ff/ff
829 color_focus_maximized = rgb:ee/cc/00
830 color_unfocus = rgb:55/55/55
833 #+begin_src conf :tangle ~/.spectrwm.conf
835 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
839 #+begin_src conf :tangle ~/.spectrwm.conf
840 program[lock] = i3lock -c 000000 -ef
841 program[term] = alacritty
842 program[screenshot_all] = flameshot gui
843 program[menu] = rofi -show run # `rofi-dmenu` handles the rest
844 program[switcher] = rofi -show window
845 program[notif] = /home/armaa/Code/scripts/setter status
848 bind[switcher] = MOD+Tab
851 #+begin_src conf :tangle ~/.spectrwm.conf
852 program[paup] = /home/armaa/Code/scripts/setter audio +5
853 program[padown] = /home/armaa/Code/scripts/setter audio -5
854 program[pamute] = /home/armaa/Code/scripts/setter audio
855 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
856 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
857 program[next] = playerctl next
858 program[prev] = playerctl previous
859 program[pause] = playerctl play-pause
861 bind[padown] = XF86AudioLowerVolume
862 bind[paup] = XF86AudioRaiseVolume
863 bind[pamute] = XF86AudioMute
864 bind[brigdown] = XF86MonBrightnessDown
865 bind[brigup] = XF86MonBrightnessUp
866 bind[pause] = XF86AudioPlay
867 bind[next] = XF86AudioNext
868 bind[prev] = XF86AudioPrev
871 #+begin_src conf :tangle ~/.spectrwm.conf
872 program[h] = xdotool keyup h key --clearmodifiers Left
873 program[j] = xdotool keyup j key --clearmodifiers Down
874 program[k] = xdotool keyup k key --clearmodifiers Up
875 program[l] = xdotool keyup l key --clearmodifiers Right
877 bind[h] = Mod1 + Tab + h
878 bind[j] = Mod1 + Tab + j
879 bind[k] = Mod1 + Tab + k
880 bind[l] = Mod1 + Tab + l
883 #+begin_src conf :tangle ~/.spectrwm.conf
884 program[aerc] = alacritty -e aerc
885 program[weechat] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat; sleep 2; done"
886 program[emacs] = emacsclient -c
887 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
888 program[firefox] = firefox
889 program[thunderbird] = thunderbird
890 program[slack] = slack
892 bind[aerc] = MOD+Control+1
893 bind[weechat] = MOD+Control+2
894 bind[emacs-anywhere] = MOD+Control+3
895 bind[firefox] = MOD+Control+4
896 bind[thunderbird] = MOD+Control+5
897 bind[slack] = MOD+Control+6
898 bind[emacs] = MOD+Control+Return
903 #+begin_src shell :tangle ~/.config/zsh/zshrc
904 autoload -Uz compinit
908 unsetopt glob_complete
911 #+begin_src shell :tangle ~/.config/zsh/zshrc
915 bindkey -M vicmd "^[[3~" delete-char
916 bindkey "^[[3~" delete-char
918 autoload edit-command-line
919 zle -N edit-command-line
920 bindkey -M vicmd ^e edit-command-line
921 bindkey ^e edit-command-line
924 #+begin_src shell :tangle ~/.config/zsh/zshrc
925 setopt extended_history
927 setopt inc_append_history
928 setopt hist_ignore_dups
929 setopt hist_reduce_blanks
933 HISTFILE=~/.local/share/zsh/history
936 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
938 #+begin_src plain :tangle ~/.config/zpe/repositories
939 https://github.com/Aloxaf/fzf-tab
940 https://github.com/zdharma/fast-syntax-highlighting
941 https://github.com/rupa/z
944 #+begin_src shell :tangle ~/.config/zsh/zshrc
945 source ~/Code/zpe/zpe.sh
946 source ~/Code/admone/admone.zsh
947 source ~/.config/zsh/fzf-bindings.zsh
949 zpe-source fzf-tab/fzf-tab.zsh
950 zstyle ':completion:*:descriptions' format '[%d]'
951 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
952 zstyle ':completion:*' completer _complete
953 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' \
954 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
956 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
957 export _Z_DATA="/home/armaa/.local/share/z"
961 **** Alert after long command
962 #+begin_src shell :tangle ~/.config/zsh/zshrc
964 notify-send --urgency=low -i ${(%):-%(?.terminal.error)} \
965 ${history[$HISTCMD]%[;&|][[:space:]]##alert}
968 **** Time Zsh startup
969 #+begin_src shell :tangle ~/.config/zsh/zshrc
971 for i in $(seq 1 10); do
972 time "zsh" -i -c exit;
976 **** Update all packages
977 #+begin_src shell :tangle ~/.config/zsh/zshrc
978 color=$(tput setaf 5)
982 sudo echo "${color}== upgrading with yay ==${reset}"
985 echo "${color}== checking for pacnew files ==${reset}"
988 echo "${color}== upgrading flatpaks ==${reset}"
991 echo "${color}== upgrading zsh plugins ==${reset}"
994 echo "${color}== updating nvim plugins ==${reset}"
995 nvim +PlugUpdate +PlugUpgrade +qall
996 echo "Updated nvim plugins"
998 echo "${color}You are entirely up to date!${reset}"
1001 **** Clean all packages
1002 #+begin_src shell :tangle ~/.config/zsh/zshrc
1004 sudo echo "${color}== cleaning pacman orphans ==${reset}"
1005 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
1007 echo "${color}== cleaning flatpaks ==${reset}"
1008 flatpak remove --unused
1010 echo "${color}== cleaning zsh plugins ==${reset}"
1013 echo "${color}== cleaning nvim plugins ==${reset}"
1014 nvim +PlugClean +qall
1015 echo "Cleaned nvim plugins"
1017 echo "${color}All orphans cleaned!${reset}"
1021 #+begin_src shell :tangle ~/.config/zsh/zshrc
1024 exa -lh --icons --git --group-directories-first
1028 #+begin_src shell :tangle ~/.config/zsh/zshrc
1030 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
1031 if [ $? -eq 0 ]; then
1032 eval "$__conda_setup"
1034 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
1035 . "/opt/anaconda/etc/profile.d/conda.sh"
1037 export PATH="/opt/anaconda/bin:$PATH"
1043 **** Interact with 0x0
1044 #+begin_src shell :tangle ~/.config/zsh/zshrc
1045 zxz="https://envs.sh"
1046 0file() { curl -F"file=@$1" "$zxz" ; }
1047 0pb() { curl -F"file=@-;" "$zxz" ; }
1048 0url() { curl -F"url=$1" "$zxz" ; }
1049 0short() { curl -F"shorten=$1" "$zxz" ; }
1050 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
1053 #+begin_src shell :tangle ~/.config/zsh/zshrc
1062 #+begin_src shell :tangle ~/.config/zsh/zshrc
1063 alias bhoji-drop='ssh -p 23 root@armaanb.net'
1064 alias weechat='ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat'
1065 alias tcf='ssh root@204.48.23.68'
1066 alias ngmun='ssh root@157.245.89.25'
1067 alias prox='ssh root@192.168.1.224'
1068 alias dock='ssh root@192.168.1.225'
1069 alias jenkins='ssh root@192.168.1.226'
1070 alias envs='ssh acheam@envs.net'
1072 **** File management
1073 #+begin_src shell :tangle ~/.config/zsh/zshrc
1074 alias ls='exa -lh --icons --git --group-directories-first'
1075 alias la='exa -lha --icons --git --group-directories-first'
1076 alias df='df -h / /boot'
1078 alias free='free -h'
1083 alias grep='grep -in --exclude-dir=.git --color=auto'
1084 alias mkdir='mkdir -pv'
1085 alias unar='atool -x'
1086 alias wget='wget -e robots=off'
1087 alias lanex='~/.local/share/lxc/lxc'
1090 #+begin_src shell :tangle ~/.config/zsh/zshrc
1091 alias padm='yadm --yadm-repo ~/Code/dotfiles/repo.git'
1092 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1094 alias padu='padm add -u && padm commit && padm push && yadu'
1097 #+begin_src shell :tangle ~/.config/zsh/zshrc
1100 alias vw="nvim ~/Documents/vimwiki/index.md"
1102 **** System management
1103 #+begin_src shell :tangle ~/.config/zsh/zshrc
1104 alias jctl='journalctl -p 3 -xb'
1105 alias pkill='pkill -i'
1107 alias please='sudo $(fc -ln -1)'
1108 alias sudo='sudo ' # allows aliases to be run with sudo
1111 #+begin_src shell :tangle ~/.config/zsh/zshrc
1112 alias ping='ping -c 10'
1113 alias speed='speedtest-cli'
1114 alias ip='ip --color=auto'
1115 alias cip='curl https://armaanb.net/ip'
1116 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1117 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1120 #+begin_src shell :tangle ~/.config/zsh/zshrc
1121 alias dc='docker-compose'
1122 alias dcdu='docker-compose down && docker-compose up -d'
1125 #+begin_src shell :tangle ~/.config/zsh/zshrc
1126 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1127 iflag=fullblock status=progress'
1128 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1129 iflag=fullblock status=progress'
1130 alias ts='gen-shell -c task'
1131 alias ts='gen-shell -c task'
1132 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1133 alias news='newsboat'
1134 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1135 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1136 --restrict-filenames -o '%(title)s.%(ext)s'"
1137 alias cal="cal -3 --color=auto"
1139 **** Virtual machines, chroots
1140 #+begin_src shell :tangle ~/.config/zsh/zshrc
1141 alias ckiss="sudo chrooter ~/Virtual/kiss"
1142 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1143 alias cwindows='devour qemu-system-x86_64 \
1148 -device VGA,vgamem_mb=64 \
1150 -device hda-duplex \
1152 -net user,smb=/home/armaa/Public \
1153 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1156 #+begin_src shell :tangle ~/.config/zsh/zshrc
1158 alias zpy="zconda && ipython"
1159 alias math="ipython --profile=math"
1160 alias pypi="python setup.py sdist && twine upload dist/*"
1161 alias pip="python -m pip"
1162 alias black="black -l 79"
1165 #+begin_src shell :tangle ~/.config/zsh/zshrc
1166 alias words='gen-shell -c "words"'
1167 alias words-e='gen-shell -c "words ~E"'
1170 #+begin_src shell :tangle ~/.config/zsh/zshrc
1171 alias zathura='devour zathura'
1172 alias mpv='devour mpv'
1173 alias sql='devour sqlitebrowser'
1174 alias cad='devour openscad'
1175 alias feh='devour feh'
1177 **** Package management (Pacman)
1178 #+begin_src shell :tangle ~/.config/zsh/zshrc
1180 alias api='yay -Syu'
1181 alias apii='sudo pacman -S'
1182 alias app='yay -Rns'
1184 alias apo='yay -Qttd'
1185 alias azf='pacman -Q | fzf'
1186 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1187 alias ufetch='ufetch-arch'
1188 alias reflect='reflector --verbose --sort rate --save \
1189 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1192 #+begin_src shell :tangle ~/.config/zsh/zshrc
1193 export EDITOR="emacsclient -c"
1194 export VISUAL="$EDITOR"
1195 export TERM=xterm-256color # for compatability
1197 export GPG_TTY="$(tty)"
1198 export MANPAGER='nvim +Man!'
1201 export GTK_USE_PORTAL=1
1203 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1204 export PATH="$PATH:/home/armaa/Code/scripts"
1205 export PATH="$PATH:/home/armaa/.cargo/bin"
1206 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1207 export PATH="$PATH:/usr/sbin"
1208 export PATH="$PATH:/opt/FreeTube/freetube"
1210 export LC_ALL="en_US.UTF-8"
1211 export LC_CTYPE="en_US.UTF-8"
1212 export LANGUAGE="en_US.UTF-8"
1214 export KISS_PATH="/home/armaa/kiss/home/armaa/kiss-repo"
1215 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1216 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1217 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1218 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1219 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1223 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1226 family: JetBrains Mono Nerd Font
1233 ligatures: true # Requires ligature patch
1240 background_opacity: 1
1243 Send <RET> + modifier through
1244 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1258 Modus vivendi. Source: https://github.com/ishan9299/Nixos/blob/d4bbb7536be95b59466bb9cca4d671be46e04e81/user/alacritty/alacritty.yml#L30-L118
1259 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1263 background: '#000000'
1264 foreground: '#ffffff'
1268 background: '#ffffff'
1270 # Normal colors (except green it is from intense colors)
1281 # Bright colors [all the faint colors in the modus theme]
1292 # dim [all the intense colors in modus theme]
1305 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1306 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1307 c.TerminalInteractiveShell.editing_mode = 'vi'
1308 c.InteractiveShell.colors = 'linux'
1309 c.TerminalInteractiveShell.confirm_exit = False
1312 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1316 return x * (180 / pi)
1319 return x * (pi / 180)
1322 return (x * (pi / 180)) / unit
1334 Make MPV play a little bit smoother.
1335 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1336 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1340 For any GNU Readline programs
1341 #+begin_src plain :tangle ~/.inputrc
1346 #+begin_src conf :tangle ~/.gitconfig
1348 name = Armaan Bhojwani
1349 email = me@armaanb.net
1350 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1353 #+begin_src conf :tangle ~/.gitconfig
1355 defaultBranch = main
1358 #+begin_src conf :tangle ~/.gitconfig
1363 #+begin_src conf :tangle ~/.gitconfig
1365 smtpserver = smtp.mailbox.org
1366 smtpuser = me@armaanb.net
1367 smtpencryption = ssl
1368 smtpserverport = 465
1372 #+begin_src conf :tangle ~/.gitconfig
1377 #+begin_src conf :tangle ~/.gitconfig
1380 sclone = clone --depth 1
1386 subup = submodule update --remote
1387 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1388 mirror = git config --global alias.mirrormirror
1391 #+begin_src conf :tangle ~/.gitconfig
1396 Lightweight notification daemon.
1398 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1400 font = "JetBrains Mono Medium Nerd Font 11"
1402 format = "<b>%s</b>\n%b"
1404 indicate_hidden = yes
1407 show_age_threshold = 60
1410 geometry = "400x5-10+10"
1412 idle_threshold = 120
1414 sticky_history = yes
1416 separator_height = 4
1418 horizontal_padding = 8
1420 separator_color = "#ffffff"
1421 startup_notification = false
1424 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1431 close_all = mod4+shift+c
1432 history = mod4+ctrl+c
1435 background = "#222222"
1436 foreground = "#ffffff"
1437 highlight = "#ffffff"
1441 background = "#222222"
1442 foreground = "#ffffff"
1443 highlight = "#ffffff"
1447 background = "#222222"
1448 foreground = "#a60000"
1449 highlight = "#ffffff"
1453 Modus vivendi theme that extends DarkBlue.
1454 #+begin_src plain :tangle ~/.config/rofi/config.rasi
1455 @import "/usr/share/rofi/themes/DarkBlue.rasi"
1457 white: rgba ( 255, 255, 255, 100 % );
1459 selected-normal-background: @white;
1460 separatorcolor: @white;
1461 background: rgba ( 34, 34, 34, 100 % );
1470 #+begin_src plain :tangle ~/.config/zathura/zathurarc
1472 map <A-b> toggle_statusbar
1473 set selection-clipboard clipboard
1476 set window-title-basename "true"
1477 set selection-clipboard "clipboard"
1480 #+begin_src plain :tangle ~/.config/zathura/zathurarc
1481 set default-bg "#000000"
1482 set default-fg "#ffffff"
1483 set render-loading true
1484 set render-loading-bg "#000000"
1485 set render-loading-fg "#ffffff"
1487 set recolor-lightcolor "#000000" # bg
1488 set recolor-darkcolor "#ffffff" # fg