summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarrick Lo <warrick.s.z.lo@gmail.com>2021-12-03 05:50:44 -0800
committerWarrick Lo <warrick.s.z.lo@gmail.com>2021-12-03 05:50:44 -0800
commit47ea7f888cb0117635d69ba6d36464714801c9af (patch)
treee7f7114151165224f524479fb71c2dc367802cd2
parent6fa236111927666155093e4fe915897a89e3cfd7 (diff)
Add shell scripts
-rw-r--r--.config/aliasrc3
-rwxr-xr-xbin/clhs11
-rwxr-xr-xbin/pdfman5
-rwxr-xr-xbin/setbg26
4 files changed, 45 insertions, 0 deletions
diff --git a/.config/aliasrc b/.config/aliasrc
index 3f63899..4f69c77 100644
--- a/.config/aliasrc
+++ b/.config/aliasrc
@@ -21,5 +21,8 @@ alias ipinfo="curl https://ipinfo.io/ip -w '\n'"
# Alias vim to neovim.
alias vim="nvim"
+# Clear history (needs to be sourced).
+alias clhs="source \$HOME/bin/clhs"
+
# Alias git bare to manage configuration files.
alias cfg="/usr/bin/git --git-dir=\$HOME/cfg --work-tree=\$HOME"
diff --git a/bin/clhs b/bin/clhs
new file mode 100755
index 0000000..8c6da89
--- /dev/null
+++ b/bin/clhs
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Clear shell history.
+
+if [ -f "$HISTFILE" ]; then
+ : > "$HISTFILE"
+fi
+
+# Script must be sourced for this to work.
+history -c > /dev/null 2>&1
+history -p > /dev/null 2>&1
diff --git a/bin/pdfman b/bin/pdfman
new file mode 100755
index 0000000..b8a815c
--- /dev/null
+++ b/bin/pdfman
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Open man pages as a PDF in zathura.
+
+man -Tpdf "$@" | zathura -
diff --git a/bin/setbg b/bin/setbg
new file mode 100755
index 0000000..e01627f
--- /dev/null
+++ b/bin/setbg
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Set images as background with feh.
+
+# Get absolute path of file.
+if ! file="$(realpath "$1" 2> /dev/null)"; then
+ echo "Usage: setbg <file>"
+ exit 0
+fi
+
+# Check if file is an image.
+case "$(file -bi "$file")" in
+ image/*)
+ ;;
+ *)
+ echo "setbg: invalid file operand" 1>&2
+ exit 1
+ ;;
+esac
+
+printf -- "#!/bin/sh\n\n" > "$HOME/bin/bg"
+printf -- "feh --no-fehbg --bg-scale %s\n" "$file" >> "$HOME/bin/bg"
+chmod 755 "$HOME/bin/bg"
+
+sh "$HOME/bin/bg"
+exit 0