updating for better ook

This commit is contained in:
tavo-wasd 2024-07-11 12:00:51 -06:00
parent a9fa989189
commit 8f8b576bfb
7 changed files with 206 additions and 208 deletions

View file

@ -12,7 +12,19 @@
; (shell-command "find ~/.config/emacs/elpa/gnupg -type f -exec chmod 600 {} \;"))
;; ---
;; --- Preferences ---
;; --- Customization
(defvar custom-font "JetBrains Mono-10.5")
(defvar custom-theme 'doom-gruvbox)
(custom-set-faces
;; '(hl-line ((t (:background "gray20" :underline nil))))
'(mode-line-inactive ((t (:background "#282828" :foreground "#504945" :box nil))))
'(mode-line ((t (:background "#282828" :foreground "#a89984" :box nil))))
'(org-block ((t (:background "#282828"))))
'(org-quote ((t (:background "#282828"))))
'(default ((t (:background "#1d2021")))))
;; --- Global Preferences ---
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file 'noerror)
(setq warning-minimum-level :error)
@ -24,10 +36,6 @@
(setq-default display-line-numbers-width 3)
(delete-selection-mode 1)
(electric-indent-mode 0)
(add-hook 'org-mode-hook (lambda ()
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))))
(global-hl-line-mode 1)
(electric-pair-mode 1)
(column-number-mode)
@ -51,7 +59,6 @@
shell-mode-hook
eshell-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
;; ---
;; --- Package manager ---
(require 'package)
@ -75,65 +82,51 @@
(dolist (pkg '(all-the-icons nerd-icons markdown-mode markdown-preview-mode))
(unless (package-installed-p pkg)
(package-install pkg)))
;; ---
;; --- Theming ---
(if (eq system-type 'android)
(set-face-attribute 'default nil :height 140) ;; Android
(progn ;; Everywhere else
(set-face-attribute 'default nil :font "JetBrains Mono")
(add-to-list 'default-frame-alist '(font . "JetBrains Mono-10.5"))))
;; --- my/functions ---
(defun my/visual-fill ()
(setq visual-fill-column-width 100
visual-fill-column-center-text t)
(visual-fill-column-mode 1))
(use-package doom-themes
:init (load-theme 'doom-gruvbox t))
(defun my/hide-modeline ()
(setq-local mode-line-format nil))
(custom-set-faces
'(default ((t (:background "#1d2021"))))
'(org-block ((t (:background "#282828"))))
'(org-quote ((t (:background "#282828")))))
(defun my/insert-latex-equation ()
"Insert a LaTeX equation environment."
(interactive)
(insert "\\begin{equation}\\label{}\\begin{aligned}\n\n\\end{aligned}\\end{equation}")
(backward-char 28))
(custom-set-faces
'(mode-line ((t (:background "#282828" :foreground "#a89984" :box nil))))
'(mode-line-inactive ((t (:background "#282828" :foreground "#504945" :box nil)))))
(defun my/org-open-pdf-in-zathura ()
"Open the corresponding PDF file in Zathura for the current Org document."
(interactive)
(when (and (buffer-file-name)
(string-equal (file-name-extension (buffer-file-name)) "org"))
(let* ((org-file (buffer-file-name))
(pdf-file (concat (file-name-sans-extension org-file) ".pdf"))
(pdf-file (expand-file-name pdf-file)))
(if (file-exists-p pdf-file)
(shell-command (concat "zathura " (shell-quote-argument pdf-file)))
(message "PDF file does not exist: %s" pdf-file)))))
(custom-set-faces
'(centaur-tabs-selected ((t (:background "#282828" :foreground "#a89984" :box nil))))
'(centaur-tabs-unselected ((t (:background "#1d2021" :foreground "#504945" :box nil))))
)
;; (custom-set-faces
;; '(hl-line ((t (:background "gray20" :underline nil)))))
;; ---
(use-package paren :ensure nil
:init (setq show-paren-delay 0)
:config (show-paren-mode +1))
(use-package dashboard
:ensure t
:init
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(if (eq system-type 'android)
(progn ;; Android
(setq dashboard-startupify-list '(dashboard-insert-banner dashboard-insert-items))
(setq dashboard-startup-banner "~/.config/emacs/banner.txt"))
(progn ;; Everywhere else
(setq dashboard-startupify-list '(dashboard-insert-banner
dashboard-insert-banner-title
dashboard-insert-items))
(setq dashboard-startup-banner "~/.config/emacs/banner.txt")
(setq dashboard-banner-logo-title "✨ M'illumino d'immenso ✨")))
(setq dashboard-items '((agenda . 5)
(bookmarks . 5)
(recents . 20)))
:config
(dashboard-setup-startup-hook))
(setq initial-buffer-choice (lambda () (get-buffer-create dashboard-buffer-name)))
(defun org-babel-execute:pic (body params)
"Evaluate pic source code to create a png file
Use with: '#+begin_src pic :file example.png'
Optional: ':exports none' to avoid showing the source
Optional: ':results silent' to avoid outputting #+RESULTS:"
(or (cdr (assoc :file params))
(error "You must specify output file :file [IMAGE.png]"))
(let* ((quoted-text (replace-regexp-in-string "'" "'\\\\''" body))
(body-with-v (replace-regexp-in-string "\\\\v" "VERTICAL" quoted-text))
(cmd (concat "echo '" body-with-v "' | "
"preconv | sed \'s/VERTICAL/\\\\v/g\' | "
"pic2graph -density 200 2>/dev/null"))
(image (shell-command-to-string cmd)))
image))
(setq org-babel-default-header-args:pic '((:results . "file")))
;; --- Modes
(use-package evil
:init
(setq evil-want-integration t
@ -143,35 +136,26 @@
evil-undo-system 'undo-redo)
:config
(evil-mode 1))
(use-package evil-collection
:after evil
:config
(evil-collection-init))
(if (eq system-type 'android)
(message "Android device, ignoring centaur-tabs") ;; Android
(progn ;; Everywhere else
(use-package centaur-tabs
:demand
:config
(centaur-tabs-mode t)
:bind
("C-<iso-lefttab>" . centaur-tabs-backward)
("C-<tab>" . centaur-tabs-forward))
(setq centaur-tabs-cycle-scope 'tabs)
(setq centaur-tabs-set-modified-marker t)
(setq centaur-tabs-modified-marker "*")
(add-hook 'pdf-view-mode-hook 'centaur-tabs-local-mode)))
(add-hook 'dashboard-mode-hook 'centaur-tabs-local-mode)
(use-package dashboard
:ensure t
:init
(setq dashboard-startup-banner "~/.config/emacs/banner.txt")
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)
(setq dashboard-items '((agenda . 5) (bookmarks . 5) (recents . 20)))
(setq dashboard-startupify-list '(dashboard-insert-banner dashboard-insert-items))
:config
(dashboard-setup-startup-hook))
(setq initial-buffer-choice (lambda () (get-buffer-create dashboard-buffer-name)))
(add-hook 'dashboard-mode-hook 'my/visual-fill)
(add-hook 'org-agenda-mode-hook 'centaur-tabs-local-mode)
(add-hook 'dired-mode-hook 'centaur-tabs-local-mode)
(defun my/hide-modeline ()
(setq-local mode-line-format nil))
(add-hook 'dashboard-mode-hook 'my/hide-modeline)
(add-hook 'server-after-make-frame-hook 'dashboard-refresh-buffer)
(if (eq system-type 'android)
(message "Android device, ignoring visual-fill") ;; Android
@ -190,19 +174,68 @@
(add-hook 'pdf-view-mode-hook #'(lambda () (interactive) (display-line-numbers-mode 0)))
(add-hook 'pdf-view-mode-hook 'my/hide-modeline)))
(use-package which-key
(use-package dired
:ensure nil
:commands (dired dired-jump)
:bind (("C-x C-j" . dired-jump))
:custom ((dired-listing-switches "-AghoD --group-directories-first --color=auto --time-style=iso"))
:config
(setq which-key-idle-delay 0)
(which-key-mode))
(evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-single-up-directory
"l" 'dired-single-buffer))
(use-package dired-single)
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package dired-open
:config
;; Doesn't work as expected!
;;(add-to-list 'dired-open-functions #'dired-open-xdg t)
(setq dired-open-extensions '(("png" . "sxiv")
("jpg" . "sxiv")
("gif" . "sxiv")
("webp" . "sxiv")
("pdf" . "zathura")
("mp4" . "mpv")
("mkv" . "mpv"))))
(use-package dired-hide-dotfiles
:hook (dired-mode . dired-hide-dotfiles-mode)
:config
(evil-collection-define-key 'normal 'dired-mode-map
"." 'dired-hide-dotfiles-mode))
(if (eq system-type 'android)
(set-face-attribute 'default nil :height 140) ;; Android
(progn ;; Everywhere else
(set-face-attribute 'default nil :font custom-font)
(add-to-list 'default-frame-alist `(font . ,custom-font))))
(use-package doom-themes
:init (load-theme custom-theme t))
;; --- Org Mode ---
(setq org-startup-folded t)
(require 'org-tempo)
(setq org-src-preserve-indentation t
org-edit-src-content-indentation 0
org-confirm-babel-evaluate nil)
(require 'ob)
(setq org-babel-load-languages '((pic . t)))
(add-to-list 'org-babel-tangle-lang-exts '("pic" . "pic"))
(if (eq system-type 'android)
(message "Android device, ignoring visual-fill") ;; Android
(add-hook 'org-mode-hook 'my/visual-fill)) ;; Everywhere else
(add-hook 'org-mode-hook
(lambda ()
(setq-local electric-pair-inhibit-predicate
`(lambda (c)
(if (char-equal c ?<) t (,electric-pair-inhibit-predicate c))))
(setq-local org-src-tab-acts-natively t org-src-tab-indentation 4)
(local-set-key (kbd "C-c e") 'my/insert-latex-equation)))
(use-package org-bullets)
(custom-set-faces
'(org-level-1 ((t (:inherit outline-1 :height 1.7))))
@ -210,22 +243,6 @@
'(org-level-3 ((t (:inherit outline-3 :height 1.3))))
'(org-level-4 ((t (:inherit outline-4 :height 1.1)))))
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.35))
(setq org-latex-toc-command "\\clearpage \\tableofcontents \\clearpage")
(setq org-highlight-latex-and-related '(latex script entities))
;; (setq org-startup-with-latex-preview t)
(defun my/visual-fill ()
(setq visual-fill-column-width 100
visual-fill-column-center-text t)
(visual-fill-column-mode 1))
(if (eq system-type 'android)
(message "Android device, ignoring visual-fill") ;; Android
(progn ;; Everywhere else
(use-package visual-fill-column
:hook (org-mode . my/visual-fill))))
(if (eq system-type 'android)
(progn ;; Android custom org-latex-preview
(setq org-format-latex-options (plist-put org-format-latex-options :scale 100))
@ -246,79 +263,17 @@
(use-package citeproc)
(require 'oc-csl)))
(setq org-format-latex-options (plist-put org-format-latex-options :scale 1.35))
(setq org-latex-toc-command "\\clearpage \\tableofcontents \\clearpage")
(setq org-highlight-latex-and-related '(latex script entities))
;; (setq org-startup-with-latex-preview t)
(unless (file-directory-p "~/.local/share/emacs/ltximg/")
(make-directory "~/.local/share/emacs/ltximg/"))
(setq org-preview-latex-image-directory "~/.local/share/emacs/ltximg/")
(defun insert-latex-equation ()
"Insert a LaTeX equation environment."
(interactive)
(insert "\\begin{equation}\\label{}\\begin{aligned}\n\n\\end{aligned}\\end{equation}")
(backward-char 28))
(add-hook 'org-mode-hook
(lambda ()
(local-set-key (kbd "C-c e") 'insert-latex-equation)))
;; Use with: '#+begin_src pic :results file'
;; Optional: ':exports none' to avoid showing the source
(defun org-babel-execute:pic (body params)
(let* ((tmpfile (org-babel-temp-file "pic-" ".png"))
(quoted-text (replace-regexp-in-string "'" "'\\\\''" body))
(body-with-v (replace-regexp-in-string "\\\\v" "VERTICAL" quoted-text))
(cmd (concat "echo '" body-with-v "' | preconv | sed \'s/VERTICAL/\\\\v/g\' | pic2graph -density 200 > " tmpfile)))
(shell-command cmd)
tmpfile))
(setq org-src-preserve-indentation t
org-edit-src-content-indentation 0
org-confirm-babel-evaluate nil)
(add-hook 'org-mode-hook
(lambda ()
(setq-local org-src-tab-acts-natively t
org-src-tab-indentation 4)))
;; ---
;; --- dired ---
(use-package dired
:ensure nil
:commands (dired dired-jump)
:bind (("C-x C-j" . dired-jump))
:custom ((dired-listing-switches "-AghoD --group-directories-first --color=auto --time-style=iso"))
:config
(evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-single-up-directory
"l" 'dired-single-buffer))
(use-package dired-single)
(use-package all-the-icons-dired
:hook (dired-mode . all-the-icons-dired-mode))
(use-package dired-open
:config
;; Doesn't work as expected!
;;(add-to-list 'dired-open-functions #'dired-open-xdg t)
(setq dired-open-extensions '(("png" . "sxiv")
("jpg" . "sxiv")
("gif" . "sxiv")
("webp" . "sxiv")
("pdf" . "zathura")
("mp4" . "mpv")
("mkv" . "mpv"))))
(use-package dired-hide-dotfiles
:hook (dired-mode . dired-hide-dotfiles-mode)
:config
(evil-collection-define-key 'normal 'dired-mode-map
"H" 'dired-hide-dotfiles-mode))
;; ---
;; --- Org Agenda ---
(setq org-agenda-files (quote ("~/Documents/agenda/archive.org"
"~/Documents/agenda/agenda.org")))
;; ---
;; --- Keybinds ---
(use-package general
@ -331,7 +286,8 @@
:global-prefix "M-SPC")
(my/leader-keys
"c" '(comment-line :wk "Comment lines")
"p" 'org-latex-preview))
"p" 'org-latex-preview
"b" 'buffer-menu))
(global-set-key (kbd "<escape>") 'keyboard-escape-quit)
(global-set-key (kbd "C-=") 'text-scale-increase)
(global-set-key (kbd "C-+") 'text-scale-increase)
@ -342,7 +298,6 @@
(define-key evil-motion-state-map (kbd "RET") nil)
(define-key evil-motion-state-map (kbd "TAB") nil))
(setq org-return-follows-link t)
;; ---
(if (eq system-type 'android)
(progn
@ -354,6 +309,6 @@
(if (string-equal system-type "android")
(exec-path-from-shell-initialize)))))
(add-hook 'server-after-make-frame-hook 'dashboard-refresh-buffer)
(message "init.el loaded successfully")
;; init.el ends here

View file

@ -19,20 +19,34 @@ grep -rq 'Charging' /sys/class/power_supply/BAT* 2>/dev/null && stat='Charging'
# Get graphical battery level
case 1 in
$((bat >= 98)) ) bar="━━━━━━━━━━" ;;
$((bat >= 90)) ) bar="━━━━━━━━━─" ;;
$((bat >= 80)) ) bar="━━━━━━━━──" ;;
$((bat >= 70)) ) bar="━━━━━━━───" ;;
$((bat >= 60)) ) bar="━━━━━━────" ;;
$((bat >= 50)) ) bar="━━━━━─────" ;;
$((bat >= 40)) ) bar="━━━━──────" ;;
$((bat >= 30)) ) bar="━━━───────" ;;
$((bat >= 20)) ) bar="━━────────" ;;
$((bat >= 10)) ) bar="━─────────" ;;
$((bat >= 10)) ) bar="──────────" ;;
$((bat >= 98)) ) icon="󰁹" ;;
$((bat >= 90)) ) icon="󰂂" ;;
$((bat >= 80)) ) icon="󰂁" ;;
$((bat >= 70)) ) icon="󰂀" ;;
$((bat >= 60)) ) icon="󰁿" ;;
$((bat >= 50)) ) icon="󰁾" ;;
$((bat >= 40)) ) icon="󰁽" ;;
$((bat >= 30)) ) icon="󰁼" ;;
$((bat >= 20)) ) icon="󰁻" ;;
$((bat >= 10)) ) icon="󰁺" ;;
$((bat >= 0)) ) icon="󰂎" ;;
esac
# Charging indicator if status file indicates such state
[ "$stat" != "Charging" ] && icon="󰁹" || icon=""
echo "$icon $bar"
if [ "$stat" = "Charging" ] ; then
icon="$(printf '%s' "$icon" | sed '
s/󰁹/󰂅/;
s/󰂂/󰂋/;
s/󰂁/󰂊/;
s/󰂀/󰢞/;
s/󰁿/󰂉/;
s/󰁾/󰢝/;
s/󰁽/󰂈/;
s/󰁼/󰂇/;
s/󰁻/󰂆/;
s/󰁺/󰢜/;
s/󰂎/󰢟/;
')"
fi
echo "$icon"

View file

@ -7,7 +7,7 @@ vol=$(amixer | grep "Capture" | grep -m 1 -o '[0-9]*[0-9]%')
vol="${vol%\%*}" # Remove percentage sign
# If device is off (muted), notify mute, print volume otherwise
if amixer scontents | grep "Capture" | grep -q "\[off\]"; then echo " ──────────" && exit ; fi
if amixer scontents | grep "Capture" | grep -q "\[off\]"; then echo "󰍭 ──────────" && exit ; fi
# Define bar progress with volume
case 1 in

View file

@ -9,38 +9,40 @@ int() { # Type of interface & status
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
strength="$(awk 'NR==3 {printf("%.0f\n",$3*10/7)}' /proc/net/wireless)"
case 1 in
$((strength >= 100)) ) bar="━━━━━━━━━━" ;;
$((strength >= 90)) ) bar="━━━━━━━━━─" ;;
$((strength >= 80)) ) bar="━━━━━━━━──" ;;
$((strength >= 70)) ) bar="━━━━━━━───" ;;
$((strength >= 60)) ) bar="━━━━━━────" ;;
$((strength >= 50)) ) bar="━━━━━─────" ;;
$((strength >= 40)) ) bar="━━━━──────" ;;
$((strength >= 30)) ) bar="━━━───────" ;;
$((strength >= 20)) ) bar="━━────────" ;;
$((strength >= 10)) ) bar="━─────────" ;;
$((strength >= 0)) ) bar="──────────" ;;
$((strength >= 85)) ) icon="󰤨" ;;
$((strength >= 65)) ) icon="󰤥" ;;
$((strength >= 45)) ) icon="󰤢" ;;
$((strength >= 25)) ) icon="󰤟" ;;
$((strength >= 0)) ) icon="󰤯" ;;
esac
echo "󰖩 $bar"
echo "$icon"
return 0
fi
# If down interfaces, exit with icon
grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null && echo "󰖪 ──────────" && return 0
grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null && echo "󰤮" && return 0
grep -xq 'down' /sys/class/net/e*/operstate 2>/dev/null && echo "󰲛" && return 0
}
# Run 'int'
info=$(int)
icon=$(int)
# Check if a VPN is enabled
vpn="$( \
sed "s/.*//" /sys/class/net/tun*/operstate 2>/dev/null
sed "s/.*//" /sys/class/net/wg*/operstate 2>/dev/null \
)"
# If so, change icon
[ -n "$vpn" ] && info="$(printf "$info" | sed 's/󰛳//' | sed 's/󰖩//')"
if [ -n "$vpn" ] ; then
icon="$(printf '%s' "$icon" | sed '
s/󰤨/󰤪/;
s/󰤥/󰤧/;
s/󰤢/󰤤/;
s/󰤟/󰤡/;
s/󰤯/󰤬/;
')"
fi
# Print $info
printf "%s" "$info"
printf "%s" "$icon"

View file

@ -55,7 +55,7 @@ short_time() {
short_path() {
curr_path="$(pwd | sed 's/\/data\/data\/com.termux\/files\/home/~/g;s/\/home\/[A-Za-z]*/~/g')"
if [ "${#curr_path}" -gt 25 ] ; then
if [ "${#curr_path}" -gt 10 ] ; then
curr_path="${curr_path##*/}"
if git rev-parse --is-inside-work-tree >/dev/null 2>&1 ; then
curr_proj="$(git rev-parse --show-toplevel 2>/dev/null)"
@ -71,11 +71,15 @@ short_path() {
printf '%s' "$curr_path"
}
[ -e "/data/data/com.termux" ] && HOSTNAME=""
[ "${HOSTNAME:=$(hostname -s)}" = "laptop" ] && HOSTNAME="󰌢"
[ "${HOSTNAME:=$(hostname -s)}" = "desktop" ] && HOSTNAME="󰇅"
PS1='
$(tput setaf 240)╭─$(tput setaf 7)$(tput setab 7)$(tput setaf 238)$?\
$(tput setaf 7)$(tput setab 108)\
$(tput setaf 235)$(tput setab 108) \
${USER:=$(id -un)}@${HOSTNAME:=$(hostname -s)} \
${HOSTNAME} \
$(tput setaf 108)$(tput setab 66)\
$(tput setab 66)$(tput setaf 235)$(short_path) $(tput sgr0)\
$(tput setaf 66)\

View file

@ -40,7 +40,7 @@ short_time() {
short_path() {
curr_path="$(pwd | sed 's/\/data\/data\/com.termux\/files\/home/~/g;s/\/home\/[A-Za-z]*/~/g')"
if [ "${#curr_path}" -gt 25 ] ; then
if [ "${#curr_path}" -gt 10 ] ; then
curr_path="${curr_path##*/}"
if git rev-parse --is-inside-work-tree >/dev/null 2>&1 ; then
curr_proj="$(git rev-parse --show-toplevel 2>/dev/null)"
@ -56,11 +56,15 @@ short_path() {
printf '%s' "$curr_path"
}
[ -e "/data/data/com.termux" ] && HOSTNAME=""
[ "${HOSTNAME:=$(hostname -s)}" = "laptop" ] && HOSTNAME="󰌢"
[ "${HOSTNAME:=$(hostname -s)}" = "desktop" ] && HOSTNAME="󰇅"
PS1='
$(tput setaf 240)╭─$(tput setaf 7)$(tput setab 7)$(tput setaf 238)$?\
$(tput setaf 7)$(tput setab 108)\
$(tput setaf 235)$(tput setab 108) \
${USER:=$(id -un)}@${HOSTNAME:=$(hostname -s)} \
${HOSTNAME} \
$(tput setaf 108)$(tput setab 66) \
$(tput setab 66)$(tput setaf 235)$(short_path) $(tput sgr0)\
$(tput setaf 66)\

19
snippets/academic.org Normal file
View file

@ -0,0 +1,19 @@
#+title: {{Title}}
#+author: {{Author}}
#+options: toc:nil
#+latex_header: \usepackage[margin=1in]{geometry}
#+latex_header: \usepackage[spanish]{babel}
#+latex_header: \AtBeginDocument{\selectlanguage{spanish}}
#+latex_header: \usepackage{multicol,lipsum}
#+cite_export: csl ~/.config/snippets/acs.csl
#+bibliography: bibliography.bib
#+begin_abstract
{{Abstract}}
#+end_abstract
* Sección
* Referencias
#+print_bibliography: