1 #+TITLE: System Configuration
2 #+DESCRIPTION: Armaan's system configuration.
5 Welcome to my system configuration! This file contains my Emacs configuration, but also my config files for many of the other programs on my system!
7 I am currently using GCCEmacs 28 from the feature/native-comp branch, so some settings may not be available for older versions of Emacs. This is a purely personal configuration, so while I can garuntee that it works on my setup, I can't for anything else.
9 I chose to create a powerful, yet not overly heavy Emacs configuration. Things like LSP mode are important to my workflow and help me be productive, so despite its weight, it is kept. Things like a fancy modeline or icons on the other hand, do not increase my productivity, and create visual clutter, and thus have been excluded.
11 Another important choice has been to integrate Emacs into a large part of my computing environment (see [[*EmacsOS]]). I use Email, IRC, et cetera, all through Emacs which simplifies my workflow.
13 Lastly, I use Evil mode. I think modal keybindings are simple and more ergonomic than standard Emacs style, and Vim keybindings are what I'm comfortable with and are pervasive throughout computing.
15 *** TODO Turn keybinding and hook declarations into use-package declarations where possible
16 *** TODO Put configs with passwords in here with some kind of authentication
20 Released under the [[https://opensource.org/licenses/MIT][MIT license]] by Armaan Bhojwani, 2021. Note that many snippets are taken from online, and other sources, who are credited for their work at the snippet.
22 ** Bootstrap straight.el
23 straight.el is really nice for managing package, and it integrates nicely with use-package. It uses the bootstrapping system defined here for installation.
24 #+begin_src emacs-lisp
25 (defvar bootstrap-version)
27 (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
28 (bootstrap-version 5))
29 (unless (file-exists-p bootstrap-file)
31 (url-retrieve-synchronously
32 "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
33 'silent 'inhibit-cookies)
34 (goto-char (point-max))
35 (eval-print-last-sexp)))
36 (load bootstrap-file nil 'nomessage))
38 ** Replace use-package with straight
39 #+begin_src emacs-lisp
40 (straight-use-package 'use-package)
41 (setq straight-use-package-by-default t)
45 Very nice high contrast theme.
47 Its fine to set this here because I run Emacs in daemon mode, but if I were not, then putting it in early-init.el would be a better choice to eliminate the window being white before the theme is loaded.
48 #+begin_src emacs-lisp
49 (setq modus-themes-slanted-constructs t
50 modus-themes-bold-constructs t
51 modus-themes-org-blocks '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)
60 Great programming font with ligatures.
61 #+begin_src emacs-lisp
62 (add-to-list 'default-frame-alist '(font . "JetBrainsMonoNF-12"))
65 #+begin_src emacs-lisp
67 :straight (ligature :type git :host github :repo "mickeynp/ligature.el")
69 (ligature-set-ligatures
70 '(prog-mode text-mode)
71 '("-|" "-~" "---" "-<<" "-<" "--" "->" "->>" "-->" "///" "/=" "/=="
72 "/>" "//" "/*" "*>" "***" "*/" "<-" "<<-" "<=>" "<=" "<|" "<||"
73 "<|||" "<|>" "<:" "<>" "<-<" "<<<" "<==" "<<=" "<=<" "<==>" "<-|"
74 "<<" "<~>" "<=|" "<~~" "<~" "<$>" "<$" "<+>" "<+" "</>" "</" "<*"
75 "<*>" "<->" "<!--" ":>" ":<" ":::" "::" ":?" ":?>" ":=" "::=" "=>>"
76 "==>" "=/=" "=!=" "=>" "===" "=:=" "==" "!==" "!!" "!=" ">]" ">:"
77 ">>-" ">>=" ">=>" ">>>" ">-" ">=" "&&&" "&&" "|||>" "||>" "|>" "|]"
78 "|}" "|=>" "|->" "|=" "||-" "|-" "||=" "||" ".." ".?" ".=" ".-" "..<"
79 "..." "+++" "+>" "++" "[||]" "[<" "[|" "{|" "??" "?." "?=" "?:" "##"
80 "###" "####" "#[" "#{" "#=" "#!" "#:" "#_(" "#_" "#?" "#(" ";;" "_|_"
81 "__" "~~" "~~>" "~>" "~-" "~@" "$>" "^=" "]#"))
82 (global-ligature-mode t))
85 #+begin_src emacs-lisp
87 :config (global-emojify-mode))
89 ;; http://ergoemacs.org/emacs/emacs_list_and_set_font.html
94 ((member "Twitter Color Emoji" (font-family-list)) "Twitter Color Emoji")
95 ((member "Noto Color Emoji" (font-family-list)) "Noto Color Emoji")
96 ((member "Noto Emoji" (font-family-list)) "Noto Emoji")))
99 Display relative line numbers except in some modes
100 #+begin_src emacs-lisp
101 (global-display-line-numbers-mode)
102 (setq display-line-numbers-type 'relative)
103 (dolist (no-line-num '(term-mode-hook
108 (add-hook no-line-num (lambda () (display-line-numbers-mode 0))))
110 ** Highlight matching parenthesis
111 #+begin_src emacs-lisp
113 :config (show-paren-mode)
114 :custom (show-paren-style 'parenthesis))
117 *** Show current function
118 #+begin_src emacs-lisp
119 (which-function-mode)
121 *** Make position in file more descriptive
122 Show current column and file size.
123 #+begin_src emacs-lisp
125 (size-indication-mode)
128 #+begin_src emacs-lisp
130 :config (minions-mode))
133 Show a ruler at a certain number of chars depending on mode.
134 #+begin_src emacs-lisp
135 (global-display-fill-column-indicator-mode)
138 Whenever starting a key chord, show possible future steps.
139 #+begin_src emacs-lisp
140 (use-package which-key
141 :config (which-key-mode)
142 :custom (which-key-idle-delay 0.3))
144 ** Visual highlights of changes
145 Highlight when changes are made.
146 #+begin_src emacs-lisp
147 (use-package evil-goggles
148 :config (evil-goggles-mode)
149 (evil-goggles-use-diff-faces))
151 ** Highlight TODOs in comments
152 #+begin_src emacs-lisp
154 :straight (hl-todo :type git :host github :repo "tarsius/hl-todo")
155 :config (global-hl-todo-mode 1))
158 #+begin_src emacs-lisp
162 Soft wrap words and do operations by visual lines.
163 #+begin_src emacs-lisp
164 (add-hook 'text-mode-hook 'turn-on-visual-line-mode)
166 ** Display number of matches in search
167 #+begin_src emacs-lisp
169 :config (global-anzu-mode))
172 Inverts modeline instead of audible bell or the standard visual bell.
173 #+begin_src emacs-lisp
174 (setq visible-bell nil
175 ring-bell-function 'flash-mode-line)
176 (defun flash-mode-line ()
177 (invert-face 'mode-line)
178 (run-with-timer 0.1 nil #'invert-face 'mode-line))
182 #+begin_src emacs-lisp
184 :custom (select-enable-clipboard nil)
187 (fset 'evil-visual-update-x-selection 'ignore) ;; Keep clipboard and register seperate
188 ;; Use visual line motions even outside of visual-line-mode buffers
189 (evil-global-set-key 'motion "j" 'evil-next-visual-line)
190 (evil-global-set-key 'motion "k" 'evil-previous-visual-line)
191 (global-set-key (kbd "<escape>") 'keyboard-escape-quit))
194 #+begin_src emacs-lisp
195 (use-package evil-collection
197 :init (evil-collection-init)
198 :custom (evil-collection-setup-minibuffer t))
202 #+begin_src emacs-lisp
203 (use-package evil-surround
204 :config (global-evil-surround-mode))
207 #+begin_src emacs-lisp
208 (use-package evil-leader
209 :straight (evil-leader :type git :host github :repo "cofi/evil-leader")
211 (evil-leader/set-leader "<SPC>")
212 (global-evil-leader-mode))
215 #+begin_src emacs-lisp
217 (use-package evil-nerd-commenter
218 :bind (:map evil-normal-state-map
219 ("gc" . evilnc-comment-or-uncomment-lines))
220 :custom (evilnc-invert-comment-line-by-line nil))
224 #+begin_src emacs-lisp
225 (use-package undo-tree
227 (undo-tree-auto-save-history t)
228 (undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo-tree")))
230 (global-undo-tree-mode)
231 (evil-set-undo-system 'undo-tree))
233 ** Number incrementing
235 #+begin_src emacs-lisp
236 (use-package evil-numbers
237 :straight (evil-numbers :type git :host github :repo "juliapath/evil-numbers")
238 :bind (:map evil-normal-state-map
239 ("C-M-a" . evil-numbers/inc-at-pt)
240 ("C-M-x" . evil-numbers/dec-at-pt)))
244 #+begin_src emacs-lisp
245 (use-package evil-org
247 :hook (org-mode . evil-org-mode)
249 (evil-org-set-key-theme '(textobjects insert navigation shift todo)))
250 (use-package evil-org-agenda
251 :straight (:type built-in)
254 (evil-org-agenda-set-keys))
257 #+begin_src emacs-lisp
258 (evil-leader/set-key-for-mode 'org-mode
259 "T" 'org-show-todo-tree
261 "c" 'org-archive-subtree)
265 #+begin_src emacs-lisp
267 :straight (:type built-in)
268 :commands (org-capture org-agenda)
271 (org-agenda-start-with-log-mode t)
273 (org-log-into-drawer t)
274 (org-src-tab-acts-natively t)
275 (org-src-fontify-natively t)
276 (org-startup-indented t)
277 (org-hide-emphasis-markers t)
278 (org-fontify-whole-block-delimiter-line nil))
281 #+begin_src emacs-lisp
282 (use-package org-tempo
284 :straight (:type built-in)
286 ;; TODO: There's gotta be a more efficient way to write this
287 (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))
288 (add-to-list 'org-structure-template-alist '("sp" . "src conf :tangle ~/.spectrwm.conf"))
289 (add-to-list 'org-structure-template-alist '("zsh" . "src shell :tangle ~/.config/zsh/zshrc"))
290 (add-to-list 'org-structure-template-alist '("al" . "src yml :tangle ~/.config/alacritty/alacritty.yml"))
291 (add-to-list 'org-structure-template-alist '("ipy" . "src python :tangle ~/.ipython/"))
292 (add-to-list 'org-structure-template-alist '("pi" . "src conf :tangle ~/.config/picom/picom.conf"))
293 (add-to-list 'org-structure-template-alist '("git" . "src conf :tangle ~/.gitconfig"))
294 (add-to-list 'org-structure-template-alist '("du" . "src conf :tangle ~/.config/dunst/dunstrc")))
298 Simple, but not too simple autocompletion.
299 #+begin_src emacs-lisp
301 :bind (("C-s" . swiper)
302 :map ivy-minibuffer-map
303 ("TAB" . ivy-alt-done)
304 :map ivy-switch-buffer-map
305 ("M-d" . ivy-switch-buffer-kill))
309 #+begin_src emacs-lisp
310 (use-package ivy-rich
312 :config (ivy-rich-mode))
316 #+begin_src emacs-lisp
318 :bind (("C-M-j" . 'counsel-switch-buffer)
319 :map minibuffer-local-map
320 ("C-r" . 'counsel-minibuffer-history))
321 :custom (counsel-linux-app-format-function #'counsel-linux-app-format-function-name-only)
322 :config (counsel-mode))
324 ** Remember frequent commands
325 #+begin_src emacs-lisp
326 (use-package ivy-prescient
329 (ivy-prescient-enable-filtering nil)
331 (prescient-persist-mode)
332 (ivy-prescient-mode))
335 Better search utility.
336 #+begin_src emacs-lisp
341 Use elfeed for RSS. I have another file with all the feeds in it.
342 #+begin_src emacs-lisp
344 :bind (("C-c e" . elfeed))
346 (load "~/.emacs.d/feeds.el")
347 (add-hook 'elfeed-new-entry-hook
348 (elfeed-make-tagger :feed-url "youtube\\.com"
350 :bind (:map elfeed-search-mode-map ("C-c C-o" . 'elfeed-show-visit)))
352 (use-package elfeed-goodies
354 :config (elfeed-goodies/setup))
357 Use mu4e for reading emails.
359 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.
361 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.
362 #+begin_src emacs-lisp
363 (use-package smtpmail
364 :straight (:type built-in))
366 :load-path "/usr/share/emacs/site-lisp/mu4e"
367 :bind (("C-c m" . mu4e))
369 (setq user-full-name "Armaan Bhojwani"
370 smtpmail-local-domain "armaanb.net"
371 smtpmail-stream-type 'ssl
372 smtpmail-smtp-service '465
373 mu4e-change-filenames-when-moving t
374 message-kill-buffer-on-exit t
375 mu4e-get-mail-command "offlineimap -q"
376 message-citation-line-format "On %a %d %b %Y at %R, %f wrote:\n"
377 message-citation-line-function 'message-insert-formatted-citation-line
378 mu4e-context-policy "pick-first"
380 `( ,(make-mu4e-context
382 :enter-func (lambda () (mu4e-message "Entering school context"))
383 :leave-func (lambda () (mu4e-message "Leaving school context"))
384 :match-func (lambda (msg)
386 (string-match-p "^/school" (mu4e-message-field msg :maildir))))
387 :vars '( (user-mail-address . "abhojwani22@nobles.edu")
388 (mu4e-sent-folder . "/school/Sent")
389 (mu4e-drafts-folder . "/school/Drafts")
390 (mu4e-trash-folder . "/school/Trash")
391 (mu4e-refile-folder . "/school/Archive")
392 (user-mail-address . "abhojwani22@nobles.edu")
393 (smtpmail-smtp-user . "abhojwani22@nobles.edu")
394 (smtpmail-smtp-server . "smtp.gmail.com")))
397 :enter-func (lambda () (mu4e-message "Entering personal context"))
398 :leave-func (lambda () (mu4e-message "Leaving personal context"))
399 :match-func (lambda (msg)
401 (string-match-p "^/personal" (mu4e-message-field msg :maildir))))
403 (mu4e-sent-folder . "/personal/Sent")
404 (mu4e-drafts-folder . "/personal/Drafts")
405 (mu4e-trash-folder . "/personal/Trash")
406 (mu4e-refile-folder . "/personal/Archive")
407 (user-mail-address . "me@armaanb.net")
408 (smtpmail-smtp-user . "me@armaanb.net")
409 (smtpmail-smtp-server "smtp.mailbox.org")
410 (mu4e-drafts-folder . "/school/Drafts")
411 (mu4e-trash-folder . "/school/Trash")))))
412 (add-to-list 'mu4e-bookmarks
413 '(:name "Unified inbox"
414 :query "maildir:\"/personal/INBOX\" or maildir:\"/school/INBOX\""
418 #+begin_src emacs-lisp
420 (use-package calfw-org)
421 (use-package calfw-ical)
423 (defun acheam-calendar ()
426 (shell-command "vdirsyncer sync")
427 (let ((default-directory "~/.local/share/vdirsyncer/"))
428 (cfw:open-calendar-buffer
431 (cfw:ical-create-source "School" (expand-file-name "school/abhojwani22@nobles.edu.ics") "Green")
432 (cfw:ical-create-source "Personal" (expand-file-name "mailbox/Y2FsOi8vMC8zMQ.ics") "Blue")
433 (cfw:ical-create-source "Birthdays" (expand-file-name "mailbox/Y2FsOi8vMS8w.ics") "Gray")
437 Another file has more specific network configuration.
438 #+begin_src emacs-lisp
440 :config (load-file "~/.emacs.d/irc.el"))
442 (use-package circe-chanop
443 :straight (:type built-in)
446 (use-package circe-color-nicks
447 :straight (:type built-in)
451 Set EWW as default browser except for videos.
452 #+begin_src emacs-lisp
453 (defun browse-url-mpv (url &optional new-window)
455 (start-process "mpv" "*mpv*" "mpv" url))
457 (setq browse-url-handlers
459 (("youtu\\.?be" . browse-url-mpv)
460 ("." . eww-browse-url)
464 Use Emacs globally. Use the Emacs daemon and bind a key in your wm to
465 "emacsclient --eval "(emacs-everywhere)".
466 #+begin_src emacs-lisp
467 (use-package emacs-everywhere)
472 #+begin_src emacs-lisp
473 (use-package lsp-mode
474 :commands (lsp lsp-deferred)
475 :custom (lsp-keymap-prefix "C-c l")
476 :hook ((lsp-mode . lsp-enable-which-key-integration)))
478 (use-package lsp-ivy)
481 :commands lsp-ui-mode
482 :custom (lsp-ui-doc-position 'bottom))
483 (use-package lsp-ui-flycheck
485 :straight (:type built-in))
488 Company-box adds icons.
489 #+begin_src emacs-lisp
492 :hook (lsp-mode . company-mode)
493 :bind (:map company-active-map
494 ("<tab>" . company-complete-selection))
496 ("<tab>" . company-indent-or-complete-common))
498 (company-minimum-prefix-length 1)
499 (setq company-dabbrev-downcase 0)
500 (company-idle-delay 0.0))
502 (use-package company-box
503 :hook (company-mode . company-box-mode))
507 #+begin_src emacs-lisp
508 (use-package lsp-pyright
509 :hook (python-mode . (lambda ()
510 (use-package lsp-pyright
511 :straight (:type built-in))
515 #+begin_src emacs-lisp
517 :hook (python-mode . blacken-mode)
519 (setq blacken-line-length 79))
522 (use-package ws-butler
524 (ws-butler-global-mode))
527 #+begin_src emacs-lisp
528 (use-package flycheck
530 (global-flycheck-mode))
532 ** Project management
533 #+begin_src emacs-lisp
534 (use-package projectile
535 :config (projectile-mode)
536 :custom ((projectile-completion-system 'ivy))
538 ("C-c p" . projectile-command-map)
540 (when (file-directory-p "~/Code")
541 (setq projectile-project-search-path '("~/Code")))
542 (setq projectile-switch-project-action #'projectile-dired))
544 (use-package counsel-projectile
546 :config (counsel-projectile-mode))
549 #+begin_src emacs-lisp
551 :straight (:type built-in)
552 :commands (dired dired-jump)
553 :custom ((dired-listing-switches "-agho --group-directories-first"))
555 (evil-collection-define-key 'normal 'dired-mode-map
556 "h" 'dired-single-up-directory
557 "l" 'dired-single-buffer))
559 (use-package dired-single
560 :commands (dired dired-jump))
562 (use-package dired-open
563 :commands (dired dired-jump)
565 (dired-open-extensions '(("png" . "feh")
568 (use-package dired-hide-dotfiles
569 :hook (dired-mode . dired-hide-dotfiles-mode)
571 (evil-collection-define-key 'normal 'dired-mode-map
572 "H" 'dired-hide-dotfiles-mode))
576 #+begin_src emacs-lisp
578 :hook (magit-mode-hook. pinentry-start))
580 *** Colored diff in line number area
581 #+begin_src emacs-lisp
583 :straight (diff-hl :type git :host github :repo "dgutov/diff-hl")
584 :hook ((magit-pre-refresh-hook . diff-hl-magit-pre-refresh)
585 (magit-post-refresh-hook . diff-hl-magit-post-refresh))
586 :config (global-diff-hl-mode))
588 * General text editing
590 Indent after every change.
591 #+begin_src emacs-lisp
592 (use-package aggressive-indent
593 :config (global-aggressive-indent-mode))
596 Spell check in text mode, and in prog-mode comments.
597 #+begin_src emacs-lisp
598 (dolist (hook '(text-mode-hook))
599 (add-hook hook (lambda () (flyspell-mode))))
600 (dolist (hook '(change-log-mode-hook log-edit-mode-hook))
601 (add-hook hook (lambda () (flyspell-mode -1))))
602 (add-hook 'prog-mode (lambda () (flyspell-prog mode)))
604 ** Expand tabs to spaces
605 #+begin_src emacs-lisp
606 (setq-default tab-width 2)
608 ** Copy kill ring to clipboard
609 #+begin_src emacs-lisp
610 (setq x-select-enable-clipboard t)
611 (defun copy-kill-ring-to-xorg ()
612 "Copy the current kill ring to the xorg clipboard."
614 (x-select-text (current-kill 0)))
617 #+begin_src emacs-lisp
618 (use-package browse-kill-ring)
621 Opens file where you left it.
622 #+begin_src emacs-lisp
626 Distraction free writing a la junegunn/goyo.
627 #+begin_src emacs-lisp
628 (use-package olivetti
630 (evil-leader/set-key "o" 'olivetti-mode))
634 #+begin_src emacs-lisp
635 (setq abbrev-file-name "~/.emacs.d/abbrevs")
636 (setq save-abbrevs 'silent)
637 (setq-default abbrev-mode t)
640 ** Easily convert splits
641 Converts splits from horizontal to vertical and vice versa. Lifted from EmacsWiki.
642 #+begin_src emacs-lisp
643 (defun toggle-window-split ()
645 (if (= (count-windows) 2)
646 (let* ((this-win-buffer (window-buffer))
647 (next-win-buffer (window-buffer (next-window)))
648 (this-win-edges (window-edges (selected-window)))
649 (next-win-edges (window-edges (next-window)))
650 (this-win-2nd (not (and (<= (car this-win-edges)
651 (car next-win-edges))
652 (<= (cadr this-win-edges)
653 (cadr next-win-edges)))))
655 (if (= (car this-win-edges)
656 (car (window-edges (next-window))))
657 'split-window-horizontally
658 'split-window-vertically)))
659 (delete-other-windows)
660 (let ((first-win (selected-window)))
662 (if this-win-2nd (other-window 1))
663 (set-window-buffer (selected-window) this-win-buffer)
664 (set-window-buffer (next-window) next-win-buffer)
665 (select-window first-win)
666 (if this-win-2nd (other-window 1))))))
668 (define-key ctl-x-4-map "t" 'toggle-window-split)
671 #+begin_src emacs-lisp
672 (defun insert-date ()
674 (insert (format-time-string "%Y-%m-%d")))
678 #+begin_src emacs-lisp
679 (use-package ace-window
680 :bind ("M-o" . ace-window))
682 ** Kill current buffer
683 Makes "C-x k" binding faster.
684 #+begin_src emacs-lisp
685 (substitute-key-definition 'kill-buffer 'kill-buffer-and-window global-map)
689 Render OpenSCAD files, and add a preview window.
691 Personal fork just merges a PR.
692 #+begin_src emacs-lisp
693 (use-package scad-mode)
694 (use-package scad-preview
695 :straight (scad-preview :type git :host github :repo "Armaanb/scad-preview"))
697 ** Control backup files
698 Stop backup files from spewing everywhere.
699 #+begin_src emacs-lisp
700 (setq backup-directory-alist `(("." . "~/.emacs.d/backups")))
702 ** Make yes/no easier
703 #+begin_src emacs-lisp
704 (defalias 'yes-or-no-p 'y-or-n-p)
706 ** Move customize file
707 No more clogging up init.el.
708 #+begin_src emacs-lisp
709 (setq custom-file "~/.emacs.d/custom.el")
713 #+begin_src emacs-lisp
715 :commands (helpful-callable helpful-variable helpful-command helpful-key)
717 (counsel-describe-function-function #'helpful-callable)
718 (counsel-describe-variable-function #'helpful-variable)
720 ([remap describe-function] . counsel-describe-function)
721 ([remap describe-command] . helpful-command)
722 ([remap describe-variable] . counsel-describe-variable)
723 ([remap describe-key] . helpful-key))
726 #+begin_src emacs-lisp
727 (use-package epa-file
728 :straight (:type built-in))
729 (setq epa-file-select-keys nil
730 epa-file-encrypt-to '("me@armaanb.net")
731 password-cache-expiry (* 60 15))
733 (use-package pinentry)
736 #+begin_src emacs-lisp
738 :straight (0x0 :type git :repo "https://git.sr.ht/~zge/nullpointer-emacs")
739 :custom (0x0-default-service 'envs)
740 :config (evil-leader/set-key
742 "0f" '0x0-upload-file
743 "0s" '0x0-upload-string
744 "0c" '0x0-upload-kill-ring
745 "0p" '0x0-upload-popup))
750 #+begin_src conf :tangle ~/.spectrwm.conf
756 autorun = ws[1]:/home/armaa/Code/scripts/autostart
760 #+begin_src conf :tangle ~/.spectrwm.conf
761 color_focus = rgb:83/a5/98
762 color_focus_maximized = rgb:d6/5d/0e
763 color_unfocus = rgb:58/58/58
766 #+begin_src conf :tangle ~/.spectrwm.conf
768 bar_font = xos4 Fira Code:pixelsize=14:antialias=true # any installed font
772 #+begin_src conf :tangle ~/.spectrwm.conf
773 program[lock] = i3lock -c 000000 -ef
774 program[term] = alacritty
775 program[screenshot_all] = flameshot gui
776 program[menu] = rofi -show run # `rofi-dmenu` handles the rest
777 program[switcher] = rofi -show window
778 program[notif] = /home/armaa/Code/scripts/setter status
781 bind[switcher] = MOD+Tab
784 #+begin_src conf :tangle ~/.spectrwm.conf
785 program[paup] = /home/armaa/Code/scripts/setter audio +5
786 program[padown] = /home/armaa/Code/scripts/setter audio -5
787 program[pamute] = /home/armaa/Code/scripts/setter audio
788 program[brigup] = /home/armaa/Code/scripts/setter brightness +10%
789 program[brigdown] = /home/armaa/Code/scripts/setter brightness 10%-
790 program[next] = playerctl next
791 program[prev] = playerctl previous
792 program[pause] = playerctl play-pause
794 bind[padown] = XF86AudioLowerVolume
795 bind[paup] = XF86AudioRaiseVolume
796 bind[pamute] = XF86AudioMute
797 bind[brigdown] = XF86MonBrightnessDown
798 bind[brigup] = XF86MonBrightnessUp
799 bind[pause] = XF86AudioPlay
800 bind[next] = XF86AudioNext
801 bind[prev] = XF86AudioPrev
804 #+begin_src conf :tangle ~/.spectrwm.conf
805 program[h] = xdotool keyup h key --clearmodifiers Left
806 program[j] = xdotool keyup j key --clearmodifiers Down
807 program[k] = xdotool keyup k key --clearmodifiers Up
808 program[l] = xdotool keyup l key --clearmodifiers Right
810 bind[h] = MOD + Control + h
811 bind[j] = MOD + Control + j
812 bind[k] = MOD + Control + k
813 bind[l] = MOD + Control + l
816 #+begin_src conf :tangle ~/.spectrwm.conf
817 program[aerc] = alacritty -e aerc
818 program[weechat] = alacritty --hold -e sh -c "while : ; do ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat; sleep 2; done"
819 program[emacs] = emacsclient -c
820 program[emacs-anywhere] = emacsclient --eval "(emacs-everywhere)"
821 program[firefox] = firefox
822 program[thunderbird] = thunderbird
823 program[slack] = slack
825 bind[aerc] = MOD+Control+s
826 bind[weechat] = MOD+Control+d
827 bind[emacs] = MOD+Control+f
828 bind[emacs-anywhere] = MOD+f
829 bind[firefox] = MOD+Control+u
830 bind[thunderbird] = MOD+Control+i
831 bind[slack] = MOD+Control+o
836 #+begin_src shell :tangle ~/.config/zsh/zshrc
837 autoload -Uz compinit
841 unsetopt glob_complete
844 #+begin_src shell :tangle ~/.config/zsh/zshrc
848 bindkey -M vicmd "^[[3~" delete-char
849 bindkey "^[[3~" delete-char
851 autoload edit-command-line
852 zle -N edit-command-line
853 bindkey -M vicmd ^e edit-command-line
854 bindkey ^e edit-command-line
857 #+begin_src shell :tangle ~/.config/zsh/zshrc
858 setopt extended_history
860 setopt inc_append_history
861 setopt hist_ignore_dups
862 setopt hist_reduce_blanks
866 HISTFILE=~/.local/share/zsh/history
869 I manage plugins using my own plugin manager, ZPE. https://git.sr.ht/~armaan/zpe
871 #+begin_src plain :tangle ~/.config/zpe/repositories
872 https://github.com/Aloxaf/fzf-tab
873 https://github.com/zdharma/fast-syntax-highlighting
874 https://github.com/rupa/z
877 #+begin_src shell :tangle ~/.config/zsh/zshrc
878 source ~/Code/zpe/zpe.sh
879 source ~/Code/admone/admone.zsh
880 source ~/.config/zsh/fzf-bindings.zsh
882 zpe-source fzf-tab/fzf-tab.zsh
883 zstyle ':completion:*:descriptions' format '[%d]'
884 zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath'
885 zstyle ':completion:*' completer _complete
886 zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' \
887 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'
889 zpe-source fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
890 export _Z_DATA="/home/armaa/.local/share/z"
894 **** Alert after long command
895 #+begin_src shell :tangle ~/.config/zsh/zshrc
897 notify-send --urgency=low -i ${(%):-%(?.terminal.error)} \
898 ${history[$HISTCMD]%[;&|][[:space:]]##alert}
901 **** Time Zsh startup
902 #+begin_src shell :tangle ~/.config/zsh/zshrc
904 for i in $(seq 1 10); do
905 time "zsh" -i -c exit;
909 **** Update all packages
910 #+begin_src shell :tangle ~/.config/zsh/zshrc
911 color=$(tput setaf 5)
915 sudo echo "${color}== upgrading with yay ==${reset}"
918 echo "${color}== checking for pacnew files ==${reset}"
921 echo "${color}== upgrading flatpaks ==${reset}"
924 echo "${color}== upgrading zsh plugins ==${reset}"
927 echo "${color}== updating nvim plugins ==${reset}"
928 nvim +PlugUpdate +PlugUpgrade +qall
929 echo "Updated nvim plugins"
931 echo "${color}You are entirely up to date!${reset}"
934 **** Clean all packages
935 #+begin_src shell :tangle ~/.config/zsh/zshrc
937 sudo echo "${color}== cleaning pacman orphans ==${reset}"
938 (pacman -Qtdq | sudo pacman -Rns - 2> /dev/null) || echo "No orphans"
940 echo "${color}== cleaning flatpaks ==${reset}"
941 flatpak remove --unused
943 echo "${color}== cleaning zsh plugins ==${reset}"
946 echo "${color}== cleaning nvim plugins ==${reset}"
947 nvim +PlugClean +qall
948 echo "Cleaned nvim plugins"
950 echo "${color}All orphans cleaned!${reset}"
954 #+begin_src shell :tangle ~/.config/zsh/zshrc
957 exa -lh --icons --git --group-directories-first
961 #+begin_src shell :tangle ~/.config/zsh/zshrc
963 __conda_setup="$('/opt/anaconda/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
964 if [ $? -eq 0 ]; then
965 eval "$__conda_setup"
967 if [ -f "/opt/anaconda/etc/profile.d/conda.sh" ]; then
968 . "/opt/anaconda/etc/profile.d/conda.sh"
970 export PATH="/opt/anaconda/bin:$PATH"
976 **** Interact with 0x0
977 #+begin_src shell :tangle ~/.config/zsh/zshrc
978 zxz="https://envs.sh"
979 0file() { curl -F"file=@$1" "$zxz" ; }
980 0pb() { curl -F"file=@-;" "$zxz" ; }
981 0url() { curl -F"url=$1" "$zxz" ; }
982 0short() { curl -F"shorten=$1" "$zxz" ; }
983 0clip() { xclip -out | curl -F"file=@-;" "$zxz" ; }
986 #+begin_src shell :tangle ~/.config/zsh/zshrc
995 #+begin_src shell :tangle ~/.config/zsh/zshrc
996 alias bhoji-drop='ssh -p 23 root@armaanb.net'
997 alias weechat='ssh -p 23 -t root@armaanb.net tmux attach-session -t weechat'
998 alias tcf='ssh root@204.48.23.68'
999 alias ngmun='ssh root@157.245.89.25'
1000 alias prox='ssh root@192.168.1.224'
1001 alias dock='ssh root@192.168.1.225'
1002 alias jenkins='ssh root@192.168.1.226'
1003 alias envs='ssh acheam@envs.net'
1005 **** File management
1006 #+begin_src shell :tangle ~/.config/zsh/zshrc
1007 alias ls='exa -lh --icons --git --group-directories-first'
1008 alias la='exa -lha --icons --git --group-directories-first'
1009 alias df='df -h / /boot'
1011 alias free='free -h'
1016 alias grep='grep -in --exclude-dir=.git --color=auto'
1017 alias mkdir='mkdir -pv'
1018 alias unar='atool -x'
1019 alias wget='wget -e robots=off'
1020 alias lanex='~/.local/share/lxc/lxc'
1023 #+begin_src shell :tangle ~/.config/zsh/zshrc
1024 alias padm='yadm --yadm-repo ~/Code/dotfiles/repo.git'
1025 alias yadu='yadm add -u && yadm commit -m "Updated `date -Iseconds`" && \
1027 alias padu='padm add -u && padm commit && padm push && yadu'
1030 #+begin_src shell :tangle ~/.config/zsh/zshrc
1033 alias vw="nvim ~/Documents/vimwiki/index.md"
1035 **** System management
1036 #+begin_src shell :tangle ~/.config/zsh/zshrc
1037 alias jctl='journalctl -p 3 -xb'
1038 alias pkill='pkill -i'
1040 alias please='sudo $(fc -ln -1)'
1041 alias sudo='sudo ' # allows aliases to be run with sudo
1044 #+begin_src shell :tangle ~/.config/zsh/zshrc
1045 alias ping='ping -c 10'
1046 alias speed='speedtest-cli'
1047 alias ip='ip --color=auto'
1048 alias cip='curl https://armaanb.net/ip'
1049 alias gps='gpg --keyserver keyserver.ubuntu.com --search-keys'
1050 alias gpp='gpg --keyserver keyserver.ubuntu.com --recv-key'
1053 #+begin_src shell :tangle ~/.config/zsh/zshrc
1054 alias dc='docker-compose'
1055 alias dcdu='docker-compose down && docker-compose up -d'
1058 #+begin_src shell :tangle ~/.config/zsh/zshrc
1059 alias bigrandomfile='dd if=/dev/urandom of=1GB-urandom bs=1M count=1024 \
1060 iflag=fullblock status=progress'
1061 alias bigboringfile='dd if=/dev/zero of=1GB-zero bs=1M count=1024 \
1062 iflag=fullblock status=progress'
1063 alias ts='gen-shell -c task'
1064 alias ts='gen-shell -c task'
1065 alias tetris='autoload -Uz tetriscurses && tetriscurses'
1066 alias news='newsboat'
1067 alias tilderadio="\mpv https://radio.tildeverse.org/radio/8000/radio.ogg"
1068 alias ytmusic="youtube-dl -x --add-metadata --audio-format aac \
1069 --restrict-filenames -o '%(title)s.%(ext)s'"
1070 alias cal="cal -3 --color=auto"
1072 **** Virtual machines, chroots
1073 #+begin_src shell :tangle ~/.config/zsh/zshrc
1074 alias ckiss="sudo chrooter ~/Virtual/kiss"
1075 alias cdebian="sudo chrooter ~/Virtual/debian bash"
1076 alias cwindows='devour qemu-system-x86_64 \
1081 -device VGA,vgamem_mb=64 \
1083 -device hda-duplex \
1085 -net user,smb=/home/armaa/Public \
1086 -drive format=qcow2,file=/home/armaa/Virtual/windows.qcow2'
1089 #+begin_src shell :tangle ~/.config/zsh/zshrc
1091 alias zpy="zconda && ipython"
1092 alias math="ipython --profile=math"
1093 alias pypi="python setup.py sdist && twine upload dist/*"
1094 alias pip="python -m pip"
1095 alias black="black -l 79"
1098 #+begin_src shell :tangle ~/.config/zsh/zshrc
1099 alias words='gen-shell -c "words"'
1100 alias words-e='gen-shell -c "words ~E"'
1103 #+begin_src shell :tangle ~/.config/zsh/zshrc
1104 alias zathura='devour zathura'
1105 alias mpv='devour mpv'
1106 alias sql='devour sqlitebrowser'
1107 alias cad='devour openscad'
1108 alias feh='devour feh'
1110 **** Package management (Pacman)
1111 #+begin_src shell :tangle ~/.config/zsh/zshrc
1113 alias api='yay -Syu'
1114 alias app='yay -Rns'
1116 alias apo='yay -Qttd'
1117 alias azf='pacman -Q | fzf'
1118 alias favorites='pacman -Qe | cut -d " " -f 1 > ~/Documents/favorites'
1119 alias ufetch='ufetch-arch'
1120 alias reflect='reflector --verbose --sort rate --save \
1121 ~/.local/etc/pacman.d/mirrorlist --download-timeout 60' # Takes ~45m to run
1124 #+begin_src shell :tangle ~/.config/zsh/zshrc
1125 export EDITOR="emacsclient -c" # $EDITOR opens in terminal
1126 export VISUAL="emacsclient -c -a emacs" # $VISUAL opens in GUI mode
1127 export TERM=xterm-256color # for compatability
1129 export GPG_TTY="$(tty)"
1130 export MANPAGER='nvim +Man!'
1133 # generated with "vivid generate gruvbox"
1134 export LS_COLORS="$(cat ~/.local/share/zsh/gruvbox)"
1136 export GTK_USE_PORTAL=1
1138 export PATH="/home/armaa/.local/bin:$PATH" # prioritize .local/bin
1139 export PATH="$PATH:/home/armaa/Code/scripts"
1140 export PATH="$PATH:/home/armaa/.cargo/bin"
1141 export PATH="$PATH:/home/armaa/.local/share/gem/ruby/2.7.0/bin"
1142 export PATH="$PATH:/usr/sbin"
1143 export PATH="$PATH:/opt/FreeTube/freetube"
1145 export LC_ALL="en_US.UTF-8"
1146 export LC_CTYPE="en_US.UTF-8"
1147 export LANGUAGE="en_US.UTF-8"
1149 export KISS_PATH="/home/armaa/kiss/home/armaa/kiss-repo"
1150 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/core"
1151 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/extra"
1152 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/xorg"
1153 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-main/testing"
1154 export KISS_PATH="$KISS_PATH:/home/armaa/Clone/repo-community/community"
1158 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1161 family: JetBrains Mono Nerd Font
1168 ligatures: true # Requires ligature patch
1175 background_opacity: 0.6
1178 Send <RET> + modifier through
1179 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1194 #+begin_src yml :tangle ~/.config/alacritty/alacritty.yml
1198 background: '#000000'
1199 foreground: '#ebdbb2'
1225 Symlink profile_default/ipython_config.py to profile_math/ipython_config.py
1226 #+begin_src python :tangle ~/.ipython/profile_default/ipython_config.py
1227 c.TerminalInteractiveShell.editing_mode = 'vi'
1228 c.InteractiveShell.colors = 'linux'
1229 c.TerminalInteractiveShell.confirm_exit = False
1232 #+begin_src python :tangle ~/.ipython/profile_math/startup.py
1236 return x * (180 / pi)
1239 return x * (pi / 180)
1242 return (x * (pi / 180)) / unit
1254 Make MPV play a little bit smoother.
1255 #+begin_src conf :tangle ~/.config/mpv/mpv.conf
1256 ytdl-format="bestvideo[height<=?1080]+bestaudio/best"
1261 #+begin_src conf :tangle ~/.config/picom/picom.conf
1264 shadow-offset-x = -5;
1265 shadow-offset-y = -5;
1268 #+begin_src conf :tangle ~/.config/picom/picom.conf
1273 #+begin_src conf :tangle ~/.config/picom/picom.conf
1276 method = "gaussian";
1282 Needs picom to be run with "--experimental-backends"
1283 #+begin_src conf :tangle ~/.config/picom/picom.conf
1287 For any GNU Readline programs
1288 #+begin_src plain :tangle ~/.inputrc
1292 https://github.com/sharkdp/vivid
1294 #+begin_src yml :tangle ~/.config/vivid/gruvbox.yml
1296 background_color: '282A36'
1308 #+begin_src yml :tangle ~/.config/vivid/gruvbox.yml
1325 missing_symlink_target:
1351 sticky_other_writable:
1384 continuous-integration:
1395 font-style: underline
1406 #+begin_src plain :tangle ~/.gitconfig
1408 name = Armaan Bhojwani
1409 email = me@armaanb.net
1410 signingkey = 0FEB9471E19C49C60CFBEB133C9ED82FFE788E4A
1413 #+begin_src plain :tangle ~/.gitconfig
1415 defaultBranch = main
1418 #+begin_src plain :tangle ~/.gitconfig
1423 #+begin_src plain :tangle ~/.gitconfig
1425 smtpserver = smtp.mailbox.org
1426 smtpuser = me@armaanb.net
1427 smtpencryption = ssl
1428 smtpserverport = 465
1432 #+begin_src plain :tangle ~/.gitconfig
1437 #+begin_src plain :tangle ~/.gitconfig
1440 sclone = clone --depth 1
1446 subup = submodule update --remote
1447 loc = diff --stat 4b825dc642cb6eb9a060e54bf8d69288fbee4904 # Empty hash
1448 mirror = git config --global alias.mirrormirror
1451 #+begin_src plain :tangle ~/.gitconfig
1456 Lightweight notification daemon. Gruvbox colors, based on https://github.com/a-schaefers/i3-wm-gruvbox-theme/
1458 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1460 font = "JetBrains Mono Medium Nerd Font 11"
1462 format = "<b>%s</b>\n%b"
1464 indicate_hidden = yes
1467 show_age_threshold = 60
1470 geometry = "400x5-20+20"
1472 idle_threshold = 120
1474 sticky_history = yes
1476 separator_height = 4
1478 horizontal_padding = 8
1480 separator_color = "#585858"
1481 startup_notification = false
1484 #+begin_src conf :tangle ~/.config/dunst/dunstrc
1491 close_all = mod4+shift+c
1492 history = mod4+ctrl+c
1495 background = "#282828"
1496 foreground = "#ebdbb2"
1497 highlight = "#ebdbb2"
1501 background = "#282828"
1502 foreground = "#ebdbb2"
1503 highlight = "#ebdbb2"
1507 background = "#282828"
1508 foreground = "#cc241d"
1509 highlight = "#ebdbb2"