Add more YASnippets and update some scripts

This commit is contained in:
foo-dogsquared 2020-06-02 22:53:56 +08:00
parent d117f30281
commit 6ba3713bca
28 changed files with 176 additions and 63 deletions

View File

@ -16,6 +16,6 @@ selection=$(awk 'match($0, /([0-9A-F ]+)\s+; fully-qualified\s+# (\S+) E[[:digit
| awk '{print $1}') | awk '{print $1}')
if [ -n "$selection" ]; then if [ -n "$selection" ]; then
printf "$selection" | xclip -selection clipboard && notify-send "'$(xclip -o -selection clipboard)' has been copied to clipboard." printf "%s" "$selection" | xclip -selection clipboard && notify-send "'$(xclip -o -selection clipboard)' has been copied to clipboard."
fi fi

View File

@ -17,6 +17,6 @@
set -o pipefail set -o pipefail
man -k . | rofi -dmenu -p 'Choose a manual' -theme fds-mini-sidebar -width 60 | awk '{print $1}' | xargs --no-run-if-empty $TERMINAL --command man man -k . | rofi -dmenu -p 'Choose a manual' -theme fds-mini-sidebar -width 60 | awk '{print $1}' | xargs --no-run-if-empty "$TERMINAL" --command man

View File

@ -2,55 +2,25 @@
# Extracts the archive. # Extracts the archive.
# The process can vary depending on the file extension. # The process can vary depending on the file extension.
# Usage: $0 ARCHIVE_FILE
# Dependencies: # Dependencies:
# * xxd V1.10 27oct98 by Juergen Weigert
# * UnZip 6.00 of 20 April 2009
# * tar (GNU tar) 1.32 # * tar (GNU tar) 1.32
# * printf (GNU coreutils 8.31)
function get_bytes() { # Extract each given filename.
local file=$1 for f in $@; do
local length=${2:-20} if [ -n "$(file "$f" | grep -i '7-zip archive data')" ]; then
7z x "$f"
# Getting the file signature. elif [ -n "$(file "$f" | grep -i 'zip archive data')" ]; then
# At most, we will just get the first 20 bytes of the file. unzip "$f"
local file_sig=$(xxd -l "$length" -ps "$file") elif [ -n "$(file "$f" | grep -i 'POSIX tar archive')" ]; then
printf "$file_sig" tar --extract --file $f # or 'tar xf $f'
} elif [ -n "$(file "$f" | grep -i 'gzip compressed data')" ]; then
tar --extract --gzip --file "$f" # or 'tar xzf $f'
function extract_path_without_ext() { elif [ -n "$(file "$f" | grep -i 'bzip2 compressed data')" ]; then
local path=$1 tar --extract --bzip2 --file "$f" # or 'tar xjf $f'
elif [ -n "$(file "$f" | grep -i 'RAR archive data')" ]; then
local filename=$(basename -- "$path") unrar x "$f"
# Return the filename without the file extension.
# For more information, you can look up the parameter expansion in
# https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html.
# Even if the filename has no extension, it will print the whole filename.
printf "${filename%.*}"
}
function extract_file() {
local file=$1
local length=$2
# Checking the file signatures.
# The reference is at https://en.wikipedia.org/wiki/List_of_file_signatures.
local file_sig=$(get_bytes "$file" "$length")
# Extracting the extension out of the given file and creating a directory out of it.
local file_without_ext=$(extract_path_without_ext "$file")
mkdir -p "$file_without_ext"
# Checking if the file signature matches of a zip
if [[ $(printf "$file_sig" | head -c 4) == "504b" ]]; then
cd "$file_without_ext" && unzip "../$file"
else else
tar xf "$file" --directory "$file_without_ext" echo "unrecognized format."
fi fi
} done
extract_file $1

View File

@ -15,5 +15,5 @@
set -o pipefail set -o pipefail
notify-send "Select a region for the OCR" notify-send "Select a region for the OCR"
maim -s | tesseract - stdout maim --select --hidecursor | tesseract - stdout

View File

@ -12,5 +12,5 @@
set -o pipefail set -o pipefail
notify-send "Select a region for the barcode (QR codes, ISBN, bar codes)" notify-send "Select a region for the barcode (QR codes, ISBN, bar codes)"
maim -s | zbarimg - --quiet | perl -pe 's|(.+?):||' maim --select --hidecursor | zbarimg - --quiet | perl -pe 's|(.+?):||'

View File

