]> git.armaanb.net Git - config.org.git/blob - config.org
xresources: add preliminary config
[config.org.git] / config.org
1 #+TITLE: System Configuration
2 #+DESCRIPTION: Personal system configuration in org-mode format.
3 #+AUTHOR: Armaan Bhojwani
4 #+EMAIL: me@armaanb.net
5
6 * Welcome
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!
8 ** Compatability
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.
10 ** Choices
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.
12
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.
14
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.
16 ** TODOs
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
19 - Offlineimap
20 - irc.el
21 ** License
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.
23 * Package management
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)
28   (let ((bootstrap-file
29          (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
30         (bootstrap-version 5))
31     (unless (file-exists-p bootstrap-file)
32       (with-current-buffer
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))
39 #+end_src
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)
44 #+end_src
45 * Visual options
46 ** Theme
47 Very nice high contrast theme.
48
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)
59 #+end_src
60 ** Tree-sitter
61 #+begin_src emacs-lisp
62   (use-package tree-sitter-langs)
63   (use-package tree-sitter
64     :config (global-tree-sitter-mode)
65     :hook (tree-sitter-after-on-hook . tree-sitter-hl-mode))
66 #+end_src
67 ** Typography
68 *** Font
69 Great programming font with ligatures.
70 #+begin_src emacs-lisp
71   (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
72 #+end_src
73 *** Ligatures
74 #+begin_src emacs-lisp
75   (use-package ligature
76     :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
77     :config
78     (ligature-set-ligatures
79      '(prog-mode text-mode)
80      '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "/=" "/=="
81        "/>" "//" "/*" "*>" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
82        "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>"
83        "<-|" "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>"
84        "</" "<*" "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>"
85        ":=" "::=" "=>>" "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!=="
86        "!!" "!=" ">]" ">:" ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&"
87        "&&" "|||>" "||>" "|>" "|]" "|}" "|=>" "|->" "|=" "||-" "|-"
88        "||=" "||" ".." ".?" ".=" ".-" "..<" "..." "+++" "+>" "++"
89        "[||]" "[<" "[|" "{|" "?." "?=" "?:" "##" "###" "####" "#["
90        "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_" "__" "~~"
91        "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
92     (global-ligature-mode t))
93 #+end_src
94 *** Emoji
95 #+begin_src emacs-lisp
96   (use-package emojify
97     :config (global-emojify-mode))
98
99   ;; http://ergoemacs.org/emacs/emacs_list_and_set_font.html
100   (set-fontset-font
101    t
102    '(#x1f300 . #x1fad0)
103    (cond
104     ((member "Twitter Color Emoji" (font-family-list)) "Twitter Color Emoji")
105     ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
106     ((member "Noto Emoji" (font-family-list)) "Noto Emoji")))
107 #+end_src
108 ** Line numbers
109 Display relative line numbers except in some modes
110 #+begin_src emacs-lisp
111   (global-display-line-numbers-mode)
112   (setq display-line-numbers-type 'relative)
113   (dolist (no-line-num '(term-mode-hook
114                          pdf-view-mode-hook
115                          shell-mode-hook
116                          org-mode-hook
117                          eshell-mode-hook))
118     (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
119 #+end_src
120 ** Highlight matching parenthesis
121 #+begin_src emacs-lisp
122   (use-package paren
123     :config (show-paren-mode)
124     :custom (show-paren-style 'parenthesis))
125 #+end_src
126 ** Modeline
127 *** Show current function
128 #+begin_src emacs-lisp
129   (which-function-mode)
130 #+end_src
131 *** Make position in file more descriptive
132 Show current column and file size.
133 #+begin_src emacs-lisp
134   (column-number-mode)
135   (size-indication-mode)
136 #+end_src
137 *** Hide minor modes
138 #+begin_src emacs-lisp
139   (use-package minions
140     :config (minions-mode))
141 #+end_src
142 ** Word count
143 #+begin_src emacs-lisp
144  (use-package wc-mode
145    :straight (wc-mode :type git :host github :repo "bnbeckwith/wc-mode")
146    :hook (text-mode-hook . wc-mode))
147 #+end_src
148 ** Ruler
149 Show a ruler at a certain number of chars depending on mode.
150 #+begin_src emacs-lisp
151   (global-display-fill-column-indicator-mode)
152 #+end_src
153 ** Keybinding hints
154 Whenever starting a key chord, show possible future steps.
155 #+begin_src emacs-lisp
156   (use-package which-key
157     :config (which-key-mode)
158     :custom (which-key-idle-delay 0.3))
159 #+end_src
160 ** Highlight TODOs in comments
161 #+begin_src emacs-lisp
162   (use-package hl-todo
163     :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
164     :config (global-hl-todo-mode 1))
165 #+end_src
166 ** Don't lose cursor
167 #+begin_src emacs-lisp
168   (blink-cursor-mode)
169 #+end_src
170 ** Visual line mode
171 Soft wrap words and do operations by visual lines.
172 #+begin_src emacs-lisp
173   (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
174 #+end_src
175 ** Display number of matches in search
176 #+begin_src emacs-lisp
177   (use-package anzu
178     :config (global-anzu-mode))
179 #+end_src
180 ** Visual bell
181 Inverts modeline instead of audible bell or the standard visual bell.
182 #+begin_src emacs-lisp
183   (setq visible-bell nil
184         ring-bell-function 'flash-mode-line)
185   (defun flash-mode-line ()
186     (invert-face 'mode-line)
187     (run-with-timer 0.1 nil #'invert-face 'mode-line))
188 #+end_src
189 * Evil mode
190 ** General
191 #+begin_src emacs-lisp
192   (use-package evil
193     :custom (select-enable-clipboard nil)
194     :config
195     (evil-mode)
196     (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
197     ;; Use visual line motions even outside of visual-line-mode buffers
198     (evil-global-set-key 'motion "j" 'evil-next-visual-line)
199     (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
200     (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
201 #+end_src
202 ** Evil collection
203 #+begin_src emacs-lisp
204   (use-package evil-collection
205     :after evil
206     :init (evil-collection-init)
207     :custom (evil-collection-setup-minibuffer t))
208 #+end_src
209 ** Surround
210 tpope prevails!
211 #+begin_src emacs-lisp
212   (use-package evil-surround
213     :config (global-evil-surround-mode))
214 #+end_src
215 ** Leader key
216 #+begin_src emacs-lisp
217   (use-package evil-leader
218     :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
219     :config
220     (evil-leader/set-leader "<SPC>")
221     (global-evil-leader-mode))
222 #+end_src
223 ** Nerd commenter
224 #+begin_src emacs-lisp
225   ;; Nerd commenter
226   (use-package evil-nerd-commenter
227     :bind (:map evil-normal-state-map
228                 ("gc" . evilnc-comment-or-uncomment-lines))
229     :custom (evilnc-invert-comment-line-by-line nil))
230 #+end_src
231 ** Undo redo
232 Fix the oopsies!
233 #+begin_src emacs-lisp
234   (evil-set-undo-system 'undo-redo)
235 #+end_src
236 ** Number incrementing
237 Add back C-a/C-x
238 #+begin_src emacs-lisp
239   (use-package evil-numbers
240     :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
241     :bind (:map evil-normal-state-map
242                 ("C-M-a" . evil-numbers/inc-at-pt)
243                 ("C-M-x" . evil-numbers/dec-at-pt)))
244 #+end_src
245 ** Evil org
246 *** Init
247 #+begin_src emacs-lisp
248   (use-package evil-org
249     :after org
250     :hook (org-mode . evil-org-mode)
251     :config
252     (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
253   (use-package evil-org-agenda
254     :straight (:type built-in)
255     :after evil-org
256     :config
257     (evil-org-agenda-set-keys))
258 #+end_src
259 *** Leader maps
260 #+begin_src emacs-lisp
261   (evil-leader/set-key-for-mode 'org-mode
262     "T" 'org-show-todo-tree
263     "a" 'org-agenda
264     "c" 'org-archive-subtree)
265 #+end_src
266 * Org mode
267 ** General
268 #+begin_src emacs-lisp
269   (use-package org
270     :straight (:type built-in)
271     :commands (org-capture org-agenda)
272     :custom
273     (org-ellipsis " ▾")
274     (org-agenda-start-with-log-mode t)
275     (org-agenda-files (quote ("~/Org/tasks.org" "~/Org/break.org")))
276     (org-log-done 'time)
277     (org-log-into-drawer t)
278     (org-src-tab-acts-natively t)
279     (org-src-fontify-natively t)
280     (org-startup-indented t)
281     (org-hide-emphasis-markers t)
282     (org-fontify-whole-block-delimiter-line nil)
283     :bind ("C-c a" . org-agenda))
284 #+end_src
285 ** Tempo
286 #+begin_src emacs-lisp
287   (use-package org-tempo
288     :after org
289     :straight (:type built-in)
290     :config
291     ;; TODO: There's gotta be a more efficient way to write this
292     (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
293     (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
294     (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
295     (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
296     (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
297     (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
298     (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
299     (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc"))
300     (add-to-list 'org-structure-template-alist '("ro" . "src javascript :tangle ~/.config/rofi/config.rasi"))
301     (add-to-list 'org-structure-template-alist '("za" . "src conf :tangle ~/.config/zathura/zathurarc"))
302     (add-to-list 'org-structure-template-alist '("ff1" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css"))
303     (add-to-list 'org-structure-template-alist '("ff2" . "src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css"))
304     (add-to-list 'org-structure-template-alist '("xr" . "src conf :tangle ~/.Xresources")))
305 #+end_src
306 ** Presentations
307 #+begin_src emacs-lisp
308   (use-package org-present
309     :straight (org-present :type git :host github :repo "rlister/org-present"))
310 #+end_src
311 * Autocompletion
312 ** Ivy
313 Simple, but not too simple autocompletion.
314 #+begin_src emacs-lisp
315   (use-package ivy
316     :bind (("C-s" . swiper)
317            :map ivy-minibuffer-map
318            ("TAB" . ivy-alt-done)
319            :map ivy-switch-buffer-map
320            ("M-d" . ivy-switch-buffer-kill))
321     :config (ivy-mode))
322 #+end_src
323 ** Ivy-rich
324 #+begin_src emacs-lisp
325   (use-package ivy-rich
326     :after (ivy counsel)
327     :config (ivy-rich-mode))
328 #+end_src
329 ** Counsel
330 Ivy everywhere.
331 #+begin_src emacs-lisp
332   (use-package counsel
333     :bind (("C-M-j" . 'counsel-switch-buffer)
334            :map minibuffer-local-map
335            ("C-r" . 'counsel-minibuffer-history))
336     :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
337     :config (counsel-mode))
338 #+end_src
339 ** Remember frequent commands
340 #+begin_src emacs-lisp
341   (use-package ivy-prescient
342     :after counsel
343     :custom
344     (ivy-prescient-enable-filtering nil)
345     :config
346     (prescient-persist-mode)
347     (ivy-prescient-mode))
348 #+end_src
349 ** Swiper
350 Better search utility.
351 #+begin_src emacs-lisp
352   (use-package swiper)
353 #+end_src
354 * EmacsOS
355 ** RSS
356 Use elfeed for RSS. I have another file with all the feeds in it.
357 #+begin_src emacs-lisp
358   (use-package elfeed
359     :bind (("C-c e" . elfeed))
360     :config
361     (load "~/.emacs.d/feeds.el")
362     (add-hook 'elfeed-new-entry-hook
363               (elfeed-make-tagger :feed-url "youtube\\.com"
364                                   :add '(youtube)))
365     :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
366
367   (use-package elfeed-goodies
368     :after elfeed
369     :config (elfeed-goodies/setup))
370 #+end_src
371 ** Email
372 Use mu4e for reading emails.
373
374 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.
375
376 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.
377 #+begin_src emacs-lisp
378   (use-package smtpmail
379     :straight (:type built-in))
380   (use-package mu4e
381     :load-path "/usr/share/emacs/site-lisp/mu4e"
382     :straight (:build nil)
383     :bind (("C-c m" . mu4e))
384     :config
385     (setq user-full-name "Armaan Bhojwani"
386           smtpmail-local-domain "armaanb.net"
387           smtpmail-stream-type 'ssl
388           smtpmail-smtp-service '465
389           mu4e-change-filenames-when-moving t
390           mu4e-get-mail-command "offlineimap -q"
391           message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
392           message-citation-line-function 'message-insert-formatted-citation-line
393           mu4e-completing-read-function 'ivy-completing-read
394           mu4e-confirm-quit nil
395           mail-user-agent 'mu4e-user-agent
396           mu4e-contexts
397           `( ,(make-mu4e-context
398                :name "school"
399                :enter-func (lambda () (mu4e-message "Entering school context"))
400                :leave-func (lambda () (mu4e-message "Leaving school context"))
401                :match-func (lambda (msg)
402                              (when msg
403                                (string-match-p "^/school" (mu4e-message-field msg :maildir))))
404                :vars '((user-mail-address . "abhojwani22@nobles.edu")
405                        (mu4e-sent-folder . "/school/Sent")
406                        (mu4e-drafts-folder . "/school/Drafts")
407                        (mu4e-trash-folder . "/school/Trash")
408                        (mu4e-refile-folder . "/school/Archive")
409                        (user-mail-address . "abhojwani22@nobles.edu")
410                        (smtpmail-smtp-user . "abhojwani22@nobles.edu")
411                        (smtpmail-smtp-server . "smtp.gmail.com")))
412              ,(make-mu4e-context
413                :name "personal"
414                :enter-func (lambda () (mu4e-message "Entering personal context"))
415                :leave-func (lambda () (mu4e-message "Leaving personal context"))
416                :match-func (lambda (msg)
417                              (when msg
418                                (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
419                :vars '((mu4e-sent-folder . "/personal/Sent")
420                        (mu4e-drafts-folder . "/personal/Drafts")
421                        (mu4e-trash-folder . "/personal/Trash")
422                        (mu4e-refile-folder . "/personal/Archive")
423                        (user-mail-address . "me@armaanb.net")
424                        (smtpmail-smtp-user . "me@armaanb.net")
425                        (smtpmail-smtp-server "smtp.mailbox.org")
426                        (mu4e-drafts-folder . "/school/Drafts")
427                        (mu4e-trash-folder . "/school/Trash")))))
428     (add-to-list 'mu4e-bookmarks
429                  '(:name "Unified inbox"
430                          :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
431                          :key ?b))
432     :hook ((mu4e-compose-mode . flyspell-mode)
433            (mu4e-view-mode-hook . turn-on-visual-line-mode)))
434 #+end_src
435 ** Default browser
436 Set EWW as default browser except for videos.
437 #+begin_src emacs-lisp
438   (defun browse-url-mpv (url &optional new-window)
439     "Open URL in MPV."
440     (start-process "mpv" "*mpv*" "mpv" url))
441
442   (setq browse-url-handlers
443         (quote
444          (("youtu\\.?be" . browse-url-mpv)
445           ("peertube.*" . browse-url-mpv)
446           ("vid.*" . browse-url-mpv)
447           ("vid.*" . browse-url-mpv)
448           ("." . eww-browse-url)
449           )))
450 #+end_src
451 ** EWW
452 Some EWW enhancements.
453 *** Give buffer a useful name
454 #+begin_src emacs-lisp
455   ;; From https://protesilaos.com/dotemacs/
456   (defun prot-eww--rename-buffer ()
457     "Rename EWW buffer using page title or URL.
458   To be used by `eww-after-render-hook'."
459     (let ((name (if (eq "" (plist-get eww-data :title))
460                     (plist-get eww-data :url)
461                   (plist-get eww-data :title))))
462       (rename-buffer (format "*%s # eww*" name) t)))
463
464   (add-hook 'eww-after-render-hook #'prot-eww--rename-buffer)
465 #+end_src
466 *** Better entrypoint
467 #+begin_src emacs-lisp
468   ;; From https://protesilaos.com/dotemacs/
469   (defun prot-eww-browse-dwim (url &optional arg)
470     "Visit a URL, maybe from `eww-prompt-history', with completion.
471
472   With optional prefix ARG (\\[universal-argument]) open URL in a
473   new eww buffer.
474
475   If URL does not look like a valid link, run a web query using
476   `eww-search-prefix'.
477
478   When called from an eww buffer, provide the current link as
479   initial input."
480     (interactive
481      (list
482       (completing-read "Query:" eww-prompt-history
483                        nil nil (plist-get eww-data :url) 'eww-prompt-history)
484       current-prefix-arg))
485     (eww url (if arg 4 nil)))
486
487   (global-set-key (kbd "C-c w") 'prot-eww-browse-dwim)
488 #+end_src
489 ** IRC
490 #+begin_src emacs-lisp
491   (use-package erc
492     :straight (:type built-in)
493     :config
494     (load "~/.emacs.d/irc.el")
495     (acheam-irc)
496     (erc-notifications-enable)
497     (erc-smiley-disable))
498
499   (use-package erc-hl-nicks
500     :config (erc-hl-nicks-mode 1))
501 #+end_src
502 ** Emacs Anywhere
503 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
504 =emacsclient --eval "(emacs-everywhere)"=.
505 #+begin_src emacs-lisp
506   (use-package emacs-everywhere)
507 #+end_src
508 * Emacs IDE
509 ** Code cleanup
510 #+begin_src emacs-lisp
511   (use-package blacken
512     :hook (python-mode . blacken-mode)
513     :config
514     (setq blacken-line-length 79))
515
516   ;; Purge whitespace
517   (use-package ws-butler
518     :config
519     (ws-butler-global-mode))
520 #+end_src
521 ** Flycheck
522 #+begin_src emacs-lisp
523   (use-package flycheck
524     :config
525     (global-flycheck-mode))
526 #+end_src
527 ** Project management
528 #+begin_src emacs-lisp
529   (use-package projectile
530     :config (projectile-mode)
531     :custom ((projectile-completion-system 'ivy))
532     :bind-keymap
533     ("C-c p" . projectile-command-map)
534     :init
535     (when (file-directory-p "~/Code")
536       (setq projectile-project-search-path '("~/Code")))
537     (setq projectile-switch-project-action #'projectile-dired))
538
539   (use-package counsel-projectile
540     :after projectile
541     :config (counsel-projectile-mode))
542 #+end_src
543 ** Dired
544 #+begin_src emacs-lisp
545   (use-package dired
546     :straight (:type built-in)
547     :commands (dired dired-jump)
548     :custom ((dired-listing-switches "-agho --group-directories-first"))
549     :config
550     (evil-collection-define-key 'normal 'dired-mode-map
551       "h" 'dired-single-up-directory
552       "l" 'dired-single-buffer))
553
554   (use-package dired-single
555     :commands (dired dired-jump))
556
557   (use-package dired-open
558     :commands (dired dired-jump)
559     :custom
560     (dired-open-extensions '(("png" . "feh")
561                              ("mkv" . "mpv"))))
562
563   (use-package dired-hide-dotfiles
564     :hook (dired-mode . dired-hide-dotfiles-mode)
565     :config
566     (evil-collection-define-key 'normal 'dired-mode-map
567       "H" 'dired-hide-dotfiles-mode))
568 #+end_src
569 ** Git
570 *** Magit
571 # TODO: Write a command that commits hunk, skipping staging step.
572 #+begin_src emacs-lisp
573   (use-package magit)
574 #+end_src
575 *** Colored diff in line number area
576 #+begin_src emacs-lisp
577   (use-package diff-hl
578     :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
579     :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
580            (magit-post-refresh-hook . diff-hl-magit-post-refresh))
581     :config (global-diff-hl-mode))
582 #+end_src
583 * General text editing
584 ** Indentation
585 Indent after every change.
586 #+begin_src emacs-lisp
587   (use-package aggressive-indent
588     :config (global-aggressive-indent-mode))
589 #+end_src
590 ** Spell checking
591 Spell check in text mode, and in prog-mode comments.
592 #+begin_src emacs-lisp
593   (dolist (hook '(text-mode-hook))
594     (add-hook hook (lambda () (flyspell-mode))))
595   (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
596     (add-hook hook (lambda () (flyspell-mode -1))))
597   (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
598 #+end_src
599 ** Expand tabs to spaces
600 #+begin_src emacs-lisp
601   (setq-default tab-width 2)
602 #+end_src
603 ** Copy kill ring to clipboard
604 #+begin_src emacs-lisp
605   (setq x-select-enable-clipboard t)
606   (defun copy-kill-ring-to-xorg ()
607     "Copy the current kill ring to the xorg clipboard."
608     (interactive)
609     (x-select-text (current-kill 0)))
610 #+end_src
611 ** Browse kill ring
612 #+begin_src emacs-lisp
613   (use-package browse-kill-ring)
614 #+end_src
615 ** Save place
616 Opens file where you left it.
617 #+begin_src emacs-lisp
618   (save-place-mode)
619 #+end_src
620 ** Writing mode
621 Distraction free writing a la junegunn/goyo.
622 #+begin_src emacs-lisp
623   (use-package olivetti
624     :config
625     (evil-leader/set-key "o" 'olivetti-mode))
626 #+end_src
627 ** Abbreviations
628 Abbreviate things!
629 #+begin_src emacs-lisp
630   (setq abbrev-file-name "~/.emacs.d/abbrevs")
631   (setq save-abbrevs 'silent)
632   (setq-default abbrev-mode t)
633 #+end_src
634 ** TRAMP
635 #+begin_src emacs-lisp
636   (setq tramp-default-method "ssh")
637 #+end_src
638 ** Don't ask about following symlinks in vc
639 #+begin_src emacs-lisp
640   (setq vc-follow-symlinks t)
641 #+end_src
642 * Functions
643 ** Easily convert splits
644 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
645 #+begin_src emacs-lisp
646   (defun toggle-window-split ()
647     (interactive)
648     (if (= (count-windows) 2)
649         (let* ((this-win-buffer (window-buffer))
650                (next-win-buffer (window-buffer (next-window)))
651                (this-win-edges (window-edges (selected-window)))
652                (next-win-edges (window-edges (next-window)))
653                (this-win-2nd (not (and (<= (car this-win-edges)
654                                            (car next-win-edges))
655                                        (<= (cadr this-win-edges)
656                                            (cadr next-win-edges)))))
657                (splitter
658                 (if (= (car this-win-edges)
659                        (car (window-edges (next-window))))
660                     'split-window-horizontally
661                   'split-window-vertically)))
662           (delete-other-windows)
663           (let ((first-win (selected-window)))
664             (funcall splitter)
665             (if this-win-2nd (other-window 1))
666             (set-window-buffer (selected-window) this-win-buffer)
667             (set-window-buffer (next-window) next-win-buffer)
668             (select-window first-win)
669             (if this-win-2nd (other-window 1))))))
670
671   (define-key ctl-x-4-map "t" 'toggle-window-split)
672 #+end_src
673 ** Insert date
674 #+begin_src emacs-lisp
675   (defun insert-date ()
676     (interactive)
677     (insert (format-time-string "%Y-%m-%d")))
678 #+end_src
679 * Keybindings
680 ** Switch windows
681 #+begin_src emacs-lisp
682   (use-package ace-window
683     :bind ("M-o" . ace-window))
684 #+end_src
685 ** Kill current buffer
686 Makes "C-x k" binding faster.
687 #+begin_src emacs-lisp
688   (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
689 #+end_src
690 * Other settings
691 ** OpenSCAD
692 Render OpenSCAD files, and add a preview window.
693
694 Personal fork just merges a PR.
695 #+begin_src emacs-lisp
696   (use-package scad-mode)
697   (use-package scad-preview
698     :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
699 #+end_src
700 ** Control backup files
701 Stop backup files from spewing everywhere.
702 #+begin_src emacs-lisp
703   (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
704 #+end_src
705 ** Make yes/no easier
706 #+begin_src emacs-lisp
707   (defalias 'yes-or-no-p 'y-or-n-p)
708 #+end_src
709 ** Move customize file
710 No more clogging up init.el.
711 #+begin_src emacs-lisp
712   (setq custom-file "~/.emacs.d/custom.el")
713   (load custom-file)
714 #+end_src
715 ** Better help
716 #+begin_src emacs-lisp
717   (use-package helpful
718     :commands (helpful-callable helpful-variable helpful-command helpful-key)
719     :custom
720     (counsel-describe-function-function #'helpful-callable)
721     (counsel-describe-variable-function #'helpful-variable)
722     :bind
723     ([remap describe-function] . counsel-describe-function)
724     ([remap describe-command] . helpful-command)
725     ([remap describe-variable] . counsel-describe-variable)
726     ([remap describe-key] . helpful-key))
727 #+end_src
728 ** GPG
729 #+begin_src emacs-lisp
730   (use-package epa-file
731     :straight (:type built-in)
732     :custom
733     (epa-file-select-keys nil)
734     (epa-file-encrypt-to '("me@armaanb.net"))
735     (password-cache-expiry (* 60 15)))
736
737   (use-package pinentry
738     :config (pinentry-start))
739 #+end_src
740 ** Pastebin
741 #+begin_src emacs-lisp
742   (use-package 0x0
743     :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
744     :custom (0x0-default-service 'envs)
745     :config (evil-leader/set-key
746               "00" '0x0-upload
747               "0f" '0x0-upload-file
748               "0s" '0x0-upload-string
749               "0c" '0x0-upload-kill-ring
750               "0p" '0x0-upload-popup))
751 #+end_src
752 * Tangles
753 ** Spectrwm
754 *** General settings
755 #+begin_src conf :tangle ~/.spectrwm.conf
756   workspace_limit = 5
757   warp_pointer = 1
758   modkey = Mod4
759   autorun = ws[1]:/home/armaa/Code/scripts/autostart
760 #+end_src
761 *** Bar
762 #+begin_src conf :tangle ~/.spectrwm.conf
763   bar_enabled = 0
764   bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
765 #+end_src
766 *** Keybindings
767 **** WM actions
768 #+begin_src conf :tangle ~/.spectrwm.conf
769   program[lock] = i3lock -c 000000 -ef
770   program[term] = alacritty
771   program[screenshot_all] = flameshot gui
772   program[menu] = rofi -show run # `rofi-dmenu` handles the rest
773   program[switcher] = rofi -show window
774   program[notif] = /home/armaa/Code/scripts/setter status
775
776   bind[notif] = MOD+n
777   bind[switcher] = MOD+Tab
778 #+end_src
779 **** Media keys
780 #+begin_src conf :tangle ~/.spectrwm.conf
781   program[paup] = /home/armaa/Code/scripts/setter audio +5
782   program[padown] = /home/armaa/Code/scripts/setter audio -5
783   program[pamute] = /home/armaa/Code/scripts/setter audio
784   program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
785   program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
786   program[next] = playerctl next
787   program[prev] = playerctl previous
788   program[pause] = playerctl play-pause
789
790   bind[padown] = XF86AudioLowerVolume
791   bind[paup] = XF86AudioRaiseVolume
792   bind[pamute] = XF86AudioMute
793   bind[brigdown] = XF86MonBrightnessDown
794   bind[brigup] = XF86MonBrightnessUp
795   bind[pause] = XF86AudioPlay
796   bind[next] = XF86AudioNext
797   bind[prev] = XF86AudioPrev
798 #+end_src
799 **** HJKL
800 #+begin_src conf :tangle ~/.spectrwm.conf
801   program[h] = xdotool keyup h key --clearmodifiers Left
802   program[j] = xdotool keyup j key --clearmodifiers Down
803   program[k] = xdotool keyup k key --clearmodifiers Up
804   program[l] = xdotool keyup l key --clearmodifiers Right
805
806   bind[h] = MOD + Control + h
807   bind[j] = MOD + Control + j
808   bind[k] = MOD + Control + k
809   bind[l] = MOD + Control + l
810 #+end_src
811 **** Programs
812 #+begin_src conf :tangle ~/.spectrwm.conf
813   program[aerc] = alacritty -e aerc
814   program[catgirl] = alacritty --hold -e sh -c "while : ; do ssh root@armaanb.net -t abduco -A irc catgirl freenode; sleep 2; done"
815   program[emacs] = emacsclient -c
816   program[firefox] = firefox
817   program[calc] = alacritty -e bc
818   program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
819   program[pass] = rofi-pass
820
821   bind[aerc] = MOD+Control+1
822   bind[catgirl] = MOD+Control+2
823   bind[firefox] = MOD+Control+3
824   bind[emacs-anywhere] = MOD+Control+4
825   bind[calc] = MOD+Control+5
826   bind[emacs] = MOD+Control+Return
827   bind[pass] = MOD+Shift+P
828 #+end_src
829 ** Zsh
830 *** Settings
831 **** Completions
832 #+begin_src shell :tangle ~/.config/zsh/zshrc
833   autoload -Uz compinit
834   compinit
835
836   setopt no_case_glob
837   unsetopt glob_complete
838
839   # Fragment completions
840   zstyle ':completion:*' list-suffixes
zstyle ':completion:*' expand prefix suffix
841
842   # Menu completions
843   zstyle ':completion:*' menu select
844   zmodload zsh/complist
845   bindkey -M menuselect '^n' expand-or-complete
846   bindkey -M menuselect '^p' reverse-menu-complete
847
848 #+end_src
849 **** Vim bindings
850 #+begin_src shell :tangle ~/.config/zsh/zshrc
851   bindkey -v
852   KEYTIMEOUT=1
853
854   bindkey -M vicmd "^[[3~" delete-char
855   bindkey "^[[3~" delete-char
856
857   autoload edit-command-line
858   zle -N edit-command-line
859   bindkey -M vicmd ^e edit-command-line
860   bindkey ^e edit-command-line
861 #+end_src
862 **** History
863 #+begin_src shell :tangle ~/.config/zsh/zshrc
864   setopt extended_history
865   setopt share_history
866   setopt inc_append_history
867   setopt hist_ignore_dups
868   setopt hist_reduce_blanks
869
870   HISTSIZE=100000
871   SAVEHIST=100000
872   HISTFILE=~/.local/share/zsh/history
873 #+end_src
874 *** Plugins
875 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
876
877 Right now, I'm only using fast-syntax-highlighting. It's a really nice visual addition.
878 **** ZPE
879 #+begin_src conf :tangle ~/.config/zpe/repositories
880   https://github.com/zdharma/fast-syntax-highlighting
881 #+end_src
882 **** Zshrc
883 #+begin_src shell :tangle ~/.config/zsh/zshrc
884   source ~/Code/zpe/zpe.sh
885   source ~/Code/admone/admone.zsh
886   source ~/.config/zsh/fzf-bindings.zsh
887
888   zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
889 #+end_src
890 *** Functions
891 **** Time Zsh startup
892 #+begin_src shell :tangle ~/.config/zsh/zshrc
893   timer() {
894       for i in $(seq 1 10); do time "$1" -i -c exit; done
895   }
896 #+end_src
897 **** Update all packages
898 #+begin_src shell :tangle ~/.config/zsh/zshrc
899   color=$(tput setaf 5)
900   reset=$(tput sgr0)
901
902   apu() {
903       sudo echo "${color}== upgrading with yay ==${reset}"
904       yay
905       echo ""
906       echo "${color}== checking for pacnew files ==${reset}"
907       sudo pacdiff
908       echo
909       echo "${color}== upgrading flatpaks ==${reset}"
910       flatpak update
911       echo ""
912       echo "${color}== upgrading zsh plugins ==${reset}"
913       zpe-pull
914       echo ""
915       echo "${color}== updating nvim plugins ==${reset}"
916       nvim +PlugUpdate +PlugUpgrade +qall
917       echo "Updated nvim plugins"
918       echo ""
919       echo "${color}You are entirely up to date!${reset}"
920   }
921 #+end_src
922 **** Clean all packages
923 #+begin_src shell :tangle ~/.config/zsh/zshrc
924   apap() {
925       sudo echo "${color}== cleaning pacman orphans ==${reset}"
926       (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
927       echo ""
928       echo "${color}== cleaning flatpaks ==${reset}"
929       flatpak remove --unused
930       echo ""
931       echo "${color}== cleaning zsh plugins ==${reset}"
932       zpe-clean
933       echo ""
934       echo "${color}== cleaning nvim plugins ==${reset}"
935       nvim +PlugClean +qall
936       echo "Cleaned nvim plugins"
937       echo ""
938       echo "${color}All orphans cleaned!${reset}"
939   }
940 #+end_src
941 **** Setup anaconda
942 #+begin_src shell :tangle ~/.config/zsh/zshrc
943   zconda() {
944       __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
945       if [ $? -eq 0 ]; then
946           eval "$__conda_setup"
947       else
948           if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
949               . "/opt/anaconda/etc/profile.d/conda.sh"
950           else
951               export PATH="/opt/anaconda/bin:$PATH"
952           fi
953       fi
954       unset __conda_setup
955   }
956 #+end_src
957 **** Interact with 0x0
958 #+begin_src shell :tangle ~/.config/zsh/zshrc
959   zxz="https://envs.sh"
960   0file() { curl -F"file=@$1" "$zxz" ; }
961   0pb() { curl -F"file=@-;" "$zxz" ; }
962   0url() { curl -F"url=$1" "$zxz" ; }
963   0short() { curl -F"shorten=$1" "$zxz" ; }
964   0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
965 #+end_src
966 **** Finger
967 #+begin_src shell :tangle ~/.config/zsh/zshrc
968   finger() {
969       user=$(echo "$1" | cut -f 1 -d '@')
970       host=$(echo "$1" | cut -f 2 -d '@')
971       echo $user | nc "$host" 79 -N
972   }
973 #+end_src
974 **** Upload to ftp.armaanb.net
975 #+begin_src shell :tangle ~/.config/zsh/zshrc
976   pubup() {
977       rsync "$1" "root@armaanb.net:/var/ftp/pub/${2}"
978       echo "https://ftp.armaanb.net/pub/"$(basename "$1") | tee /dev/tty | xclip -sel c
979   }
980 #+end_src
981 *** Aliases
982 **** SSH
983 #+begin_src shell :tangle ~/.config/zsh/zshrc
984   alias bhoji-drop='ssh -p 23 root@armaanb.net'
985   alias catgirl='ssh root@armaanb.net -t abduco -A irc catgirl freenode'
986   alias union='ssh 192.168.1.18'
987   alias mine='ssh -p 23 root@pickupserver.cc'
988   alias tcf='ssh root@204.48.23.68'
989   alias ngmun='ssh root@157.245.89.25'
990   alias prox='ssh root@192.168.1.224'
991   alias ncq='ssh root@143.198.123.17'
992   alias dock='ssh root@192.168.1.225'
993   alias jenkins='ssh root@192.168.1.226'
994   alias envs='ssh acheam@envs.net'
995 #+end_src
996 **** File management
997 #+begin_src shell :tangle ~/.config/zsh/zshrc
998   alias ls='exa -lh --icons --git --group-directories-first'
999   alias la='exa -lha --icons --git --group-directories-first'
1000   alias df='df -h / /boot'
1001   alias du='du -h'
1002   alias free='free -h'
1003   alias cp='cp -riv'
1004   alias rm='rm -Iv'
1005   alias mv='mv -iv'
1006   alias ln='ln -iv'
1007   alias grep='grep -in --exclude-dir=.git --color=auto'
1008   alias fname='find -name'
1009   alias mkdir='mkdir -pv'
1010   alias unar='atool -x'
1011   alias wget='wget -e robots=off'
1012   alias lanex='~/.local/share/lxc/lxc'
1013 #+end_src
1014 **** Editing
1015 #+begin_src shell :tangle ~/.config/zsh/zshrc
1016   alias v='nvim'
1017   alias vim='nvim'
1018   alias vw="nvim ~/Documents/vimwiki/index.md"
1019 #+end_src
1020 **** System management
1021 #+begin_src shell :tangle ~/.config/zsh/zshrc
1022   alias jctl='journalctl -p 3 -xb'
1023   alias pkill='pkill -i'
1024   alias cx='chmod +x'
1025   alias redoas='doas $(fc -ln -1)'
1026   alias crontab='crontab-argh'
1027   alias sudo='doas ' # allows aliases to be run with doas
1028   alias pasc='pass -c'
1029   alias pasu='\pass git push'
1030   alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1031     yadm push'
1032 #+end_src
1033 **** Networking
1034 #+begin_src shell :tangle ~/.config/zsh/zshrc
1035   alias ping='ping -c 10'
1036   alias speed='speedtest-cli'
1037   alias ip='ip --color=auto'
1038   alias cip='curl https://armaanb.net/ip'
1039   alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1040   alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1041   alias plan='T=$(mktemp) && \
1042         rsync root@armaanb.net:/etc/finger/plan.txt "$T" && \
1043         TT=$(mktemp) && \
1044         head -n -2 $T > $TT && \
1045         vim $TT && \
1046         echo "\nLast updated: $(date -R)" >> "$TT" && \
1047         rsync "$TT" root@armaanb.net:/etc/finger/plan.txt'
1048   alias wttr='curl -s "wttr.in/02445?n" | head -n -3'
1049 #+end_src
1050 **** Other
1051 #+begin_src shell :tangle ~/.config/zsh/zshrc
1052   alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1053     iflag=fullblock status=progress'
1054   alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1055     iflag=fullblock status=progress'
1056   alias ts='gen-shell -c task'
1057   alias ts='gen-shell -c task'
1058   alias tetris='autoload -Uz tetriscurses && tetriscurses'
1059   alias news='newsboat'
1060   alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1061   alias ytmusic="youtube-dl -x --add-metadata  --audio-format aac \
1062     --restrict-filenames -o '%(title)s.%(ext)s'"
1063   alias cal="cal -3 --color=auto"
1064   alias bc='bc -l'
1065 #+end_src
1066 **** Virtual machines, chroots
1067 #+begin_src shell :tangle ~/.config/zsh/zshrc
1068   alias ckiss="sudo chrooter ~/Virtual/kiss"
1069   alias cdebian="sudo chrooter ~/Virtual/debian bash"
1070   alias cwindows='devour qemu-system-x86_64 \
1071     -smp 3 \
1072     -cpu host \
1073     -enable-kvm \
1074     -m 3G \
1075     -device VGA,vgamem_mb=64 \
1076     -device intel-hda \
1077     -device hda-duplex \
1078     -net nic \
1079     -net user,smb=/home/armaa/Public \
1080     -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1081 #+end_src
1082 **** Python
1083 #+begin_src shell :tangle ~/.config/zsh/zshrc
1084   alias ipy="ipython"
1085   alias zpy="zconda && ipython"
1086   alias math="ipython --profile=math"
1087   alias pypi="python setup.py sdist && twine upload dist/*"
1088   alias pip="python -m pip"
1089   alias black="black -l 79"
1090 #+end_src
1091 **** Latin
1092 #+begin_src shell :tangle ~/.config/zsh/zshrc
1093   alias words='gen-shell -c "words"'
1094   alias words-e='gen-shell -c "words ~E"'
1095 #+end_src
1096 **** Devour
1097 #+begin_src shell :tangle ~/.config/zsh/zshrc
1098   alias zathura='devour zathura'
1099   alias mpv='devour mpv'
1100   alias sql='devour sqlitebrowser'
1101   alias cad='devour openscad'
1102   alias feh='devour feh'
1103 #+end_src
1104 **** Package management (Pacman)
1105 #+begin_src shell :tangle ~/.config/zsh/zshrc
1106   alias aps='yay -Ss'
1107   alias api='yay -Syu'
1108   alias apii='sudo pacman -S'
1109   alias app='yay -Rns'
1110   alias apc='yay -Sc'
1111   alias apo='yay -Qttd'
1112   alias azf='pacman -Q | fzf'
1113   alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1114   alias ufetch='ufetch-arch'
1115   alias reflect='reflector --verbose --sort rate --save \
1116      ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1117 #+end_src
1118 **** Package management (KISS)
1119 #+begin_src shell :tangle ~/.config/zsh/zshrc
1120   alias kzf="kiss s \* | xargs -l basename | \
1121     fzf --preview 'kiss search {} | xargs -l dirname'"
1122 #+end_src
1123 *** Exports
1124 #+begin_src shell :tangle ~/.config/zsh/zshrc
1125   export EDITOR="emacsclient -c"
1126   export VISUAL="$EDITOR"
1127   export TERM=xterm-256color # for compatability
1128
1129   export GPG_TTY="$(tty)"
1130   export MANPAGER='nvim +Man!'
1131   export PAGER='less'
1132
1133   export GTK_USE_PORTAL=1
1134
1135   export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1136   export PATH="/home/armaa/Code/scripts:$PATH" # prioritize my scripts
1137   export PATH="/home/armaa/Code/scripts/bin:$PATH" # prioritize my bins
1138   export PATH="$PATH:/home/armaa/.cargo/bin"
1139   export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1140   export PATH="$PATH:/usr/sbin"
1141   export PATH="$PATH:/opt/FreeTube/freetube"
1142
1143   export LC_ALL="en_US.UTF-8"
1144   export LC_CTYPE="en_US.UTF-8"
1145   export LANGUAGE="en_US.UTF-8"
1146
1147   export KISS_PATH="/home/armaa/Virtual/kiss/home/armaa/kiss-repo"
1148   export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1149   export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1150   export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1151   export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1152   export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1153 #+end_src
1154 ** Alacritty
1155 *** Appearance
1156 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1157 font:
1158   normal:
1159     family: JetBrains Mono Nerd Font
1160     style: Medium
1161   italic:
1162     style: Italic
1163   Bold:
1164     style: Bold
1165   size: 7
1166   ligatures: true # Requires ligature patch
1167
1168 window:
1169   padding:
1170     x: 5
1171     y: 5
1172
1173 background_opacity: 1
1174 #+end_src
1175 *** Color scheme
1176 Modus vivendi. Source: https://github.com/ishan9299/Nixos/blob/d4bbb7536be95b59466bb9cca4d671be46e04e81/user/alacritty/alacritty.yml#L30-L118
1177 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1178 colors:
1179   # Default colors
1180   primary:
1181     background: '#000000'
1182     foreground: '#ffffff'
1183
1184   cursor:
1185     text: '#000000'
1186     background: '#ffffff'
1187
1188   # Normal colors (except green it is from intense colors)
1189   normal:
1190     black:   '#000000'
1191     red:     '#ff8059'
1192     green:   '#00fc50'
1193     yellow:  '#eecc00'
1194     blue:    '#29aeff'
1195     magenta: '#feacd0'
1196     cyan:    '#00d3d0'
1197     white:   '#eeeeee'
1198
1199   # Bright colors [all the faint colors in the modus theme]
1200   bright:
1201     black:   '#555555'
1202     red:     '#ffa0a0'
1203     green:   '#88cf88'
1204     yellow:  '#d2b580'
1205     blue:    '#92baff'
1206     magenta: '#e0b2d6'
1207     cyan:    '#a0bfdf'
1208     white:   '#ffffff'
1209
1210   # dim [all the intense colors in modus theme]
1211   dim:
1212     black:   '#222222'
1213     red:     '#fb6859'
1214     green:   '#00fc50'
1215     yellow:  '#ffdd00'
1216     blue:    '#00a2ff'
1217     magenta: '#ff8bd4'
1218     cyan:    '#30ffc0'
1219     white:   '#dddddd'
1220 #+end_src
1221 ** IPython
1222 *** General
1223 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1224 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1225   c.TerminalInteractiveShell.editing_mode = 'vi'
1226   c.InteractiveShell.colors = 'linux'
1227   c.TerminalInteractiveShell.confirm_exit = False
1228 #+end_src
1229 *** Math
1230 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1231   from math import *
1232
1233   def deg(x):
1234       return x * (180 /  pi)
1235
1236   def rad(x):
1237       return x * (pi / 180)
1238
1239   def rad(x, unit):
1240       return (x * (pi / 180)) / unit
1241
1242   def csc(x):
1243       return 1 / sin(x)
1244
1245   def sec(x):
1246       return 1 / cos(x)
1247
1248   def cot(x):
1249       return 1 / tan(x)
1250 #+end_src
1251 ** MPV
1252 Make MPV play a little bit smoother.
1253 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1254   ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1255   hwdec=auto-copy
1256 #+end_src
1257 ** Inputrc
1258 For any GNU Readline programs
1259 #+begin_src conf :tangle ~/.inputrc
1260   set editing-mode vi
1261 #+end_src
1262 ** Git
1263 *** User
1264 #+begin_src conf :tangle ~/.gitconfig
1265 [user]
1266   name = Armaan Bhojwani
1267   email = me@armaanb.net
1268   signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1269 #+end_src
1270 *** Init
1271 #+begin_src conf :tangle ~/.gitconfig
1272 [init]
1273   defaultBranch = main
1274 #+end_src
1275 *** GPG
1276 #+begin_src conf :tangle ~/.gitconfig
1277 [gpg]
1278   program = gpg
1279 #+end_src
1280 *** Sendemail
1281 #+begin_src conf :tangle ~/.gitconfig
1282 [sendemail]
1283   smtpserver = smtp.mailbox.org
1284   smtpuser = me@armaanb.net
1285   smtpencryption = ssl
1286   smtpserverport = 465
1287   confirm = auto
1288 #+end_src
1289 *** Submodules
1290 #+begin_src conf :tangle ~/.gitconfig
1291 [submodule]
1292   recurse = true
1293 #+end_src
1294 *** Aliases
1295 #+begin_src conf :tangle ~/.gitconfig
1296 [alias]
1297   stat = diff --stat
1298   sclone = clone --depth 1
1299   sclean = clean -dfX
1300   a = add
1301   aa = add .
1302   c = commit
1303   p = push
1304   subup = submodule update --remote
1305   loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1306   mirror = git config --global alias.mirrormirror
1307 #+end_src
1308 *** Commits
1309 #+begin_src conf :tangle ~/.gitconfig
1310 [commit]
1311   gpgsign = true
1312   verbose = true
1313 #+end_src
1314 ** Dunst
1315 Lightweight notification daemon.
1316 *** General
1317 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1318   [global]
1319   font = "JetBrains Mono Medium Nerd Font 11"
1320   allow_markup = yes
1321   format = "<b>%s</b>\n%b"
1322   sort = no
1323   indicate_hidden = yes
1324   alignment = center
1325   bounce_freq = 0
1326   show_age_threshold = 60
1327   word_wrap = yes
1328   ignore_newline = no
1329   geometry = "400x5-10+10"
1330   transparency = 0
1331   idle_threshold = 120
1332   monitor = 0
1333   sticky_history = yes
1334   line_height = 0
1335   separator_height = 1
1336   padding = 8
1337   horizontal_padding = 8
1338   max_icon_size = 32
1339   separator_color = "#ffffff"
1340   startup_notification = false
1341 #+end_src
1342 *** Modes
1343 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1344   [frame]
1345   width = 1
1346   color = "#ffffff"
1347
1348   [shortcuts]
1349   close = mod4+c
1350   close_all = mod4+shift+c
1351   history = mod4+ctrl+c
1352
1353   [urgency_low]
1354   background = "#222222"
1355   foreground = "#ffffff"
1356   highlight = "#ffffff"
1357   timeout = 5
1358
1359   [urgency_normal]
1360   background = "#222222"
1361   foreground = "#ffffff"
1362   highlight = "#ffffff"
1363   timeout = 15
1364
1365   [urgency_critical]
1366   background = "#222222"
1367   foreground = "#a60000"
1368   highlight = "#ffffff"
1369   timeout = 0
1370 #+end_src
1371 ** Rofi
1372 Modus vivendi theme that extends DarkBlue.
1373 #+begin_src javascript :tangle ~/.config/rofi/config.rasi
1374   @import "/usr/share/rofi/themes/DarkBlue.rasi"
1375       ,* {
1376           white:                        rgba ( 255, 255, 255, 100 % );
1377           foreground:                   @white;
1378           selected-normal-background:   @white;
1379           separatorcolor:               @white;
1380           background:                   rgba ( 34, 34, 34, 100 % );
1381       }
1382 #+end_src
1383 ** Zathura
1384 *** Options
1385 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1386   map <C-i> recolor
1387   map <A-b> toggle_statusbar
1388   set selection-clipboard clipboard
1389   set scroll-step 200
1390
1391   set window-title-basename "true"
1392   set selection-clipboard "clipboard"
1393 #+end_src
1394 *** Colors
1395 #+begin_src conf :tangle ~/.config/zathura/zathurarc
1396   set default-bg         "#000000"
1397   set default-fg         "#ffffff"
1398   set render-loading     true
1399   set render-loading-bg  "#000000"
1400   set render-loading-fg  "#ffffff"
1401
1402   set recolor-lightcolor "#000000" # bg
1403   set recolor-darkcolor  "#ffffff" # fg
1404   set recolor            "true"
1405 #+end_src
1406 ** Firefox
1407 *** Swap tab and URL bars
1408 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1409   #nav-bar {
1410       -moz-box-ordinal-group: 1 !important;
1411   }
1412
1413   #PersonalToolbar {
1414       -moz-box-ordinal-group: 2 !important;
1415   }
1416
1417   #titlebar {
1418       -moz-box-ordinal-group: 3 !important;
1419   }
1420 #+end_src
1421 *** Hide URL bar when not focused.
1422 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1423   #navigator-toolbox:not(:focus-within):not(:hover) {
1424       margin-top: -30px;
1425   }
1426
1427   #navigator-toolbox {
1428       transition: 0.1s margin-top ease-out;
1429   }
1430 #+end_src
1431 ** Black screen by default
1432 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userChrome.css
1433   #main-window,
1434   #browser,
1435   #browser vbox#appcontent tabbrowser,
1436   #content,
1437   #tabbrowser-tabpanels,
1438   #tabbrowser-tabbox,
1439   browser[type="content-primary"],
1440   browser[type="content"] > html,
1441   .browserContainer {
1442       background: black !important;
1443       color: #fff !important;
1444   }
1445 #+end_src
1446 #+begin_src css :tangle ~/.mozilla/firefox/armaan-release/chrome/userContent.css
1447   @-moz-document url("about:home"), url("about:blank"), url("about:newtab") {
1448       body {
1449           background: black !important;
1450       }
1451   }
1452 #+end_src
1453 ** Xresources
1454 *** Font
1455 #+begin_src conf :tangle ~/.Xresources
1456   xterm*font: JetBrains Mono NF:pixelsize=15
1457
1458   XTerm.vt100.translations: #override \n\
1459     Ctrl <Key> minus: smaller-vt-font() \n\
1460     Ctrl <Key> plus: larger-vt-font()
1461 #+end_src
1462 *** Color scheme
1463 Modus operandi.
1464 #+begin_src conf :tangle ~/.Xresources
1465   ! special
1466   ,*.foreground:   #ffffff
1467   ,*.background:   #000000
1468   ,*.cursorColor:  #ffffff
1469
1470   ! black
1471   ,*.color0:       #000000
1472   ,*.color8:       #555555
1473
1474   ! red
1475   ,*.color1:       #ff8059
1476   ,*.color9:       #ffa0a0
1477
1478   ! green
1479   ,*.color2:       #00fc50
1480   ,*.color10:      #88cf88
1481
1482   ! yellow
1483   ,*.color3:       #eecc00
1484   ,*.color11:      #d2b580
1485
1486   ! blue
1487   ,*.color4:       #29aeff
1488   ,*.color12:      #92baff
1489
1490   ! magenta
1491   ,*.color5:       #feacd0
1492   ,*.color13:      #e0b2d6
1493
1494   ! cyan
1495   ,*.color6:       #00d3d0
1496   ,*.color14:      #a0bfdf
1497
1498   ! white
1499   ,*.color7:       #eeeeee
1500   ,*.color15:      #dddddd
1501 #+end_src
1502 *** Copy paste
1503 #+begin_src conf :tangle ~/.Xresources
1504   xterm*VT100.Translations: #override \
1505     Shift <KeyPress> Insert: insert-selection(CLIPBOARD) \n\
1506     Ctrl Shift <Key>V:    insert-selection(CLIPBOARD) \n\
1507     Ctrl Shift <Key>C:    copy-selection(CLIPBOARD) \n\
1508     Ctrl <Btn1Up>: exec-formatted("xdg-open '%t'", PRIMARY)
1509 #+end_src
1510 *** Blink cursor
1511 #+begin_src conf :tangle ~/.Xresources
1512   xterm*cursorBlink: true
1513 #+end_src
1514 *** Alt keys
1515 #+begin_src conf :tangle ~/.Xresources
1516   XTerm*eightBitInput:   false
1517   XTerm*eightBitOutput:  true
1518 #+end_src