diff options
Diffstat (limited to '.scripts')
-rwxr-xr-x | .scripts/compile | 18 | ||||
-rwxr-xr-x | .scripts/ext | 29 | ||||
-rwxr-xr-x | .scripts/preview | 9 |
3 files changed, 56 insertions, 0 deletions
diff --git a/.scripts/compile b/.scripts/compile new file mode 100755 index 0000000..41dd951 --- /dev/null +++ b/.scripts/compile @@ -0,0 +1,18 @@ +#!/usr/bin/env sh + +file=$(readlink -f "$1") +base="${file%.*}" +ext="${file##*.}" + +case "$ext" in +ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf >"$base".pdf ;; +[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf >"$base".pdf ;; +md) lowdown -d nointem -e super "$file" -Tms | groff -T pdf -ms -kept >"$base".pdf ;; +h) sudo make install ;; +c) cc "$file" -o "$base" && "$base" ;; +py) python "$file" ;; +rs) cargo build ;; +go) go run "$file" ;; +sent) setsid -f sent "$file" 2>/dev/null ;; +*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;; +esac diff --git a/.scripts/ext b/.scripts/ext new file mode 100755 index 0000000..4b85f88 --- /dev/null +++ b/.scripts/ext @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +archive="$(readlink -f "$*")" && + directory="$(echo "$archive" | sed 's/\.[^\/.]*$//')" && + mkdir -p "$directory" && + cd "$directory" || exit + +[ "$archive" = "" ] && printf "Give archive to extract as argument\\n" && exit + +if [ -f "$archive" ]; then + case "$archive" in + *.tar.bz2 | *.tbz2) tar xvjf "$archive" ;; + *.tar.xz) tar -xf "$archive" ;; + *.tar.gz | *.tgz) tar xvzf "$archive" ;; + *.lzma) unlzma "$archive" ;; + *.bz2) bunzip2 "$archive" ;; + *.rar) unrar x -ad "$archive" ;; + *.gz) gunzip "$archive" ;; + *.tar) tar xvf "$archive" ;; + *.zip) unzip "$archive" ;; + *.Z) uncompress "$archive" ;; + *.7z) 7z x "$archive" ;; + *.xz) unxz "$archive" ;; + *.exe) cabextract "$archive" ;; + *) printf "extract: '%s' - unknown archive method\\n" "$archive" ;; + esac +else + printf "File \"%s\" not found\\n" "$archive" +fi diff --git a/.scripts/preview b/.scripts/preview new file mode 100755 index 0000000..822e5b0 --- /dev/null +++ b/.scripts/preview @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +basename="$(echo "$1" | sed 's/\.[^\/.]*$//')" + +case "$1" in +*.tex | *.m[dse] | *.[rR]md | *.mom | *.[0-9]) compile "$1" && setsid -f xdg-open "$basename".pdf >/dev/null 2>&1 ;; +*.html) setsid -f "$BROWSER" "$basename".html >/dev/null 2>&1 ;; +*.sent) setsid -f sent "$1" >/dev/null 2>&1 ;; +esac |