#+title: GNU/Linux and GNU Emacs Introduction #+keywords: beginner gnu linux emacs * Installing Debian ** Preparations *** Getting debian Download Debian [[https://www.debian.org/][installer image]] *** Creating installation medium On =M$= Windows, use a tool like [[https://rufus.ie/en/][Rufus]] to create a bootable USB flash drive with the downloaded =.iso= file *** Allocating disk space Either get an empty disk or shrink on of your data partitions (toms) to get a continuous region of free space which is at least around 100GB. ** Installation process If installing on a laptop, make sure that it's fully charged and keep the charger plugged in. *** Booting from the installation medium NOTE: You might have to enable booting from USB in BIOS. Select the USB from boot menu or change boot order. *** The Debian installer Select the =install= option (not the =Graphical install=) in the GRUB bootloader. To navigate the menus, use arrow keys and TAB, to toggle check boxes use spacebar and to press button use the enter key. Simple guide: 1. Select region 2. Select localization (US) 3. Select keyboard layout (most likely US/ISO) 4. Select connected if you have Ethernet connection or wireless if you want to connect to wifi. 5. Choose hostname. 6. Skip domain name. 7. Skip proxy. 8. Select mirror in your region. 9. Set root password. 10. Set user's full name, username and password. 11. Deselect all software packages except base. 12. To dual boot with Windows select guided partitioning (free space). 13. Select =/home= folder on a separate partition. 14. Start the installation. 15. Reboot and check that you can boot everything. * Setting up GNU/Linux ** User setup 1. Login as root 1. Edit =/etc/apt/sources= and add =non-free contrib testing unstable= 2. ~apt udpate~ 3. ~apt upgrade~ 4. ~apt install sudo~ 5. ~visudo~ (%wheel ALL=(ALL) NOPASSWD: ALL) 6. ~groupadd wheel~ 7. ~usermod -aG wheel YOUR_USERNAME~ 8. ~exit~ ** Environment setup *** Folder setup #+begin_src sh cd rmdir Downloads Desktop ... mkdir downloads documents multimedia cd multimedia mkdir screenshots mkdir screencasts #+end_src *** Emacs setup ~sudo apt install emacs git vterm-module libtd~ Delete =~/.emacs.d= Edit =~/.config/emacs/init.el= #+name: emacs-server #+header: :tangle emacs/init.el #+begin_src emacs-lisp (server-start) #+end_src #+name: emacs-straight #+header: :tangle emacs/init.el #+begin_src emacs-lisp (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 6)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (straight-use-package 'use-package) (setq straight-use-package-by-default t use-package-always-ensure t) #+end_src #+name: emacs-coding #+header: :tangle emacs/init.el #+begin_src emacs-lisp (prefer-coding-system 'utf-8) (set-language-environment "UTF-8") (set-default-coding-systems 'utf-8) (set-terminal-coding-system 'utf-8) (setq-default buffer-file-coding-system 'utf-8) #+end_src #+name: emacs-clean-look #+header: :tangle emacs/init.el #+begin_src emacs-lisp (menu-bar-mode -1) (tool-bar-mode -1) (scroll-bar-mode -1) #+end_src #+name: emacs-misc #+header: :tangle emacs/init.el #+begin_src emacs-lisp (setq kill-ring-max 10000) (repeat-mode 1) (auto-insert-mode 1) (global-hl-line-mode 1) (setq display-time-24hr-format t) (setq default-input-method "russian-computer") (load-theme 'modus-vivendi t) (fset 'yes-or-no-p 'y-or-n-p) (set-face-attribute 'default nil :font "Iosevka" :height 180) (global-subword-mode) #+end_src #+name: emacs-compilation #+header: :tangle emacs/init.el #+begin_src emacs-lisp (require 'ansi-color) (add-hook 'compilation-filter-hook 'ansi-color-compilation-filter) (add-hook 'compilation-mode-hook 'toggle-truncate-lines) (define-key global-map (kbd "C-") 'compile) (define-key global-map (kbd "") 'recompile) #+end_src #+name: emacs-trash #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package trashed) (setq delete-by-moving-to-trash t) #+end_src #+name: emacs-undo-tree #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package undo-tree :config (global-undo-tree-mode)) #+end_src #+name: emacs-page-break-lines #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package page-break-lines :config (global-page-break-lines-mode)) #+end_src #+name: emacs-pdf-tools #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package pdf-tools :demand t :hook (pdf-view-mode . pdf-view-themed-minor-mode) :config ;; Initialize the package (pdf-tools-install) ;; Associate pdf-view-mode with PDF files (add-to-list 'auto-mode-alist '("\\.pdf\\'" . pdf-view-mode)) ;; Enable seamless scrolling between pages (setq pdf-view-continuous-scroll-mode t) ;; Use normal Emacs keybindings for scrolling (setq pdf-view-continuous-scroll-keystrokes nil)) #+end_src #+name: emacs-eglot #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package eglot) #+end_src #+name: emacs-project #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package project) #+end_src #+name: emacs-terminals #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package vterm) (use-package eat) #+end_src #+name: emacs-telega #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package telega :custom (telega-server-libs-prefix "/usr")) #+end_src #+name: emacs-emms #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package emms) #+end_src #+name: emacs-multitran #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package multitran :bind (("s-t" . multitran-at-pos))) #+end_src #+name: emacs-savehist #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package savehist :config (savehist-mode)) #+end_src #+name: emacs-lorem-ipsum #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package lorem-ipsum) #+end_src #+name: emacs-smartparens #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package smartparens :init (smartparens-global-mode t)) #+end_src #+name: emacs-completion #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package vertico :init (vertico-mode) ;; (setq vertico-scroll-margin 0) ;; (setq vertico-count 20) ;; (setq vertico-resize t) (setq vertico-cycle t)) (use-package orderless :init ;; (setq orderless-style-dispatchers '(+orderless-consult-dispatch ;; orderless-affix-dispatch) orderless-component-separator #'orderless-escapable-split-on-space) (setq completion-styles '(orderless basic) completion-category-defaults nil completion-category-overrides '((file (styles partial-completion))))) (use-package consult :bind (;; C-c bindings in `mode-specific-map' ("C-c M-x" . consult-mode-command) ("C-c h" . consult-history) ("C-c k" . consult-kmacro) ("C-c m" . consult-man) ("C-c i" . consult-info) ([remap Info-search] . consult-info) ;; C-x bindings in `ctl-x-map' ("C-x M-:" . consult-complex-command) ;; orig. repeat-complex-command ("C-x b" . consult-buffer) ;; orig. switch-to-buffer ("C-x 4 b" . consult-buffer-other-window) ;; orig. switch-to-buffer-other-window ("C-x 5 b" . consult-buffer-other-frame) ;; orig. switch-to-buffer-other-frame ("C-x r b" . consult-bookmark) ;; orig. bookmark-jump ("C-x p b" . consult-project-buffer) ;; orig. project-switch-to-buffer ;; Custom M-# bindings for fast register access ("M-#" . consult-register-load) ("M-'" . consult-register-store) ;; orig. abbrev-prefix-mark (unrelated) ("C-M-#" . consult-register) ;; Other custom bindings ("M-y" . consult-yank-pop) ;; orig. yank-pop ;; M-g bindings in `goto-map' ("M-g e" . consult-compile-error) ("M-g f" . consult-flymake) ;; Alternative: consult-flycheck ("M-g g" . consult-goto-line) ;; orig. goto-line ("M-g M-g" . consult-goto-line) ;; orig. goto-line ("M-g o" . consult-outline) ;; Alternative: consult-org-heading ("M-g m" . consult-mark) ("M-g k" . consult-global-mark) ("M-g i" . consult-imenu) ("M-g I" . consult-imenu-multi) ;; M-s bindings in `search-map' ("M-s d" . consult-find) ;; Alternative: consult-fd ("M-s D" . consult-locate) ("M-s g" . consult-grep) ("M-s G" . consult-git-grep) ("M-s r" . consult-ripgrep) ("M-s l" . consult-line) ("M-s L" . consult-line-multi) ("M-s k" . consult-keep-lines) ("M-s u" . consult-focus-lines) ;; Isearch integration ("M-s e" . consult-isearch-history) :map isearch-mode-map ("M-e" . consult-isearch-history) ;; orig. isearch-edit-string ("M-s e" . consult-isearch-history) ;; orig. isearch-edit-string ("M-s l" . consult-line) ;; needed by consult-line to detect isearch ("M-s L" . consult-line-multi) ;; needed by consult-line to detect isearch ;; Minibuffer history :map minibuffer-local-map ("M-s" . consult-history) ;; orig. next-matching-history-element ("M-r" . consult-history)) ;; orig. previous-matching-history-element ;; Enable automatic preview at point in the *Completions* buffer. This is ;; relevant when you use the default completion UI. :hook (completion-list-mode . consult-preview-at-point-mode) :init ;; Optionally configure the register formatting. This improves the register ;; preview for `consult-register', `consult-register-load', ;; `consult-register-store' and the Emacs built-ins. (setq register-preview-delay 0.5 register-preview-function #'consult-register-format) ;; Optionally tweak the register preview window. ;; This adds thin lines, sorting and hides the mode line of the window. (advice-add #'register-preview :override #'consult-register-window) ;; Use Consult to select xref locations with preview (setq xref-show-xrefs-function #'consult-xref xref-show-definitions-function #'consult-xref) ;; Configure other variables and modes in the :config section, ;; after lazily loading the package. :config ;; Optionally configure preview. The default value ;; is 'any, such that any key triggers the preview. ;; (setq consult-preview-key 'any) ;; (setq consult-preview-key "M-.") ;; (setq consult-preview-key '("S-" "S-")) ;; For some commands and buffer sources it is useful to configure the ;; :preview-key on a per-command basis using the `consult-customize' macro. (consult-customize consult-theme :preview-key '(:debounce 0.2 any) consult-ripgrep consult-git-grep consult-grep consult-bookmark consult-recent-file consult-xref consult--source-bookmark consult--source-file-register consult--source-recent-file consult--source-project-recent-file ;; :preview-key "M-." :preview-key '(:debounce 0.4 any)) ;; Optionally configure the narrowing key. ;; Both < and C-+ work reasonably well. (setq consult-narrow-key "<") ;; "C-+" ;; Optionally make narrowing help available in the minibuffer. ;; You may want to use `embark-prefix-help-command' or which-key instead. ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help) ) (use-package corfu :custom (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' (corfu-auto t) ;; Enable auto completion (corfu-separator ?\s) ;; Orderless field separator (corfu-quit-at-boundary nil) ;; Never quit at completion boundary (corfu-quit-no-match nil) ;; Never quit, even if there is no match (corfu-preview-current nil) ;; Disable current candidate preview (corfu-preselect 'prompt) ;; Preselect the prompt (corfu-on-exact-match nil) ;; Configure handling of exact matches (corfu-scroll-margin 5) ;; Use scroll margin :init (global-corfu-mode)) #+end_src #+name: emacs-dired #+header: :tangle emacs/init.el #+begin_src emacs-lisp (setq dired-listing-switches "-alh" dired-dwim-target t dired-recursive-copies 'always dired-recursive-deletes 'always) (use-package dired-single) #+end_src #+name: emacs-emacs #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package emacs :init ;; Add prompt indicator to `completing-read-multiple'. ;; We display [CRM], e.g., [CRM,] if the separator is a comma. (defun crm-indicator (args) (cons (format "[CRM%s] %s" (replace-regexp-in-string "\\`\\[.*?]\\*\\|\\[.*?]\\*\\'" "" crm-separator) (car args)) (cdr args))) (advice-add #'completing-read-multiple :filter-args #'crm-indicator) ;; Do not allow the cursor in the minibuffer prompt (setq minibuffer-prompt-properties '(read-only t cursor-intangible t face minibuffer-prompt)) (add-hook 'minibuffer-setup-hook #'cursor-intangible-mode) ;; Enable recursive minibuffers (setq enable-recursive-minibuffers t)) ;; Save all tempfiles in $TMPDIR/emacs$UID/ (defconst emacs-tmp-dir (expand-file-name (format "emacs%d" (user-uid)) temporary-file-directory)) (setq backup-directory-alist `((".*" . ,emacs-tmp-dir))) (setq auto-save-file-name-transforms `((".*" ,emacs-tmp-dir t))) (setq auto-save-list-file-prefix emacs-tmp-dir) #+end_src #+name: emacs-multiple-cursors #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package multiple-cursors :bind (("C-S-c" . mc/edit-lines) ("C->" . mc/mark-next-like-this) ("C-<" . mc/mark-previous-like-this) ("C-c C-S-c" . mc/mark-all-like-this) ("C-\"" . mc/skip-to-next-like-this) ("C-:" . mc/skip-to-previous-like-this))) #+end_src #+name: emacs-expand-region #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package expand-region :bind (("C-M-=" . er/expand-region))) #+end_src #+name: emacs-move-text #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package move-text :bind (("M-P" . move-text-up) ("M-N" . move-text-down))) #+end_src #+name: emacs-duplicate #+header: :tangle emacs/init.el #+begin_src emacs-lisp (keymap-global-set "C-'" 'duplicate-dwim) (setq duplicate-line-final-position 1) #+end_src #+name: emacs-hl-todo #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package hl-todo :config (global-hl-todo-mode 1)) #+end_src #+name: emacs-ligature #+header: :tangle emacs/init.el #+begin_src emacs-lisp (use-package ligature :config (ligature-set-ligatures 't '("-<<" "-<" "-<-" "<--" "<---" "<<-" "<-" "->" "->>" "-->" "--->" "->-" ">-" ">>-" "=<<" "=<" "=<=" "<==" "<===" "<<=" "<=" "=>" "=>>" "==>" "===>" "=>=" ">=" ">>=" "<->" "<-->" "<--->" "<---->" "<=>" "<==>" "<===>" "<====>" "::" ":::" "__" "<~~" "" "/>" "~~>" "==" "!=" "/=" "~=" "<>" "===" "!==" "!===" "=/=" "=!=" "<:" ":=" "*=" "*+" "<*" "<*>" "*>" "<|" "<|>" "|>" "<." "<.>" ".>" "+*" "=*" "=:" ":>" "(*" "*)" "/*" "*/" "[|" "|]" "{|" "|}" "++" "+++" "\\/" "/\\" "|-" "-|" "