Convenience-features for Emacs and shell scripts

NixOS:
feat: add cdw, cdr, cdb, bak scripts/aliases
feat: spawn firefox on workspace 1 again
fix: adjust systemd stop timeout to avoid 1m30s wait on shutdown
feat: add fzf-tab

Emacs:
fix: file-switcher directory up was not working consistently
feat: more intuitive minibuffer-local-map (DEL is now 1 char again)
chore: C-z now a prefix key, several new keybinds
fix: make project switching in dashboard work again
fix: add proper projectile backend (was still set to ivy)
fix: allow yubikey unlocking from within emacs
feat: add dotfile directory to magit repository list
This commit is contained in:
Swarsel 2024-06-17 19:39:20 +02:00
parent 1ddc3eb81d
commit 5e9c3c398f
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
6 changed files with 435 additions and 269 deletions

138
Emacs.org
View file

@ -250,6 +250,13 @@ This function will check if a directory for which a file we want to open exists;
(evil-mode 1) (evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state) ; alternative for exiting insert mode (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state) ; alternative for exiting insert mode
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join) ; dont show help but instead do normal vim delete backwards (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join) ; dont show help but instead do normal vim delete backwards
(define-key evil-normal-state-map (kbd "C-z") nil)
(define-key evil-insert-state-map (kbd "C-z") nil)
(define-key evil-visual-state-map (kbd "C-z") nil)
(define-key evil-motion-state-map (kbd "C-z") nil)
(define-key evil-operator-state-map (kbd "C-z") nil)
(define-key evil-replace-state-map (kbd "C-z") nil)
(define-key global-map (kbd "C-z") nil)
;; evil undo system ;; evil undo system
(evil-set-undo-system 'undo-tree) (evil-set-undo-system 'undo-tree)
@ -388,6 +395,26 @@ Base emacs undo logic is very useful, but not easy to understand. I prefer undo-
#+end_src #+end_src
** Move up one directory for find-file
I find it very annoying that the standard behavior for M-DEL only deletes one word when using find-file. This function makes it so that we always go up by one directory level instead.
#+begin_src emacs-lisp
(defun up-directory (path)
"Move up a directory in PATH without affecting the kill buffer."
(interactive "p")
(if (string-match-p "/." (minibuffer-contents))
(let ((end (point)))
(re-search-backward "/.")
(forward-char)
(delete-region (point) end))))
(define-key minibuffer-local-filename-completion-map
[C-backspace] #'up-directory)
#+end_src
* Custom Keybindings * Custom Keybindings
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -405,6 +432,7 @@ Base emacs undo logic is very useful, but not easy to understand. I prefer undo-
(swarsel/leader-keys (swarsel/leader-keys
"t" '(:ignore t :which-key "toggles") "t" '(:ignore t :which-key "toggles")
"ts" '(hydra-text-scale/body :which-key "scale text") "ts" '(hydra-text-scale/body :which-key "scale text")
"te" '(swarsel/toggle-evil-state :which-key "emacs/evil")
"tl" '(display-line-numbers-mode :which-key "line numbers") "tl" '(display-line-numbers-mode :which-key "line numbers")
"tp" '(evil-cleverparens-mode :wk "cleverparens") "tp" '(evil-cleverparens-mode :wk "cleverparens")
"to" '(olivetti-mode :wk "olivetti") "to" '(olivetti-mode :wk "olivetti")
@ -478,6 +506,12 @@ Base emacs undo logic is very useful, but not easy to understand. I prefer undo-
"C-<f9>" 'my-python-shell-run "C-<f9>" 'my-python-shell-run
) )
(defun swarsel/toggle-evil-state ()
(interactive)
(if (or (evil-emacs-state-p) (evil-insert-state-p))
(evil-normal-state)
(evil-emacs-state)))
#+end_src #+end_src
* UI * UI
@ -643,8 +677,8 @@ Soon I want to try out this new hot stuff - just at the moment there is too much
:after vertico :after vertico
:bind (:map vertico-map :bind (:map vertico-map
("RET" . vertico-directory-enter) ("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-word) ("C-DEL" . vertico-directory-delete-word)
("M-DEL" . vertico-directory-delete-char)) ("DEL" . vertico-directory-delete-char))
;; Tidy shadowed file names ;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
@ -658,14 +692,17 @@ Soon I want to try out this new hot stuff - just at the moment there is too much
:config :config
(setq consult-fontify-max-size 1024) (setq consult-fontify-max-size 1024)
:bind :bind
("C-x b" . consult-buffer) (("C-x b" . consult-buffer)
("C-c <C-m>" . consult-global-mark) ("C-c <C-m>" . consult-global-mark)
("C-c C-a" . consult-org-agenda) ("C-c C-a" . consult-org-agenda)
("C-x O" . consult-outline) ("C-x O" . consult-org-heading)
("M-g M-g" . consult-goto-line) ("M-g M-g" . consult-goto-line)
("M-g i" . consult-imenu) ("M-g i" . consult-imenu)
("M-s s" . consult-line) ("M-s s" . consult-line)
("M-s M-s" . consult-line-multi)) ("M-s M-s" . consult-line-multi)
:map minibuffer-local-map
("C-j" . next-line)
("C-k" . previous-line)))
(use-package embark (use-package embark
:bind :bind
@ -776,14 +813,13 @@ Soon I want to try out this new hot stuff - just at the moment there is too much
;; ([remap describe-key] . helpful-key)) ;; ([remap describe-key] . helpful-key))
(use-package helpful (use-package helpful
:custom
(help-select-window t)
:bind :bind
(("C-h f" . helpful-callable) (("C-h f" . helpful-callable)
("C-h v" . helpful-variable) ("C-h v" . helpful-variable)
("C-h k" . helpful-key) ("C-h k" . helpful-key)
("C-h C-." . helpful-at-point))) ("C-h C-." . helpful-at-point))
:config
(setq help-window-select nil))
#+end_src #+end_src
** Text Scaling ** Text Scaling
@ -1624,7 +1660,7 @@ In order to update the language grammars, run the next command below.
(use-package projectile (use-package projectile
:diminish projectile-mode :diminish projectile-mode
:config (projectile-mode) :config (projectile-mode)
:custom ((projectile-completion-system 'ivy)) ;; integrate ivy into completion system :custom ((projectile-completion-system 'auto)) ;; integrate ivy into completion system
:bind-keymap :bind-keymap
("C-c p" . projectile-command-map) ; all projectile commands under this ("C-c p" . projectile-command-map) ; all projectile commands under this
:init :init
@ -1660,17 +1696,19 @@ In order to update the language grammars, run the next command below.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package magit (use-package magit
:config :config
(setq magit-repository-directories `((,swarsel-projects-directory . 1) (setq magit-repository-directories `((,swarsel-projects-directory . 1)
(,swarsel-emacs-directory . 0) (,swarsel-emacs-directory . 0)
(,swarsel-obsidian-directory . 0))) (,swarsel-obsidian-directory . 0)
:custom ("~/.dotfiles/" . 0)))
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) ; stay in the same window :custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) ; stay in the same window
;; yubikey support for pushing commits ;; yubikey support for pushing commits
;; commiting is enabled through nixos gpg-agent config ;; commiting is enabled through nixos gpg-agent config
(setenv "SSH_AUTH_SOCK" (string-chop-newline (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket"))) (setq epg-pinentry-mode 'loopback)
(setenv "SSH_AUTH_SOCK" (string-chop-newline (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))
#+end_src #+end_src
** Forge ** Forge
@ -1852,23 +1890,23 @@ Currently unused
;; Bind dedicated completion commands ;; Bind dedicated completion commands
;; Alternative prefix keys: C-c p, M-p, M-+, ... ;; Alternative prefix keys: C-c p, M-p, M-+, ...
:bind :bind
("C-c p p" . completion-at-point) ;; capf ("C-z p" . completion-at-point) ;; capf
("C-c p t" . complete-tag) ;; etags ("C-z t" . complete-tag) ;; etags
("C-c p d" . cape-dabbrev) ;; or dabbrev-completion ("C-z d" . cape-dabbrev) ;; or dabbrev-completion
("C-c p h" . cape-history) ("C-z h" . cape-history)
("C-c p f" . cape-file) ("C-z f" . cape-file)
("C-c p k" . cape-keyword) ("C-z k" . cape-keyword)
("C-c p s" . cape-elisp-symbol) ("C-z s" . cape-elisp-symbol)
("C-c p e" . cape-elisp-block) ("C-z e" . cape-elisp-block)
("C-c p a" . cape-abbrev) ("C-z a" . cape-abbrev)
("C-c p l" . cape-line) ("C-z l" . cape-line)
("C-c p w" . cape-dict) ("C-z w" . cape-dict)
("C-c p :" . cape-emoji) ("C-z :" . cape-emoji)
("C-c p \\" . cape-tex) ("C-z \\" . cape-tex)
("C-c p _" . cape-tex) ("C-z _" . cape-tex)
("C-c p ^" . cape-tex) ("C-z ^" . cape-tex)
("C-c p &" . cape-sgml) ("C-z &" . cape-sgml)
("C-c p r" . cape-rfc1345) ("C-z r" . cape-rfc1345)
;; Add to the global default value of `completion-at-point-functions' which is ;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'. The order of the functions matters, the ;; used by `completion-at-point'. The order of the functions matters, the
;; first function returning a result wins. Note that the list of buffer-local ;; first function returning a result wins. Note that the list of buffer-local
@ -1887,6 +1925,8 @@ Currently unused
;; (add-to-list 'completion-at-point-functions #'cape-line) ;; (add-to-list 'completion-at-point-functions #'cape-line)
) )
#+end_src #+end_src
*** rust *** rust
@ -2025,7 +2065,7 @@ Currently unused
((prog-mode ((prog-mode
org-mode) . diff-hl-mode) org-mode) . diff-hl-mode)
:init :init
(diff-fl-flydiff-mode) (diff-hl-flydiff-mode)
(diff-hl-margin-mode) (diff-hl-margin-mode)
(diff-hl-show-hunk-mouse-mode)) (diff-hl-show-hunk-mouse-mode))
@ -2152,17 +2192,15 @@ The following block is 100% stolen from Dominik :P
("u" . "\\cup") ("u" . "\\cup")
("0" . "\\emptyset"))) ("0" . "\\emptyset")))
;; (yas-define-snippets
(yas-define-snippets ;; 'latex-mode
'latex-mode ;; (mapcar
(mapcar ;; (lambda (elem)
(lambda (elem) ;; (let ((key (car elem))
(let ((key (car elem)) ;; (value (cdr elem)))
(value (cdr elem))) ;; (list (concat wtf/latex-math-prefix key) value (concat "Math symbol " value))))
(list (concat wtf/latex-math-prefix key) value (concat "Math symbol " value)))) ;; swtf/latex-math-symbols))
swtf/latex-math-symbols)) )
)
#+end_src #+end_src
@ -2754,6 +2792,7 @@ Yep, none currently.
dashboard-image-banner-max-height 300 dashboard-image-banner-max-height 300
dashboard-startup-banner "~/.dotfiles/wallpaper/swarsel.png" dashboard-startup-banner "~/.dotfiles/wallpaper/swarsel.png"
dashboard-projects-backend 'projectile dashboard-projects-backend 'projectile
dashboard-projects-switch-function 'magit-status
dashboard-set-navigator t dashboard-set-navigator t
dashboard-startupify-list '(dashboard-insert-banner dashboard-startupify-list '(dashboard-insert-banner
dashboard-insert-newline dashboard-insert-newline
@ -2795,7 +2834,6 @@ Yep, none currently.
(lambda (&rest _) (browse-url "swarsel.win"))) (lambda (&rest _) (browse-url "swarsel.win")))
) )
))) )))
(setq dashboard-projects-switch-function 'project-switch-project)
#+end_src #+end_src

55
Nix.org
View file

@ -4490,6 +4490,12 @@ Section for all settings that are not really deserving of their own section.
driSupport32Bit = true; driSupport32Bit = true;
}; };
# systemd
systemd.extraConfig = ''
DefaultTimeoutStartSec=60s
DefaultTimeoutStopSec=15s
'';
# audio # audio
sound.enable = true; sound.enable = true;
# nixpkgs.config.pulseaudio = true; # nixpkgs.config.pulseaudio = true;
@ -4769,6 +4775,7 @@ Also, I define some useful shell scripts here.
# utilities # utilities
util-linux util-linux
nmap nmap
lsof
# local file sharing # local file sharing
wormhole-rs wormhole-rs
@ -5020,7 +5027,41 @@ Also, I define some useful shell scripts here.
''; '';
}) })
]; (pkgs.writeShellApplication {
name = "cdw";
runtimeInputs = [ pkgs.fzf ];
text = ''
cd "$(git worktree list | fzf | awk '{print $1}')"
'';
})
(pkgs.writeShellApplication {
name = "cdb";
runtimeInputs = [ pkgs.fzf ];
text = ''
git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')"
'';
})
# (pkgs.writeShellApplication {
# name = "cdr";
# runtimeInputs = [ pkgs.fzf ];
# text = ''
# cdr () {
# cd "$( (find /home/swarsel/Documents/GitHub -maxdepth 1 && echo /home/swarsel/.dotfiles) | fzf )"
# }
# cdr
# '';
# })
(pkgs.writeShellApplication {
name = "bak";
text = ''
cp "$1"{,.bak}
'';
})
];
# MIGHT NEED TO ENABLE THIS ON SURFACE!! # MIGHT NEED TO ENABLE THIS ON SURFACE!!
@ -5557,6 +5598,8 @@ zsh is clearly the most convenient shell for me and it happens to be super neat
passpush = "cd ~/.local/share/password-store; git add .; git commit -m 'pass file changes'; git push; cd -;"; passpush = "cd ~/.local/share/password-store; git add .; git commit -m 'pass file changes'; git push; cd -;";
passpull = "cd ~/.local/share/password-store; git pull; cd -;"; passpull = "cd ~/.local/share/password-store; git pull; cd -;";
hotspot = "nmcli connection up local; nmcli device wifi hotspot password 12345678;"; hotspot = "nmcli connection up local; nmcli device wifi hotspot password 12345678;";
cd="z";
cdr = "cd \"$( (find /home/swarsel/Documents/GitHub -maxdepth 1 && echo /home/swarsel/.dotfiles) | fzf )\"";
}; };
autosuggestion.enable = true; autosuggestion.enable = true;
enableCompletion = true; enableCompletion = true;
@ -5569,6 +5612,7 @@ zsh is clearly the most convenient shell for me and it happens to be super neat
defaultKeymap = "emacs"; defaultKeymap = "emacs";
dirHashes = { dirHashes = {
dl = "$HOME/Downloads"; dl = "$HOME/Downloads";
gh = "$HOME/Documents/GitHub";
}; };
history = { history = {
expireDuplicatesFirst = true; expireDuplicatesFirst = true;
@ -5577,6 +5621,12 @@ zsh is clearly the most convenient shell for me and it happens to be super neat
size = 10000; size = 10000;
}; };
historySubstringSearch.enable = true; historySubstringSearch.enable = true;
plugins = [
{
name = "fzf-tab";
src = pkgs.zsh-fzf-tab;
}
];
initExtra = '' initExtra = ''
bindkey "^[[1;5D" backward-word bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word bindkey "^[[1;5C" forward-word
@ -6537,8 +6587,7 @@ I am currently using SwayFX, which adds some nice effects to sway, like rounded
titlebar = false; titlebar = false;
}; };
assigns = { assigns = {
# disabled, this is too annoying to be of use "1:一" = [{ app_id = "firefox"; }];
# "1:一" = [{ app_id = "^firefox$"; }];
}; };
colors = { colors = {
focused = { focused = {

View file

@ -23,6 +23,7 @@
# utilities # utilities
util-linux util-linux
nmap nmap
lsof
# local file sharing # local file sharing
wormhole-rs wormhole-rs
@ -274,7 +275,41 @@
''; '';
}) })
]; (pkgs.writeShellApplication {
name = "cdw";
runtimeInputs = [ pkgs.fzf ];
text = ''
cd "$(git worktree list | fzf | awk '{print $1}')"
'';
})
(pkgs.writeShellApplication {
name = "cdb";
runtimeInputs = [ pkgs.fzf ];
text = ''
git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')"
'';
})
# (pkgs.writeShellApplication {
# name = "cdr";
# runtimeInputs = [ pkgs.fzf ];
# text = ''
# cdr () {
# cd "$( (find /home/swarsel/Documents/GitHub -maxdepth 1 && echo /home/swarsel/.dotfiles) | fzf )"
# }
# cdr
# '';
# })
(pkgs.writeShellApplication {
name = "bak";
text = ''
cp "$1"{,.bak}
'';
})
];
# MIGHT NEED TO ENABLE THIS ON SURFACE!! # MIGHT NEED TO ENABLE THIS ON SURFACE!!
@ -724,6 +759,8 @@ programs.zsh = {
passpush = "cd ~/.local/share/password-store; git add .; git commit -m 'pass file changes'; git push; cd -;"; passpush = "cd ~/.local/share/password-store; git add .; git commit -m 'pass file changes'; git push; cd -;";
passpull = "cd ~/.local/share/password-store; git pull; cd -;"; passpull = "cd ~/.local/share/password-store; git pull; cd -;";
hotspot = "nmcli connection up local; nmcli device wifi hotspot password 12345678;"; hotspot = "nmcli connection up local; nmcli device wifi hotspot password 12345678;";
cd="z";
cdr = "cd \"$( (find /home/swarsel/Documents/GitHub -maxdepth 1 && echo /home/swarsel/.dotfiles) | fzf )\"";
}; };
autosuggestion.enable = true; autosuggestion.enable = true;
enableCompletion = true; enableCompletion = true;
@ -736,6 +773,7 @@ programs.zsh = {
defaultKeymap = "emacs"; defaultKeymap = "emacs";
dirHashes = { dirHashes = {
dl = "$HOME/Downloads"; dl = "$HOME/Downloads";
gh = "$HOME/Documents/GitHub";
}; };
history = { history = {
expireDuplicatesFirst = true; expireDuplicatesFirst = true;
@ -744,6 +782,12 @@ programs.zsh = {
size = 10000; size = 10000;
}; };
historySubstringSearch.enable = true; historySubstringSearch.enable = true;
plugins = [
{
name = "fzf-tab";
src = pkgs.zsh-fzf-tab;
}
];
initExtra = '' initExtra = ''
bindkey "^[[1;5D" backward-word bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word bindkey "^[[1;5C" forward-word
@ -1647,8 +1691,7 @@ wayland.windowManager.sway = {
titlebar = false; titlebar = false;
}; };
assigns = { assigns = {
# disabled, this is too annoying to be of use "1:" = [{ app_id = "firefox"; }];
# "1:一" = [{ app_id = "^firefox$"; }];
}; };
colors = { colors = {
focused = { focused = {

View file

@ -63,6 +63,12 @@
driSupport32Bit = true; driSupport32Bit = true;
}; };
# systemd
systemd.extraConfig = ''
DefaultTimeoutStartSec=60s
DefaultTimeoutStopSec=15s
'';
# audio # audio
sound.enable = true; sound.enable = true;
# nixpkgs.config.pulseaudio = true; # nixpkgs.config.pulseaudio = true;

View file

@ -163,6 +163,13 @@
(evil-mode 1) (evil-mode 1)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state) ; alternative for exiting insert mode (define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state) ; alternative for exiting insert mode
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join) ; dont show help but instead do normal vim delete backwards (define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join) ; dont show help but instead do normal vim delete backwards
(define-key evil-normal-state-map (kbd "C-z") nil)
(define-key evil-insert-state-map (kbd "C-z") nil)
(define-key evil-visual-state-map (kbd "C-z") nil)
(define-key evil-motion-state-map (kbd "C-z") nil)
(define-key evil-operator-state-map (kbd "C-z") nil)
(define-key evil-replace-state-map (kbd "C-z") nil)
(define-key global-map (kbd "C-z") nil)
;; evil undo system ;; evil undo system
(evil-set-undo-system 'undo-tree) (evil-set-undo-system 'undo-tree)
@ -271,92 +278,111 @@
kept-new-versions 5 ; keep some new versions kept-new-versions 5 ; keep some new versions
kept-old-versions 2) ; and some old ones, too kept-old-versions 2) ; and some old ones, too
(defun up-directory (path)
"Move up a directory in PATH without affecting the kill buffer."
(interactive "p")
(if (string-match-p "/." (minibuffer-contents))
(let ((end (point)))
(re-search-backward "/.")
(forward-char)
(delete-region (point) end))))
(define-key minibuffer-local-filename-completion-map
[C-backspace] #'up-directory)
;; Make ESC quit prompts ;; Make ESC quit prompts
(global-set-key (kbd "<escape>") 'keyboard-escape-quit) (global-set-key (kbd "<escape>") 'keyboard-escape-quit)
;; Set up general keybindings ;; Set up general keybindings
(use-package general (use-package general
:config :config
(general-create-definer swarsel/leader-keys (general-create-definer swarsel/leader-keys
:keymaps '(normal insert visual emacs) :keymaps '(normal insert visual emacs)
:prefix "SPC" :prefix "SPC"
:global-prefix "C-SPC") :global-prefix "C-SPC")
(swarsel/leader-keys (swarsel/leader-keys
"t" '(:ignore t :which-key "toggles") "t" '(:ignore t :which-key "toggles")
"ts" '(hydra-text-scale/body :which-key "scale text") "ts" '(hydra-text-scale/body :which-key "scale text")
"tl" '(display-line-numbers-mode :which-key "line numbers") "te" '(swarsel/toggle-evil-state :which-key "emacs/evil")
"tp" '(evil-cleverparens-mode :wk "cleverparens") "tl" '(display-line-numbers-mode :which-key "line numbers")
"to" '(olivetti-mode :wk "olivetti") "tp" '(evil-cleverparens-mode :wk "cleverparens")
"td" '(darkroom-tentative-mode :wk "darkroom") "to" '(olivetti-mode :wk "olivetti")
"tw" '((lambda () (interactive) (toggle-truncate-lines)) :which-key "line wrapping") "td" '(darkroom-tentative-mode :wk "darkroom")
"m" '(:ignore m :which-key "modes/programs") "tw" '((lambda () (interactive) (toggle-truncate-lines)) :which-key "line wrapping")
"mm" '((lambda () (interactive) (mu4e)) :which-key "mu4e") "m" '(:ignore m :which-key "modes/programs")
"mg" '((lambda () (interactive) (magit-list-repositories)) :which-key "magit-list-repos") "mm" '((lambda () (interactive) (mu4e)) :which-key "mu4e")
"mc" '((lambda () (interactive) (swarsel/open-calendar)) :which-key "calendar") "mg" '((lambda () (interactive) (magit-list-repositories)) :which-key "magit-list-repos")
"mp" '(popper-toggle :which-key "popper") "mc" '((lambda () (interactive) (swarsel/open-calendar)) :which-key "calendar")
"md" '(dirvish :which-key "dirvish") "mp" '(popper-toggle :which-key "popper")
"o" '(:ignore o :which-key "org") "md" '(dirvish :which-key "dirvish")
"op" '((lambda () (interactive) (org-present)) :which-key "org-present") "o" '(:ignore o :which-key "org")
;; "c" '(:ignore c :which-key "capture") "op" '((lambda () (interactive) (org-present)) :which-key "org-present")
;; "cj" '((lambda () (interactive) (org-capture nil "jj")) :which-key "journal") ;; "c" '(:ignore c :which-key "capture")
;; "cs" '(markdown-download-screenshot :which-key "screenshot") ;; "cj" '((lambda () (interactive) (org-capture nil "jj")) :which-key "journal")
"l" '(:ignore l :which-key "links") ;; "cs" '(markdown-download-screenshot :which-key "screenshot")
"le" '((lambda () (interactive) (find-file swarsel-emacs-org-filepath)) :which-key "Emacs.org") "l" '(:ignore l :which-key "links")
"ls" '((lambda () (interactive) (find-file "/smb:Swarsel@192.168.1.3:")) :which-key "Server") "le" '((lambda () (interactive) (find-file swarsel-emacs-org-filepath)) :which-key "Emacs.org")
"lo" '(dired swarsel-obsidian-vault-directory :which-key "obsidian") "ls" '((lambda () (interactive) (find-file "/smb:Swarsel@192.168.1.3:")) :which-key "Server")
;; "la" '((lambda () (interactive) (find-file swarsel-org-anki-filepath)) :which-key "anki") "lo" '(dired swarsel-obsidian-vault-directory :which-key "obsidian")
"ln" '((lambda () (interactive) (find-file swarsel-nix-org-filepath)) :which-key "Nix.org") ;; "la" '((lambda () (interactive) (find-file swarsel-org-anki-filepath)) :which-key "anki")
"lp" '((lambda () (interactive) (projectile-switch-project)) :which-key "switch project") "ln" '((lambda () (interactive) (find-file swarsel-nix-org-filepath)) :which-key "Nix.org")
"lg" '((lambda () (interactive) (magit-list-repositories)) :which-key "list git repos") "lp" '((lambda () (interactive) (projectile-switch-project)) :which-key "switch project")
;; "a" '(:ignore a :which-key "anki") "lg" '((lambda () (interactive) (magit-list-repositories)) :which-key "list git repos")
;; "ap" '(anki-editor-push-tree :which-key "push new cards") ;; "a" '(:ignore a :which-key "anki")
;; "an" '((lambda () (interactive) (org-capture nil "a")) :which-key "new card") ;; "ap" '(anki-editor-push-tree :which-key "push new cards")
;; "as" '(swarsel-anki-set-deck-and-notetype :which-key "change deck and notetype") ;; "an" '((lambda () (interactive) (org-capture nil "a")) :which-key "new card")
"h" '(:ignore h :which-key "help") ;; "as" '(swarsel-anki-set-deck-and-notetype :which-key "change deck and notetype")
"hy" '(yas-describe-tables :which-key "yas tables") "h" '(:ignore h :which-key "help")
"hb" '(embark-bindings :which-key "current key bindings") "hy" '(yas-describe-tables :which-key "yas tables")
"h" '(:ignore t :which-key "describe") "hb" '(embark-bindings :which-key "current key bindings")
"he" 'view-echo-area-messages "h" '(:ignore t :which-key "describe")
"hf" 'describe-function "he" 'view-echo-area-messages
"hF" 'describe-face "hf" 'describe-function
"hl" '(view-lossage :which-key "show command keypresses") "hF" 'describe-face
"hL" 'find-library "hl" '(view-lossage :which-key "show command keypresses")
"hm" 'describe-mode "hL" 'find-library
"ho" 'describe-symbol "hm" 'describe-mode
"hk" 'describe-key "ho" 'describe-symbol
"hK" 'describe-keymap "hk" 'describe-key
"hp" 'describe-package "hK" 'describe-keymap
"hv" 'describe-variable "hp" 'describe-package
"hd" 'devdocs-lookup "hv" 'describe-variable
"w" '(:ignore t :which-key "window") "hd" 'devdocs-lookup
"wl" 'windmove-right "w" '(:ignore t :which-key "window")
"wh" 'windmove-left "wl" 'windmove-right
"wk" 'windmove-up "wh" 'windmove-left
"wj" 'windmove-down "wk" 'windmove-up
"wr" 'winner-redo "wj" 'windmove-down
"wd" 'delete-window "wr" 'winner-redo
"w=" 'balance-windows-area "wd" 'delete-window
"wD" 'kill-buffer-and-window "w=" 'balance-windows-area
"wu" 'winner-undo "wD" 'kill-buffer-and-window
"wr" 'winner-redo "wu" 'winner-undo
"w/" 'evil-window-vsplit "wr" 'winner-redo
"w-" 'evil-window-split "w/" 'evil-window-vsplit
"wm" '(delete-other-windows :wk "maximize") "w-" 'evil-window-split
)) "wm" '(delete-other-windows :wk "maximize")
))
;; General often used hotkeys ;; General often used hotkeys
(general-define-key (general-define-key
"C-M-a" (lambda () (interactive) (org-capture nil "a")) ; make new anki card "C-M-a" (lambda () (interactive) (org-capture nil "a")) ; make new anki card
;; "C-M-d" 'swarsel-obsidian-daily ; open daily obsidian file and create if not exist ;; "C-M-d" 'swarsel-obsidian-daily ; open daily obsidian file and create if not exist
;; "C-M-S" 'swarsel-anki-set-deck-and-notetype ; switch deck and notetype for new anki cards ;; "C-M-S" 'swarsel-anki-set-deck-and-notetype ; switch deck and notetype for new anki cards
;; "C-M-s" 'markdown-download-screenshot ; wrapper for org-download-screenshot ;; "C-M-s" 'markdown-download-screenshot ; wrapper for org-download-screenshot
"C-c d" 'duplicate-line ; duplicate line on CURSOR "C-c d" 'duplicate-line ; duplicate line on CURSOR
"C-M-j" 'consult-buffer "C-M-j" 'consult-buffer
"C-s" 'consult-line "C-s" 'consult-line
"M-o" 'avy-goto-char-timer "M-o" 'avy-goto-char-timer
"C-<f9>" 'my-python-shell-run "C-<f9>" 'my-python-shell-run
) )
(defun swarsel/toggle-evil-state ()
(interactive)
(if (or (evil-emacs-state-p) (evil-insert-state-p))
(evil-normal-state)
(evil-emacs-state)))
(setq inhibit-startup-message t) (setq inhibit-startup-message t)
@ -467,8 +493,8 @@
:after vertico :after vertico
:bind (:map vertico-map :bind (:map vertico-map
("RET" . vertico-directory-enter) ("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-word) ("C-DEL" . vertico-directory-delete-word)
("M-DEL" . vertico-directory-delete-char)) ("DEL" . vertico-directory-delete-char))
;; Tidy shadowed file names ;; Tidy shadowed file names
:hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) :hook (rfn-eshadow-update-overlay . vertico-directory-tidy))
@ -482,14 +508,17 @@
:config :config
(setq consult-fontify-max-size 1024) (setq consult-fontify-max-size 1024)
:bind :bind
("C-x b" . consult-buffer) (("C-x b" . consult-buffer)
("C-c <C-m>" . consult-global-mark) ("C-c <C-m>" . consult-global-mark)
("C-c C-a" . consult-org-agenda) ("C-c C-a" . consult-org-agenda)
("C-x O" . consult-outline) ("C-x O" . consult-org-heading)
("M-g M-g" . consult-goto-line) ("M-g M-g" . consult-goto-line)
("M-g i" . consult-imenu) ("M-g i" . consult-imenu)
("M-s s" . consult-line) ("M-s s" . consult-line)
("M-s M-s" . consult-line-multi)) ("M-s M-s" . consult-line-multi)
:map minibuffer-local-map
("C-j" . next-line)
("C-k" . previous-line)))
(use-package embark (use-package embark
:bind :bind
@ -587,13 +616,13 @@
;; ([remap describe-key] . helpful-key)) ;; ([remap describe-key] . helpful-key))
(use-package helpful (use-package helpful
:custom
(help-select-window t)
:bind :bind
(("C-h f" . helpful-callable) (("C-h f" . helpful-callable)
("C-h v" . helpful-variable) ("C-h v" . helpful-variable)
("C-h k" . helpful-key) ("C-h k" . helpful-key)
("C-h C-." . helpful-at-point))) ("C-h C-." . helpful-at-point))
:config
(setq help-window-select nil))
(use-package hydra) (use-package hydra)
@ -1223,7 +1252,7 @@
(use-package projectile (use-package projectile
:diminish projectile-mode :diminish projectile-mode
:config (projectile-mode) :config (projectile-mode)
:custom ((projectile-completion-system 'ivy)) ;; integrate ivy into completion system :custom ((projectile-completion-system 'auto)) ;; integrate ivy into completion system
:bind-keymap :bind-keymap
("C-c p" . projectile-command-map) ; all projectile commands under this ("C-c p" . projectile-command-map) ; all projectile commands under this
:init :init
@ -1245,16 +1274,18 @@
;; (add-to-list 'project-switch-commands '(magit-project-status "Magit" "m"))) ;; (add-to-list 'project-switch-commands '(magit-project-status "Magit" "m")))
(use-package magit (use-package magit
:config :config
(setq magit-repository-directories `((,swarsel-projects-directory . 1) (setq magit-repository-directories `((,swarsel-projects-directory . 1)
(,swarsel-emacs-directory . 0) (,swarsel-emacs-directory . 0)
(,swarsel-obsidian-directory . 0))) (,swarsel-obsidian-directory . 0)
:custom ("~/.dotfiles/" . 0)))
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) ; stay in the same window :custom
(magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) ; stay in the same window
;; yubikey support for pushing commits ;; yubikey support for pushing commits
;; commiting is enabled through nixos gpg-agent config ;; commiting is enabled through nixos gpg-agent config
(setenv "SSH_AUTH_SOCK" (string-chop-newline (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket"))) (setq epg-pinentry-mode 'loopback)
(setenv "SSH_AUTH_SOCK" (string-chop-newline (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))
(use-package forge (use-package forge
:after magit) :after magit)
@ -1382,23 +1413,23 @@
;; Bind dedicated completion commands ;; Bind dedicated completion commands
;; Alternative prefix keys: C-c p, M-p, M-+, ... ;; Alternative prefix keys: C-c p, M-p, M-+, ...
:bind :bind
("C-c p p" . completion-at-point) ;; capf ("C-z p" . completion-at-point) ;; capf
("C-c p t" . complete-tag) ;; etags ("C-z t" . complete-tag) ;; etags
("C-c p d" . cape-dabbrev) ;; or dabbrev-completion ("C-z d" . cape-dabbrev) ;; or dabbrev-completion
("C-c p h" . cape-history) ("C-z h" . cape-history)
("C-c p f" . cape-file) ("C-z f" . cape-file)
("C-c p k" . cape-keyword) ("C-z k" . cape-keyword)
("C-c p s" . cape-elisp-symbol) ("C-z s" . cape-elisp-symbol)
("C-c p e" . cape-elisp-block) ("C-z e" . cape-elisp-block)
("C-c p a" . cape-abbrev) ("C-z a" . cape-abbrev)
("C-c p l" . cape-line) ("C-z l" . cape-line)
("C-c p w" . cape-dict) ("C-z w" . cape-dict)
("C-c p :" . cape-emoji) ("C-z :" . cape-emoji)
("C-c p \\" . cape-tex) ("C-z \\" . cape-tex)
("C-c p _" . cape-tex) ("C-z _" . cape-tex)
("C-c p ^" . cape-tex) ("C-z ^" . cape-tex)
("C-c p &" . cape-sgml) ("C-z &" . cape-sgml)
("C-c p r" . cape-rfc1345) ("C-z r" . cape-rfc1345)
;; Add to the global default value of `completion-at-point-functions' which is ;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'. The order of the functions matters, the ;; used by `completion-at-point'. The order of the functions matters, the
;; first function returning a result wins. Note that the list of buffer-local ;; first function returning a result wins. Note that the list of buffer-local
@ -1521,7 +1552,7 @@
((prog-mode ((prog-mode
org-mode) . diff-hl-mode) org-mode) . diff-hl-mode)
:init :init
(diff-fl-flydiff-mode) (diff-hl-flydiff-mode)
(diff-hl-margin-mode) (diff-hl-margin-mode)
(diff-hl-show-hunk-mouse-mode)) (diff-hl-show-hunk-mouse-mode))
@ -1537,109 +1568,108 @@
;; (use-package yasnippet-snippets) ;; (use-package yasnippet-snippets)
;; (setq wtf/latex-greek-prefix "'") ;; (setq wtf/latex-greek-prefix "'")
;; (setq wtf/latex-math-prefix "`") ;; (setq wtf/latex-math-prefix "`")
(setq wtf/latex-mathbb-prefix "''") (setq wtf/latex-mathbb-prefix "''")
(setq swarsel/latex-mathcal-prefix "``") (setq swarsel/latex-mathcal-prefix "``")
(use-package yasnippet (use-package yasnippet
:config :config
;; (setq swtf/greek-alphabet ;; (setq swtf/greek-alphabet
;; '(("a" . "\\alpha") ;; '(("a" . "\\alpha")
;; ("b" . "\\beta" ) ;; ("b" . "\\beta" )
;; ("g" . "\\gamma") ;; ("g" . "\\gamma")
;; ("d" . "\\delta") ;; ("d" . "\\delta")
;; ("e" . "\\epsilon") ;; ("e" . "\\epsilon")
;; ("z" . "\\zeta") ;; ("z" . "\\zeta")
;; ("h" . "\\eta") ;; ("h" . "\\eta")
;; ("th" . "\\theta") ;; ("th" . "\\theta")
;; ("i" . "\\iota") ;; ("i" . "\\iota")
;; ("k" . "\\kappa") ;; ("k" . "\\kappa")
;; ("l" . "\\lambda") ;; ("l" . "\\lambda")
;; ("m" . "\\mu") ;; ("m" . "\\mu")
;; ("n" . "\\nu") ;; ("n" . "\\nu")
;; ("x" . "\\xi") ;; ("x" . "\\xi")
;; ("p" . "\\pi") ;; ("p" . "\\pi")
;; ("r" . "\\rho") ;; ("r" . "\\rho")
;; ("s" . "\\sigma") ;; ("s" . "\\sigma")
;; ("t" . "\\tau") ;; ("t" . "\\tau")
;; ("u" . "\\upsilon") ;; ("u" . "\\upsilon")
;; ("f" . "\\phi") ;; ("f" . "\\phi")
;; ("c" . "\\chi") ;; ("c" . "\\chi")
;; ("v" . "\\psi") ;; ("v" . "\\psi")
;; ("o" . "\\omega"))) ;; ("o" . "\\omega")))
;; The same for capitalized letters ;; The same for capitalized letters
;; (dolist (elem swtf/greek-alphabet) ;; (dolist (elem swtf/greek-alphabet)
;; (let ((key (car elem)) ;; (let ((key (car elem))
;; (value (cdr elem))) ;; (value (cdr elem)))
;; (when (string-equal key (downcase key)) ;; (when (string-equal key (downcase key))
;; (add-to-list 'swtf/greek-alphabet ;; (add-to-list 'swtf/greek-alphabet
;; (cons ;; (cons
;; (capitalize (car elem)) ;; (capitalize (car elem))
;; (concat ;; (concat
;; (substring value 0 1) ;; (substring value 0 1)
;; (capitalize (substring value 1 2)) ;; (capitalize (substring value 1 2))
;; (substring value 2))))))) ;; (substring value 2)))))))
;; (yas-define-snippets ;; (yas-define-snippets
;; 'latex-mode ;; 'latex-mode
;; (mapcar ;; (mapcar
;; (lambda (elem) ;; (lambda (elem)
;; (list (concat wtf/latex-greek-prefix (car elem)) (cdr elem) (concat "Greek letter " (car elem)))) ;; (list (concat wtf/latex-greek-prefix (car elem)) (cdr elem) (concat "Greek letter " (car elem))))
;; swtf/greek-alphabet)) ;; swtf/greek-alphabet))
(setq wtf/english-alphabet (setq wtf/english-alphabet
'("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z")) '("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"))
(dolist (elem wtf/english-alphabet) (dolist (elem wtf/english-alphabet)
(when (string-equal elem (downcase elem)) (when (string-equal elem (downcase elem))
(add-to-list 'wtf/english-alphabet (upcase elem)))) (add-to-list 'wtf/english-alphabet (upcase elem))))
(yas-define-snippets (yas-define-snippets
'latex-mode 'latex-mode
(mapcar (mapcar
(lambda (elem) (lambda (elem)
(list (concat wtf/latex-mathbb-prefix elem) (concat "\\mathbb{" elem "}") (concat "Mathbb letter " elem))) (list (concat wtf/latex-mathbb-prefix elem) (concat "\\mathbb{" elem "}") (concat "Mathbb letter " elem)))
wtf/english-alphabet)) wtf/english-alphabet))
(yas-define-snippets (yas-define-snippets
'latex-mode 'latex-mode
(mapcar (mapcar
(lambda (elem) (lambda (elem)
(list (concat swarsel/latex-mathcal-prefix elem) (concat "\\mathcal{" elem "}") (concat "Mathcal letter " elem))) (list (concat swarsel/latex-mathcal-prefix elem) (concat "\\mathcal{" elem "}") (concat "Mathcal letter " elem)))
wtf/english-alphabet)) wtf/english-alphabet))
(setq swtf/latex-math-symbols (setq swtf/latex-math-symbols
'(("x" . "\\times") '(("x" . "\\times")
("*" . "\\cdot") ("*" . "\\cdot")
("." . "\\ldots") ("." . "\\ldots")
("op" . "\\operatorname{$1}$0") ("op" . "\\operatorname{$1}$0")
("o" . "\\circ") ("o" . "\\circ")
("V" . "\\forall") ("V" . "\\forall")
("v" . "\\vee") ("v" . "\\vee")
("w" . "\\wedge") ("w" . "\\wedge")
("q" . "\\quad") ("q" . "\\quad")
("f" . "\\frac{$1}{$2}$0") ("f" . "\\frac{$1}{$2}$0")
("s" . "\\sum_{$1}^{$2}$0") ("s" . "\\sum_{$1}^{$2}$0")
("p" . "\\prod_{$1}^{$2}$0") ("p" . "\\prod_{$1}^{$2}$0")
("e" . "\\exists") ("e" . "\\exists")
("i" . "\\int_{$1}^{$2}$0") ("i" . "\\int_{$1}^{$2}$0")
("c" . "\\cap") ("c" . "\\cap")
("u" . "\\cup") ("u" . "\\cup")
("0" . "\\emptyset"))) ("0" . "\\emptyset")))
;; (yas-define-snippets
(yas-define-snippets ;; 'latex-mode
'latex-mode ;; (mapcar
(mapcar ;; (lambda (elem)
(lambda (elem) ;; (let ((key (car elem))
(let ((key (car elem)) ;; (value (cdr elem)))
(value (cdr elem))) ;; (list (concat wtf/latex-math-prefix key) value (concat "Math symbol " value))))
(list (concat wtf/latex-math-prefix key) value (concat "Math symbol " value)))) ;; swtf/latex-math-symbols))
swtf/latex-math-symbols)) )
)
(defun duplicate-line (arg) (defun duplicate-line (arg)
"Duplicate current line, leaving point in lower line." "Duplicate current line, leaving point in lower line."
@ -2106,6 +2136,7 @@
dashboard-image-banner-max-height 300 dashboard-image-banner-max-height 300
dashboard-startup-banner "~/.dotfiles/wallpaper/swarsel.png" dashboard-startup-banner "~/.dotfiles/wallpaper/swarsel.png"
dashboard-projects-backend 'projectile dashboard-projects-backend 'projectile
dashboard-projects-switch-function 'magit-status
dashboard-set-navigator t dashboard-set-navigator t
dashboard-startupify-list '(dashboard-insert-banner dashboard-startupify-list '(dashboard-insert-banner
dashboard-insert-newline dashboard-insert-newline
@ -2147,7 +2178,6 @@
(lambda (&rest _) (browse-url "swarsel.win"))) (lambda (&rest _) (browse-url "swarsel.win")))
) )
))) )))
(setq dashboard-projects-switch-function 'project-switch-project)
(setq gc-cons-threshold (* 800 1000 )) (setq gc-cons-threshold (* 800 1000 ))
(fset 'epg-wait-for-status 'ignore) (fset 'epg-wait-for-status 'ignore)

View file

@ -7,7 +7,7 @@ if [ "$STR" == "" ]; then
else else
VAR="0" VAR="0"
fi fi
emacsclient -c -a "" "$@" emacsclient -c -a "" "$@" # open emacs in a new frame, start new daemon if it is dead and open arg
if [ "$VAR" == "1" ] if [ "$VAR" == "1" ]
then then
swaymsg '[title="kittyterm"]' scratchpad show swaymsg '[title="kittyterm"]' scratchpad show