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