From 6ba3713bca4cebea767f10d56b5977246a8fae6d Mon Sep 17 00:00:00 2001 From: foo-dogsquared Date: Tue, 2 Jun 2020 22:53:56 +0800 Subject: [PATCH] Add more YASnippets and update some scripts --- bin/choose-emoji-menu | 2 +- bin/choose-manual-menu | 2 +- bin/extract | 66 ++++++-------------- bin/ocr | 2 +- bin/parse-barcodes | 2 +- emacs/config.el | 7 ++- emacs/init.el | 10 ++- emacs/packages.el | 2 - emacs/snippets/latex-mode/{bf => boldface} | 0 emacs/snippets/latex-mode/{it => italics} | 0 emacs/snippets/latex-mode/{li => listitem} | 0 emacs/snippets/latex-mode/{tt => teletype} | 0 emacs/snippets/latex-mode/template | 72 ++++++++++++++++++++++ emacs/snippets/org-mode/.yas-parents | 1 + emacs/snippets/org-mode/block | 7 +++ emacs/snippets/org-mode/boldface | 5 ++ emacs/snippets/org-mode/deflist | 5 ++ emacs/snippets/org-mode/drawer | 8 +++ emacs/snippets/org-mode/footnote | 5 ++ emacs/snippets/org-mode/header | 5 ++ emacs/snippets/org-mode/img | 7 +++ emacs/snippets/org-mode/italics | 5 ++ emacs/snippets/org-mode/link | 2 +- emacs/snippets/org-mode/monospace | 5 ++ emacs/snippets/org-mode/subscript | 5 ++ emacs/snippets/org-mode/superscript | 5 ++ zsh/.profile | 3 + zsh/.zprofile | 6 +- 28 files changed, 176 insertions(+), 63 deletions(-) rename emacs/snippets/latex-mode/{bf => boldface} (100%) rename emacs/snippets/latex-mode/{it => italics} (100%) rename emacs/snippets/latex-mode/{li => listitem} (100%) rename emacs/snippets/latex-mode/{tt => teletype} (100%) create mode 100644 emacs/snippets/latex-mode/template create mode 100644 emacs/snippets/org-mode/.yas-parents create mode 100644 emacs/snippets/org-mode/block create mode 100644 emacs/snippets/org-mode/boldface create mode 100644 emacs/snippets/org-mode/deflist create mode 100644 emacs/snippets/org-mode/drawer create mode 100644 emacs/snippets/org-mode/footnote create mode 100644 emacs/snippets/org-mode/header create mode 100644 emacs/snippets/org-mode/img create mode 100644 emacs/snippets/org-mode/italics create mode 100644 emacs/snippets/org-mode/monospace create mode 100644 emacs/snippets/org-mode/subscript create mode 100644 emacs/snippets/org-mode/superscript diff --git a/bin/choose-emoji-menu b/bin/choose-emoji-menu index 1a26ed5..6109c64 100755 --- a/bin/choose-emoji-menu +++ b/bin/choose-emoji-menu @@ -16,6 +16,6 @@ selection=$(awk 'match($0, /([0-9A-F ]+)\s+; fully-qualified\s+# (\S+) E[[:digit | awk '{print $1}') 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 diff --git a/bin/choose-manual-menu b/bin/choose-manual-menu index f7e24e3..772c2de 100755 --- a/bin/choose-manual-menu +++ b/bin/choose-manual-menu @@ -17,6 +17,6 @@ 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 diff --git a/bin/extract b/bin/extract index f070049..76529de 100755 --- a/bin/extract +++ b/bin/extract @@ -1,56 +1,26 @@ #!/usr/bin/env sh -# Extracts the archive. -# The process can vary depending on the file extension. -# Usage: $0 ARCHIVE_FILE +# Extracts the archive. +# The process can vary depending on the file extension. # Dependencies: -# * xxd V1.10 27oct98 by Juergen Weigert -# * UnZip 6.00 of 20 April 2009 # * tar (GNU tar) 1.32 -# * printf (GNU coreutils 8.31) -function get_bytes() { - local file=$1 - local length=${2:-20} - - # Getting the file signature. - # At most, we will just get the first 20 bytes of the file. - local file_sig=$(xxd -l "$length" -ps "$file") - printf "$file_sig" -} - -function extract_path_without_ext() { - local path=$1 - - local filename=$(basename -- "$path") - - # 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" +# Extract each given filename. +for f in $@; do + if [ -n "$(file "$f" | grep -i '7-zip archive data')" ]; then + 7z x "$f" + elif [ -n "$(file "$f" | grep -i 'zip archive data')" ]; then + unzip "$f" + elif [ -n "$(file "$f" | grep -i 'POSIX tar archive')" ]; then + 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' + elif [ -n "$(file "$f" | grep -i 'bzip2 compressed data')" ]; then + tar --extract --bzip2 --file "$f" # or 'tar xjf $f' + elif [ -n "$(file "$f" | grep -i 'RAR archive data')" ]; then + unrar x "$f" else - tar xf "$file" --directory "$file_without_ext" + echo "unrecognized format." fi -} - -extract_file $1 - +done diff --git a/bin/ocr b/bin/ocr index 1169de8..7b74f9e 100755 --- a/bin/ocr +++ b/bin/ocr @@ -15,5 +15,5 @@ set -o pipefail notify-send "Select a region for the OCR" -maim -s | tesseract - stdout +maim --select --hidecursor | tesseract - stdout diff --git a/bin/parse-barcodes b/bin/parse-barcodes index e43d271..e5b566f 100755 --- a/bin/parse-barcodes +++ b/bin/parse-barcodes @@ -12,5 +12,5 @@ set -o pipefail 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|(.+?):||' diff --git a/emacs/config.el b/emacs/config.el index 6c26c24..ffaf084 100644 --- a/emacs/config.el +++ b/emacs/config.el @@ -65,8 +65,11 @@ (after! tex (TeX-engine-set "luatex") (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 ;; :init (setq ewal-json-file "~/.cache/wal/colors.json" diff --git a/emacs/init.el b/emacs/init.el index 0015816..6640f70 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -138,10 +138,16 @@ ;;nim ; python + lisp at the speed of c ;;nix ; I hereby declare "nix geht mehr!" ;;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 ;;php ; perl's insecure younger brother - ;;plantuml ; diagrams for confusing people more + plantuml ; diagrams for confusing people more ;;purescript ; javascript, but functional python ; beautiful is better than ugly ;;qt ; the 'cutest' gui framework ever diff --git a/emacs/packages.el b/emacs/packages.el index 0c5800c..7df82b7 100644 --- a/emacs/packages.el +++ b/emacs/packages.el @@ -51,7 +51,5 @@ ;;;;;;;;;;;; ; PACKAGES ; ;;;;;;;;;;;; -(package! org-brain) (package! modus-operandi-theme) (package! modus-vivendi-theme) -;;(package! org-roam) diff --git a/emacs/snippets/latex-mode/bf b/emacs/snippets/latex-mode/boldface similarity index 100% rename from emacs/snippets/latex-mode/bf rename to emacs/snippets/latex-mode/boldface diff --git a/emacs/snippets/latex-mode/it b/emacs/snippets/latex-mode/italics similarity index 100% rename from emacs/snippets/latex-mode/it rename to emacs/snippets/latex-mode/italics diff --git a/emacs/snippets/latex-mode/li b/emacs/snippets/latex-mode/listitem similarity index 100% rename from emacs/snippets/latex-mode/li rename to emacs/snippets/latex-mode/listitem diff --git a/emacs/snippets/latex-mode/tt b/emacs/snippets/latex-mode/teletype similarity index 100% rename from emacs/snippets/latex-mode/tt rename to emacs/snippets/latex-mode/teletype diff --git a/emacs/snippets/latex-mode/template b/emacs/snippets/latex-mode/template new file mode 100644 index 0000000..b897866 --- /dev/null +++ b/emacs/snippets/latex-mode/template @@ -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} \ No newline at end of file diff --git a/emacs/snippets/org-mode/.yas-parents b/emacs/snippets/org-mode/.yas-parents new file mode 100644 index 0000000..0e45870 --- /dev/null +++ b/emacs/snippets/org-mode/.yas-parents @@ -0,0 +1 @@ +latex-mode diff --git a/emacs/snippets/org-mode/block b/emacs/snippets/org-mode/block new file mode 100644 index 0000000..2fd262a --- /dev/null +++ b/emacs/snippets/org-mode/block @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: Org-Mode dynamic blocks +# key: block +# -- +\#+BEGIN: ${1:} +$2 +\#+END: diff --git a/emacs/snippets/org-mode/boldface b/emacs/snippets/org-mode/boldface new file mode 100644 index 0000000..092cc31 --- /dev/null +++ b/emacs/snippets/org-mode/boldface @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode boldface +# key: bf +# -- +*$1* $0 diff --git a/emacs/snippets/org-mode/deflist b/emacs/snippets/org-mode/deflist new file mode 100644 index 0000000..a906447 --- /dev/null +++ b/emacs/snippets/org-mode/deflist @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode definition list +# key: dl +# -- +- ${1:} :: ${2:} diff --git a/emacs/snippets/org-mode/drawer b/emacs/snippets/org-mode/drawer new file mode 100644 index 0000000..16bb816 --- /dev/null +++ b/emacs/snippets/org-mode/drawer @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# name: Org-Mode drawer +# key: drawer +# -- +:${1:}: +$2 +:END: + diff --git a/emacs/snippets/org-mode/footnote b/emacs/snippets/org-mode/footnote new file mode 100644 index 0000000..c2ba806 --- /dev/null +++ b/emacs/snippets/org-mode/footnote @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode footnotes +# key: fn +# -- +[fn:: $1] diff --git a/emacs/snippets/org-mode/header b/emacs/snippets/org-mode/header new file mode 100644 index 0000000..4f19dbd --- /dev/null +++ b/emacs/snippets/org-mode/header @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode header +# key: header +# -- +`(make-string (read-number "WHAT IS THE NUMBER?: ") ?*)` \ No newline at end of file diff --git a/emacs/snippets/org-mode/img b/emacs/snippets/org-mode/img new file mode 100644 index 0000000..a43d803 --- /dev/null +++ b/emacs/snippets/org-mode/img @@ -0,0 +1,7 @@ +# -*- mode: snippet -*- +# name: Org-Mode image +# key: img +# -- +#+CAPTION: $1 +#+NAME: $2 +[[${3:}] diff --git a/emacs/snippets/org-mode/italics b/emacs/snippets/org-mode/italics new file mode 100644 index 0000000..02531ce --- /dev/null +++ b/emacs/snippets/org-mode/italics @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode italics +# key: it +# -- +/$1/ $0 diff --git a/emacs/snippets/org-mode/link b/emacs/snippets/org-mode/link index 329ebca..2f7b15e 100644 --- a/emacs/snippets/org-mode/link +++ b/emacs/snippets/org-mode/link @@ -2,4 +2,4 @@ # name: Org-Mode link # key: link # -- -[[${1:URL}][${2:Description}]] +[[${1:URL}][${2:Description}] diff --git a/emacs/snippets/org-mode/monospace b/emacs/snippets/org-mode/monospace new file mode 100644 index 0000000..1725d51 --- /dev/null +++ b/emacs/snippets/org-mode/monospace @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode monospace +# key: tt +# -- +~$1~ $0 diff --git a/emacs/snippets/org-mode/subscript b/emacs/snippets/org-mode/subscript new file mode 100644 index 0000000..3321924 --- /dev/null +++ b/emacs/snippets/org-mode/subscript @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode subscript +# key: == +# -- +_{$1} $0 diff --git a/emacs/snippets/org-mode/superscript b/emacs/snippets/org-mode/superscript new file mode 100644 index 0000000..96aab4e --- /dev/null +++ b/emacs/snippets/org-mode/superscript @@ -0,0 +1,5 @@ +# -*- mode: snippet -*- +# name: Org-Mode superscript +# key: -- +# -- +^{$1} $0 diff --git a/zsh/.profile b/zsh/.profile index da13606..f10ef82 100644 --- a/zsh/.profile +++ b/zsh/.profile @@ -29,3 +29,6 @@ export TERMINAL="alacritty" export BROWSER="firefox" export READ="zathura" export FILE="lf" + +# This is a program that `sudo -a` needs for prompting the user and password. +export SUDO_ASKPASS="$HOME/.local/bin/askpass" diff --git a/zsh/.zprofile b/zsh/.zprofile index d1efda3..b9f2d60 100644 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -1,6 +1,4 @@ -if [[ -f $HOME/.profile ]]; then - source $HOME/.profile +if [[ -f $ZDOTDIR/.profile ]]; then + source $ZDOTDIR/.profile fi -# This is a program that `sudo -a` needs for prompting the user and password. -export SUDO_ASKPASS="$HOME/bin/askpass"