@ -65,8 +65,11 @@
(after! tex (after! tex
(TeX-engine-set "luatex") (TeX-engine-set "luatex")
(add-to-list 'safe-local-variable-values (add-to-list 'safe-local-variable-values
'(TeX-command-extra-options . "-shell-escape")) '(TeX-command-extra-options . "-shell-escape")))
)
; Disable indentation in org-mode (it's very spacey in my opinion).
(add-hook! org-mode
(setq org-indent-mode nil))
;;(use-package! ewal ;;(use-package! ewal
;; :init (setq ewal-json-file "~/.cache/wal/colors.json" ;; :init (setq ewal-json-file "~/.cache/wal/colors.json"

View File

@ -138,10 +138,16 @@
;;nim ; python + lisp at the speed of c ;;nim ; python + lisp at the speed of c
;;nix ; I hereby declare "nix geht mehr!" ;;nix ; I hereby declare "nix geht mehr!"
;;ocaml ; an objective camel ;;ocaml ; an objective camel
org ; organize your plain life in plain text (org +brain
+hugo
+jupyter
+noter
+pandoc
+present
+roam) ; organize your plain life in plain text
;;perl ; write code no one else can comprehend ;;perl ; write code no one else can comprehend
;;php ; perl's insecure younger brother ;;php ; perl's insecure younger brother
;;plantuml ; diagrams for confusing people more plantuml ; diagrams for confusing people more
;;purescript ; javascript, but functional ;;purescript ; javascript, but functional
python ; beautiful is better than ugly python ; beautiful is better than ugly
;;qt ; the 'cutest' gui framework ever ;;qt ; the 'cutest' gui framework ever

View File

@ -51,7 +51,5 @@
;;;;;;;;;;;; ;;;;;;;;;;;;
; PACKAGES ; ; PACKAGES ;
;;;;;;;;;;;; ;;;;;;;;;;;;
(package! org-brain)
(package! modus-operandi-theme) (package! modus-operandi-theme)
(package! modus-vivendi-theme) (package! modus-vivendi-theme)
;;(package! org-roam)

View File

@ -0,0 +1,72 @@
\documentclass[class=memoir, crop=false, oneside, 14pt]{standalone}
% all of the packages to be used
\usepackage[nocomments]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{fontawesome}
\usepackage[english]{babel}
\usepackage[rgb]{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{fancyhdr}
\usepackage{minted}
\usepackage[most]{tcolorbox}
\usepackage[colorlinks=true, linkcolor=., urlcolor=blue]{hyperref}
\usepackage{kpfonts}
% using the fancy header package
% http://linorg.usp.br/CTAN/macros/latex/contrib/fancyhdr/fancyhdr.pdf
\pagestyle{fancy}
% fill the header with the format
\fancyhead[L]{\doctitle}
\fancyhead[R]{\nouppercase{\rightmark}}
% fill the footer with the format
\fancyfoot[C]{\nouppercase{\leftmark}}
\fancyfoot[R]{\thepage}
% set the width of the horizontal bars in the header
\renewcommand{\headrulewidth}{2pt}
\renewcommand{\footrulewidth}{1pt}
% set the paragraph formatting
\renewcommand{\baselinestretch}{1.35}
% set chapter style
\chapterstyle{bianchi}
% set chapter spacing for easier reading on digital screen
\setlength{\beforechapskip}{-\beforechapskip}
% document metadata
\author{${1:"Gabriel Arazas"}}
\title{${2:"New Title"}}
\date{`!p
`}
\begin{document}
% Frontmatter of the class note if it's compiled standalone
\renewcommand{\abstractname}{Summary}
\maketitle
\newpage
\frontmatter
\chapter{Preface}
$3
\newpage
\tableofcontents
\newpage
\listoffigures
\newpage
\mainmatter
% Core content (HINT: always start with chapter LaTeX tag)
$0
\end{document}

View File

@ -0,0 +1 @@
latex-mode

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: Org-Mode dynamic blocks
# key: block
# --
\#+BEGIN: ${1:<PARAMETERS>}
$2
\#+END:

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode boldface
# key: bf
# --
*$1* $0

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode definition list
# key: dl
# --
- ${1:<TERM>} :: ${2:<DEFINITION>}

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: Org-Mode drawer
# key: drawer
# --
:${1:<DRAWERNAME>}:
$2
:END:

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode footnotes
# key: fn
# --
[fn:: $1]

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode header
# key: header
# --
`(make-string (read-number "WHAT IS THE NUMBER?: ") ?*)`

View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: Org-Mode image
# key: img
# --
#+CAPTION: $1
#+NAME: $2
[[${3:<LINK>}]

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode italics
# key: it
# --
/$1/ $0

View File

@ -2,4 +2,4 @@
# name: Org-Mode link # name: Org-Mode link
# key: link # key: link
# -- # --
[[${1:URL}][${2:Description}]] [[${1:URL}][${2:Description}]

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode monospace
# key: tt
# --
~$1~ $0

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode subscript
# key: ==
# --
_{$1} $0

View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: Org-Mode superscript
# key: --
# --
^{$1} $0

View File

@ -29,3 +29,6 @@ export TERMINAL="alacritty"
export BROWSER="firefox" export BROWSER="firefox"
export READ="zathura" export READ="zathura"
export FILE="lf" export FILE="lf"
# This is a program that `sudo -a` needs for prompting the user and password.
export SUDO_ASKPASS="$HOME/.local/bin/askpass"

View File

@ -1,6 +1,4 @@
if [[ -f $HOME/.profile ]]; then if [[ -f $ZDOTDIR/.profile ]]; then
source $HOME/.profile source $ZDOTDIR/.profile
fi fi
# This is a program that `sudo -a` needs for prompting the user and password.
export SUDO_ASKPASS="$HOME/bin/askpass"