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))
224 #+begin_src emacs-lisp
225 (evil-set-undo-system 'undo-tree)
227 ** Number incrementing
229 #+begin_src emacs-lisp
230 (use-package evil-numbers
231 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
232 :bind (:map evil-normal-state-map
233 ("C-M-a" . evil-numbers/inc-at-pt)
234 ("C-M-x" . evil-numbers/dec-at-pt)))
238 #+begin_src emacs-lisp
239 (use-package evil-org
241 :hook (org-mode . evil-org-mode)
243 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
244 (use-package evil-org-agenda
245 :straight (:type built-in)
248 (evil-org-agenda-set-keys))
251 #+begin_src emacs-lisp
252 (evil-leader/set-key-for-mode 'org-mode
253 "T" 'org-show-todo-tree
255 "c" 'org-archive-subtree)
259 #+begin_src emacs-lisp
261 :straight (:type built-in)
262 :commands (org-capture org-agenda)
264 (org-ellipsis " â–¾")
265 (org-agenda-start-with-log-mode t)
266 (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
268 (org-log-into-drawer t)
269 (org-src-tab-acts-natively t)
270 (org-src-fontify-natively t)
271 (org-startup-indented t)
272 (org-hide-emphasis-markers t)
273 (org-fontify-whole-block-delimiter-line nil)
274 :bind ("C-c a" . org-agenda))
277 #+begin_src emacs-lisp
278 (use-package org-tempo
280 :straight (:type built-in)
282 ;; TODO: There's gotta be a more efficient way to write this
283 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
284 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
285 (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
286 (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
287 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
288 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
289 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
290 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc"))
291 (add-to-list 'org-structure-template-alist '("ro" . "src plain :tangle ~/.config/rofi/config.rasi")))
295 Simple, but not too simple autocompletion.
296 #+begin_src emacs-lisp
298 :bind (("C-s" . swiper)
299 :map ivy-minibuffer-map
300 ("TAB" . ivy-alt-done)
301 :map ivy-switch-buffer-map
302 ("M-d" . ivy-switch-buffer-kill))
306 #+begin_src emacs-lisp
307 (use-package ivy-rich
309 :config (ivy-rich-mode))
313 #+begin_src emacs-lisp
315 :bind (("C-M-j" . 'counsel-switch-buffer)
316 :map minibuffer-local-map
317 ("C-r" . 'counsel-minibuffer-history))
318 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
319 :config (counsel-mode))
321 ** Remember frequent commands
322 #+begin_src emacs-lisp
323 (use-package ivy-prescient
326 (ivy-prescient-enable-filtering nil)
328 (prescient-persist-mode)
329 (ivy-prescient-mode))
332 Better search utility.
333 #+begin_src emacs-lisp
338 Use elfeed for RSS. I have another file with all the feeds in it.
339 #+begin_src emacs-lisp
341 :bind (("C-c e" . elfeed))
343 (load "~/.emacs.d/feeds.el")
344 (add-hook 'elfeed-new-entry-hook
345 (elfeed-make-tagger :feed-url "youtube\\.com"
347 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
349 (use-package elfeed-goodies
351 :config (elfeed-goodies/setup))
354 Use mu4e for reading emails.
356 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.
358 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.
359 #+begin_src emacs-lisp
360 (use-package smtpmail
361 :straight (:type built-in))
363 :load-path "/usr/share/emacs/site-lisp/mu4e"
364 :bind (("C-c m" . mu4e))
366 (setq user-full-name "Armaan Bhojwani"
367 smtpmail-local-domain "armaanb.net"
368 smtpmail-stream-type 'ssl
369 smtpmail-smtp-service '465
370 mu4e-change-filenames-when-moving t
371 message-kill-buffer-on-exit t
372 mu4e-get-mail-command "offlineimap -q"
373 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
374 message-citation-line-function 'message-insert-formatted-citation-line
375 mu4e-context-policy "pick-first"
377 `( ,(make-mu4e-context
379 :enter-func (lambda () (mu4e-message "Entering school context"))
380 :leave-func (lambda () (mu4e-message "Leaving school context"))
381 :match-func (lambda (msg)
383 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
384 :vars '( (user-mail-address . "abhojwani22@nobles.edu")
385 (mu4e-sent-folder . "/school/Sent")
386 (mu4e-drafts-folder . "/school/Drafts")
387 (mu4e-trash-folder . "/school/Trash")
388 (mu4e-refile-folder . "/school/Archive")
389 (user-mail-address . "abhojwani22@nobles.edu")
390 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
391 (smtpmail-smtp-server . "smtp.gmail.com")))
394 :enter-func (lambda () (mu4e-message "Entering personal context"))
395 :leave-func (lambda () (mu4e-message "Leaving personal context"))
396 :match-func (lambda (msg)
398 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
400 (mu4e-sent-folder . "/personal/Sent")
401 (mu4e-drafts-folder . "/personal/Drafts")
402 (mu4e-trash-folder . "/personal/Trash")
403 (mu4e-refile-folder . "/personal/Archive")
404 (user-mail-address . "me@armaanb.net")
405 (smtpmail-smtp-user . "me@armaanb.net")
406 (smtpmail-smtp-server "smtp.mailbox.org")
407 (mu4e-drafts-folder . "/school/Drafts")
408 (mu4e-trash-folder . "/school/Trash")))))
409 (add-to-list 'mu4e-bookmarks
410 '(:name "Unified inbox"
411 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
415 #+begin_src emacs-lisp
417 (use-package calfw-org)
418 (use-package calfw-ical)
420 (defun acheam-calendar ()
423 (shell-command "vdirsyncer sync")
424 (let ((default-directory "~/.local/share/vdirsyncer/"))
425 (cfw:open-calendar-buffer
428 (cfw:ical-create-source "School" (expand-file-name "school/abhojwani22@nobles.edu.ics") "Green")
429 (cfw:ical-create-source "Personal" (expand-file-name "mailbox/Y2FsOi8vMC8zMQ.ics") "Blue")
430 (cfw:ical-create-source "Birthdays" (expand-file-name "mailbox/Y2FsOi8vMS8w.ics") "Gray")
434 Another file has more specific network configuration.
435 #+begin_src emacs-lisp
437 :config (load-file "~/.emacs.d/irc.el"))
439 (use-package circe-chanop
440 :straight (:type built-in)
443 (use-package circe-color-nicks
444 :straight (:type built-in)
448 Set EWW as default browser except for videos.
449 #+begin_src emacs-lisp
450 (defun browse-url-mpv (url &optional new-window)
452 (start-process "mpv" "*mpv*" "mpv" url))
454 (setq browse-url-handlers
456 (("youtu\\.?be" . browse-url-mpv)
457 ("." . eww-browse-url)
461 Some EWW enhancements.
462 *** Give buffer a useful name
463 #+begin_src emacs-lisp
464 ;; From https://protesilaos.com/dotemacs/
465 (defun prot-eww--rename-buffer ()
466 "Rename EWW buffer using page title or URL.
467 To be used by `eww-after-render-hook'."
468 (let ((name (if (eq "" (plist-get eww-data :title))
469 (plist-get eww-data :url)
470 (plist-get eww-data :title))))
471 (rename-buffer (format "*%s # eww*" name) t)))
473 (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
475 *** Better entrypoint
476 #+begin_src emacs-lisp
477 ;; From https://protesilaos.com/dotemacs/
478 (defun prot-eww-browse-dwim (url &optional arg)
479 "Visit a URL, maybe from `eww-prompt-history', with completion.
481 With optional prefix ARG (\\[universal-argument]) open URL in a
484 If URL does not look like a valid link, run a web query using
487 When called from an eww buffer, provide the current link as
491 (completing-read "Query:" eww-prompt-history
492 nil nil (plist-get eww-data :url) 'eww-prompt-history)
494 (eww url (if arg 4 nil)))
496 (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
499 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
500 =emacsclient --eval "(emacs-everywhere)"=.
501 #+begin_src emacs-lisp
502 (use-package emacs-everywhere)
507 #+begin_src emacs-lisp
508 (use-package lsp-mode
509 :commands (lsp lsp-deferred)
510 :custom (lsp-keymap-prefix "C-c l")
511 :hook ((lsp-mode . lsp-enable-which-key-integration)))
513 (use-package lsp-ivy)
516 :commands lsp-ui-mode
517 :custom (lsp-ui-doc-position 'bottom))
518 (use-package lsp-ui-flycheck
520 :straight (:type built-in))
523 Company-box adds icons.
524 #+begin_src emacs-lisp
527 :hook (lsp-mode . company-mode)
528 :bind (:map company-active-map
529 ("<tab>" . company-complete-selection))
531 ("<tab>" . company-indent-or-complete-common))
533 (company-minimum-prefix-length 1)
534 (setq company-dabbrev-downcase 0)
535 (company-idle-delay 0.0))
537 (use-package company-box
538 :hook (company-mode . company-box-mode))
542 #+begin_src emacs-lisp
543 (use-package lsp-pyright
544 :hook (python-mode . (lambda ()
545 (use-package lsp-pyright
546 :straight (:type built-in))
550 #+begin_src emacs-lisp
552 :hook (python-mode . blacken-mode)
554 (setq blacken-line-length 79))
557 (use-package ws-butler
559 (ws-butler-global-mode))
562 #+begin_src emacs-lisp
563 (use-package flycheck
565 (global-flycheck-mode))
567 ** Project management
568 #+begin_src emacs-lisp
569 (use-package projectile
570 :config (projectile-mode)
571 :custom ((projectile-completion-system 'ivy))
573 ("C-c p" . projectile-command-map)
575 (when (file-directory-p "~/Code")
576 (setq projectile-project-search-path '("~/Code")))
577 (setq projectile-switch-project-action #'projectile-dired))
579 (use-package counsel-projectile
581 :config (counsel-projectile-mode))
584 #+begin_src emacs-lisp
586 :straight (:type built-in)
587 :commands (dired dired-jump)
588 :custom ((dired-listing-switches "-agho --group-directories-first"))
590 (evil-collection-define-key 'normal 'dired-mode-map
591 "h" 'dired-single-up-directory
592 "l" 'dired-single-buffer))
594 (use-package dired-single
595 :commands (dired dired-jump))
597 (use-package dired-open
598 :commands (dired dired-jump)
600 (dired-open-extensions '(("png" . "feh")
603 (use-package dired-hide-dotfiles
604 :hook (dired-mode . dired-hide-dotfiles-mode)
606 (evil-collection-define-key 'normal 'dired-mode-map
607 "H" 'dired-hide-dotfiles-mode))
611 # TODO: Write a command that commits hunk, skipping staging step.
612 #+begin_src emacs-lisp
615 *** Colored diff in line number area
616 #+begin_src emacs-lisp
618 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
619 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
620 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
621 :config (global-diff-hl-mode))
623 * General text editing
625 Indent after every change.
626 #+begin_src emacs-lisp
627 (use-package aggressive-indent
628 :config (global-aggressive-indent-mode))
631 Spell check in text mode, and in prog-mode comments.
632 #+begin_src emacs-lisp
633 (dolist (hook '(text-mode-hook))
634 (add-hook hook (lambda () (flyspell-mode))))
635 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
636 (add-hook hook (lambda () (flyspell-mode -1))))
637 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
639 ** Expand tabs to spaces
640 #+begin_src emacs-lisp
641 (setq-default tab-width 2)
643 ** Copy kill ring to clipboard
644 #+begin_src emacs-lisp
645 (setq x-select-enable-clipboard t)
646 (defun copy-kill-ring-to-xorg ()
647 "Copy the current kill ring to the xorg clipboard."
649 (x-select-text (current-kill 0)))
652 #+begin_src emacs-lisp
653 (use-package browse-kill-ring)
656 Opens file where you left it.
657 #+begin_src emacs-lisp
661 Distraction free writing a la junegunn/goyo.
662 #+begin_src emacs-lisp
663 (use-package olivetti
665 (evil-leader/set-key "o" 'olivetti-mode))
669 #+begin_src emacs-lisp
670 (setq abbrev-file-name "~/.emacs.d/abbrevs")
671 (setq save-abbrevs 'silent)
672 (setq-default abbrev-mode t)
675 #+begin_src emacs-lisp
676 (setq tramp-default-method "ssh")
679 ** Easily convert splits
680 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
681 #+begin_src emacs-lisp
682 (defun toggle-window-split ()
684 (if (= (count-windows) 2)
685 (let* ((this-win-buffer (window-buffer))
686 (next-win-buffer (window-buffer (next-window)))
687 (this-win-edges (window-edges (selected-window)))
688 (next-win-edges (window-edges (next-window)))
689 (this-win-2nd (not (and (<= (car this-win-edges)
690 (car next-win-edges))
691 (<= (cadr this-win-edges)
692 (cadr next-win-edges)))))
694 (if (= (car this-win-edges)
695 (car (window-edges (next-window))))
696 'split-window-horizontally
697 'split-window-vertically)))
698 (delete-other-windows)
699 (let ((first-win (selected-window)))
701 (if this-win-2nd (other-window 1))
702 (set-window-buffer (selected-window) this-win-buffer)
703 (set-window-buffer (next-window) next-win-buffer)
704 (select-window first-win)
705 (if this-win-2nd (other-window 1))))))
707 (define-key ctl-x-4-map "t" 'toggle-window-split)
710 #+begin_src emacs-lisp
711 (defun insert-date ()
713 (insert (format-time-string "%Y-%m-%d")))
717 #+begin_src emacs-lisp
718 (use-package ace-window
719 :bind ("M-o" . ace-window))
721 ** Kill current buffer
722 Makes "C-x k" binding faster.
723 #+begin_src emacs-lisp
724 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
728 Render OpenSCAD files, and add a preview window.
730 Personal fork just merges a PR.
731 #+begin_src emacs-lisp
732 (use-package scad-mode)
733 (use-package scad-preview
734 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
736 ** Control backup files
737 Stop backup files from spewing everywhere.
738 #+begin_src emacs-lisp
739 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
741 ** Make yes/no easier
742 #+begin_src emacs-lisp
743 (defalias 'yes-or-no-p 'y-or-n-p)
745 ** Move customize file
746 No more clogging up init.el.
747 #+begin_src emacs-lisp
748 (setq custom-file "~/.emacs.d/custom.el")
752 #+begin_src emacs-lisp
754 :commands (helpful-callable helpful-variable helpful-command helpful-key)
756 (counsel-describe-function-function #'helpful-callable)
757 (counsel-describe-variable-function #'helpful-variable)
759 ([remap describe-function] . counsel-describe-function)
760 ([remap describe-command] . helpful-command)
761 ([remap describe-variable] . counsel-describe-variable)
762 ([remap describe-key] . helpful-key))
765 #+begin_src emacs-lisp
766 (use-package epa-file
767 :straight (:type built-in)
769 (epa-file-select-keys nil)
770 (epa-file-encrypt-to '("me@armaanb.net"))
771 (password-cache-expiry (* 60 15)))
773 (use-package pinentry
774 :config (pinentry-start))
777 #+begin_src emacs-lisp
779 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
780 :custom (0x0-default-service 'envs)
781 :config (evil-leader/set-key
783 "0f" '0x0-upload-file
784 "0s" '0x0-upload-string
785 "0c" '0x0-upload-kill-ring
786 "0p" '0x0-upload-popup))
791 #+begin_src conf :tangle ~/.spectrwm.conf
796 autorun = ws[1]:/home/armaa/Code/scripts/autostart
799 #+begin_src conf :tangle ~/.spectrwm.conf
800 color_focus = rgb:00/d3/d0
801 color_focus_maximized = rgb:ee/cc/00
802 color_unfocus = rgb:55/55/55
805 #+begin_src conf :tangle ~/.spectrwm.conf
807 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
811 #+begin_src conf :tangle ~/.spectrwm.conf
812 program[lock] = i3lock -c 000000 -ef
813 program[term] = alacritty
814 program[screenshot_all] = flameshot gui
815 program[menu] = rofi -show run # `rofi-dmenu` handles the rest
816 program[switcher] = rofi -show window
817 program[notif] = /home/armaa/Code/scripts/setter status
820 bind[switcher] = MOD+Tab
823 #+begin_src conf :tangle ~/.spectrwm.conf
824 program[paup] = /home/armaa/Code/scripts/setter audio +5
825 program[padown] = /home/armaa/Code/scripts/setter audio -5
826 program[pamute] = /home/armaa/Code/scripts/setter audio
827 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
828 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
829 program[next] = playerctl next
830 program[prev] = playerctl previous
831 program[pause] = playerctl play-pause
833 bind[padown] = XF86AudioLowerVolume
834 bind[paup] = XF86AudioRaiseVolume
835 bind[pamute] = XF86AudioMute
836 bind[brigdown] = XF86MonBrightnessDown
837 bind[brigup] = XF86MonBrightnessUp
838 bind[pause] = XF86AudioPlay
839 bind[next] = XF86AudioNext
840 bind[prev] = XF86AudioPrev
843 #+begin_src conf :tangle ~/.spectrwm.conf
844 program[h] = xdotool keyup h key --clearmodifiers Left
845 program[j] = xdotool keyup j key --clearmodifiers Down
846 program[k] = xdotool keyup k key --clearmodifiers Up
847 program[l] = xdotool keyup l key --clearmodifiers Right
849 bind[h] = Mod1 + Tab + h
850 bind[j] = Mod1 + Tab + j
851 bind[k] = Mod1 + Tab + k
852 bind[l] = Mod1 + Tab + l
855 #+begin_src conf :tangle ~/.spectrwm.conf
856 program[aerc] = alacritty -e aerc
857 program[weechat] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat; sleep 2; done"
858 program[emacs] = emacsclient -c
859 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
860 program[firefox] = firefox
861 program[thunderbird] = thunderbird
862 program[slack] = slack
864 bind[aerc] = MOD+Control+s
865 bind[weechat] = MOD+Control+d
866 bind[emacs] = MOD+Control+Return
867 bind[emacs-anywhere] = MOD+Control+f
868 bind[firefox] = MOD+Control+u
869 bind[thunderbird] = MOD+Control+i
870 bind[slack] = MOD+Control+o
875 #+begin_src shell :tangle ~/.config/zsh/zshrc
876 autoload -Uz compinit
880 unsetopt glob_complete
883 #+begin_src shell :tangle ~/.config/zsh/zshrc
887 bindkey -M vicmd "^[[3~" delete-char
888 bindkey "^[[3~" delete-char
890 autoload edit-command-line
891 zle -N edit-command-line
892 bindkey -M vicmd ^e edit-command-line
893 bindkey ^e edit-command-line
896 #+begin_src shell :tangle ~/.config/zsh/zshrc
897 setopt extended_history
899 setopt inc_append_history
900 setopt hist_ignore_dups
901 setopt hist_reduce_blanks
905 HISTFILE=~/.local/share/zsh/history
908 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
910 #+begin_src plain :tangle ~/.config/zpe/repositories
911 https://github.com/Aloxaf/fzf-tab
912 https://github.com/zdharma/fast-syntax-highlighting
913 https://github.com/rupa/z
916 #+begin_src shell :tangle ~/.config/zsh/zshrc
917 source ~/Code/zpe/zpe.sh
918 source ~/Code/admone/admone.zsh
919 source ~/.config/zsh/fzf-bindings.zsh
921 zpe-source fzf-tab/fzf-tab.zsh
922 zstyle ':completion:*:descriptions' format '[%d]'
923 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
924 zstyle ':completion:*' completer _complete
925 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' \
926 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
928 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
929 export _Z_DATA="/home/armaa/.local/share/z"
933 **** Alert after long command
934 #+begin_src shell :tangle ~/.config/zsh/zshrc
936 notify-send --urgency=low -i ${(%):-%(?.terminal.error)} \
937 ${history[$HISTCMD]%[;&|][[:space:]]##alert}
940 **** Time Zsh startup
941 #+begin_src shell :tangle ~/.config/zsh/zshrc
943 for i in $(seq 1 10); do
944 time "zsh" -i -c exit;
948 **** Update all packages
949 #+begin_src shell :tangle ~/.config/zsh/zshrc
950 color=$(tput setaf 5)
954 sudo echo "${color}== upgrading with yay ==${reset}"
957 echo "${color}== checking for pacnew files ==${reset}"
960 echo "${color}== upgrading flatpaks ==${reset}"
963 echo "${color}== upgrading zsh plugins ==${reset}"
966 echo "${color}== updating nvim plugins ==${reset}"
967 nvim +PlugUpdate +PlugUpgrade +qall
968 echo "Updated nvim plugins"
970 echo "${color}You are entirely up to date!${reset}"
973 **** Clean all packages
974 #+begin_src shell :tangle ~/.config/zsh/zshrc
976 sudo echo "${color}== cleaning pacman orphans ==${reset}"
977 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
979 echo "${color}== cleaning flatpaks ==${reset}"
980 flatpak remove --unused
982 echo "${color}== cleaning zsh plugins ==${reset}"
985 echo "${color}== cleaning nvim plugins ==${reset}"
986 nvim +PlugClean +qall
987 echo "Cleaned nvim plugins"
989 echo "${color}All orphans cleaned!${reset}"
993 #+begin_src shell :tangle ~/.config/zsh/zshrc
996 exa -lh --icons --git --group-directories-first
1000 #+begin_src shell :tangle ~/.config/zsh/zshrc
1002 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
1003 if [ $? -eq 0 ]; then
1004 eval "$__conda_setup"
1006 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
1007 . "/opt/anaconda/etc/profile.d/conda.sh"
1009 export PATH="/opt/anaconda/bin:$PATH"
1015 **** Interact with 0x0
1016 #+begin_src shell :tangle ~/.config/zsh/zshrc
1017 zxz="https://envs.sh"
1018 0file() { curl -F"file=@$1" "$zxz" ; }
1019 0pb() { curl -F"file=@-;" "$zxz" ; }
1020 0url() { curl -F"url=$1" "$zxz" ; }
1021 0short() { curl -F"shorten=$1" "$zxz" ; }
1022 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
1025 #+begin_src shell :tangle ~/.config/zsh/zshrc
1034 #+begin_src shell :tangle ~/.config/zsh/zshrc
1035 alias bhoji-drop='ssh -p 23 root@armaanb.net'
1036 alias weechat='ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat'
1037 alias tcf='ssh root@204.48.23.68'
1038 alias ngmun='ssh root@157.245.89.25'
1039 alias prox='ssh root@192.168.1.224'
1040 alias dock='ssh root@192.168.1.225'
1041 alias jenkins='ssh root@192.168.1.226'
1042 alias envs='ssh acheam@envs.net'
1044 **** File management
1045 #+begin_src shell :tangle ~/.config/zsh/zshrc
1046 alias ls='exa -lh --icons --git --group-directories-first'
1047 alias la='exa -lha --icons --git --group-directories-first'
1048 alias df='df -h / /boot'
1050 alias free='free -h'
1055 alias grep='grep -in --exclude-dir=.git --color=auto'
1056 alias mkdir='mkdir -pv'
1057 alias unar='atool -x'
1058 alias wget='wget -e robots=off'
1059 alias lanex='~/.local/share/lxc/lxc'
1062 #+begin_src shell :tangle ~/.config/zsh/zshrc
1063 alias padm='yadm --yadm-repo ~/Code/dotfiles/repo.git'
1064 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1066 alias padu='padm add -u && padm commit && padm push && yadu'
1069 #+begin_src shell :tangle ~/.config/zsh/zshrc
1072 alias vw="nvim ~/Documents/vimwiki/index.md"
1074 **** System management
1075 #+begin_src shell :tangle ~/.config/zsh/zshrc
1076 alias jctl='journalctl -p 3 -xb'
1077 alias pkill='pkill -i'
1079 alias please='sudo $(fc -ln -1)'
1080 alias sudo='sudo ' # allows aliases to be run with sudo
1083 #+begin_src shell :tangle ~/.config/zsh/zshrc
1084 alias ping='ping -c 10'
1085 alias speed='speedtest-cli'
1086 alias ip='ip --color=auto'
1087 alias cip='curl https://armaanb.net/ip'
1088 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1089 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1092 #+begin_src shell :tangle ~/.config/zsh/zshrc
1093 alias dc='docker-compose'
1094 alias dcdu='docker-compose down && docker-compose up -d'
1097 #+begin_src shell :tangle ~/.config/zsh/zshrc
1098 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1099 iflag=fullblock status=progress'
1100 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1101 iflag=fullblock status=progress'
1102 alias ts='gen-shell -c task'
1103 alias ts='gen-shell -c task'
1104 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1105 alias news='newsboat'
1106 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1107 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1108 --restrict-filenames -o '%(title)s.%(ext)s'"
1109 alias cal="cal -3 --color=auto"
1111 **** Virtual machines, chroots
1112 #+begin_src shell :tangle ~/.config/zsh/zshrc
1113 alias ckiss="sudo chrooter ~/Virtual/kiss"
1114 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1115 alias cwindows='devour qemu-system-x86_64 \
1120 -device VGA,vgamem_mb=64 \
1122 -device hda-duplex \
1124 -net user,smb=/home/armaa/Public \
1125 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1128 #+begin_src shell :tangle ~/.config/zsh/zshrc
1130 alias zpy="zconda && ipython"
1131 alias math="ipython --profile=math"
1132 alias pypi="python setup.py sdist && twine upload dist/*"
1133 alias pip="python -m pip"
1134 alias black="black -l 79"
1137 #+begin_src shell :tangle ~/.config/zsh/zshrc
1138 alias words='gen-shell -c "words"'
1139 alias words-e='gen-shell -c "words ~E"'
1142 #+begin_src shell :tangle ~/.config/zsh/zshrc
1143 alias zathura='devour zathura'
1144 alias mpv='devour mpv'
1145 alias sql='devour sqlitebrowser'
1146 alias cad='devour openscad'
1147 alias feh='devour feh'
1149 **** Package management (Pacman)
1150 #+begin_src shell :tangle ~/.config/zsh/zshrc
1152 alias api='yay -Syu'
1153 alias apii='sudo pacman -S'
1154 alias app='yay -Rns'
1156 alias apo='yay -Qttd'
1157 alias azf='pacman -Q | fzf'
1158 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1159 alias ufetch='ufetch-arch'
1160 alias reflect='reflector --verbose --sort rate --save \
1161 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1164 #+begin_src shell :tangle ~/.config/zsh/zshrc
1165 export EDITOR="emacsclient -c"
1166 export VISUAL="$VISUAL"
1167 export TERM=xterm-256color # for compatability
1169 export GPG_TTY="$(tty)"
1170 export MANPAGER='nvim +Man!'
1173 export GTK_USE_PORTAL=1
1175 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1176 export PATH="$PATH:/home/armaa/Code/scripts"
1177 export PATH="$PATH:/home/armaa/.cargo/bin"
1178 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1179 export PATH="$PATH:/usr/sbin"
1180 export PATH="$PATH:/opt/FreeTube/freetube"
1182 export LC_ALL="en_US.UTF-8"
1183 export LC_CTYPE="en_US.UTF-8"
1184 export LANGUAGE="en_US.UTF-8"
1186 export KISS_PATH="/home/armaa/kiss/home/armaa/kiss-repo"
1187 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1188 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1189 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1190 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1191 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1195 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1198 family: JetBrains Mono Nerd Font
1205 ligatures: true # Requires ligature patch
1212 background_opacity: 1
1215 Send <RET> + modifier through
1216 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1230 Modus vivendi. Source: https://github.com/ishan9299/Nixos/blob/d4bbb7536be95b59466bb9cca4d671be46e04e81/user/alacritty/alacritty.yml#L30-L118
1231 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1235 background: '#000000'
1236 foreground: '#ffffff'
1240 background: '#777777'
1242 # Normal colors (except green it is from intense colors)
1253 # Bright colors [all the faint colors in the modus theme]
1264 # dim [all the intense colors in modus theme]
1277 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1278 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1279 c.TerminalInteractiveShell.editing_mode = 'vi'
1280 c.InteractiveShell.colors = 'linux'
1281 c.TerminalInteractiveShell.confirm_exit = False
1284 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1288 return x * (180 / pi)
1291 return x * (pi / 180)
1294 return (x * (pi / 180)) / unit
1306 Make MPV play a little bit smoother.
1307 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1308 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1312 For any GNU Readline programs
1313 #+begin_src plain :tangle ~/.inputrc
1318 #+begin_src conf :tangle ~/.gitconfig
1320 name = Armaan Bhojwani
1321 email = me@armaanb.net
1322 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1325 #+begin_src conf :tangle ~/.gitconfig
1327 defaultBranch = main
1330 #+begin_src conf :tangle ~/.gitconfig
1335 #+begin_src conf :tangle ~/.gitconfig
1337 smtpserver = smtp.mailbox.org
1338 smtpuser = me@armaanb.net
1339 smtpencryption = ssl
1340 smtpserverport = 465
1344 #+begin_src conf :tangle ~/.gitconfig
1349 #+begin_src conf :tangle ~/.gitconfig
1352 sclone = clone --depth 1
1358 subup = submodule update --remote
1359 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1360 mirror = git config --global alias.mirrormirror
1363 #+begin_src conf :tangle ~/.gitconfig
1368 Lightweight notification daemon.
1370 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1372 font = "JetBrains Mono Medium Nerd Font 11"
1374 format = "<b>%s</b>\n%b"
1376 indicate_hidden = yes
1379 show_age_threshold = 60
1382 geometry = "400x5-10+10"
1384 idle_threshold = 120
1386 sticky_history = yes
1388 separator_height = 4
1390 horizontal_padding = 8
1392 separator_color = "#777777"
1393 startup_notification = false
1396 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1403 close_all = mod4+shift+c
1404 history = mod4+ctrl+c
1407 background = "#222222"
1408 foreground = "#ffffff"
1409 highlight = "#777777"
1413 background = "#222222"
1414 foreground = "#ffffff"
1415 highlight = "#777777"
1419 background = "#222222"
1420 foreground = "#a60000"
1421 highlight = "#777777"
1425 Modus vivendi theme that extends DarkBlue.
1426 #+begin_src plain :tangle ~/.config/rofi/config.rasi
1427 @import "/usr/share/rofi/themes/DarkBlue.rasi"
1429 selected-normal-foreground: rgba ( 0, 0, 0, 100 % );
1430 foreground: rgba ( 255, 255, 255, 100 % );
1431 background: rgba ( 0, 0, 0, 100 % );
1432 lightfg: rgba ( 255, 255, 255, 100 % );
1433 selected-normal-background: rgba ( 255, 255, 255, 100 % );