summary refs log tree commit diff
path: root/.local/bin
diff options
context:
space:
mode:
authorZach DeCook <zach.decook@bettercarpeople.com>2022-10-17 11:57:51 -0400
committerZach DeCook <zach.decook@bettercarpeople.com>2022-10-17 11:57:51 -0400
commitbef368a6363dadb025515a6a6d989d6cb7a3574f (patch)
treef6d0e5b0bf373690ee8e3355406bac74cbbfbf1b /.local/bin
downloaddotfiles-bef368a6363dadb025515a6a6d989d6cb7a3574f.tar.gz
work: initial commit
Diffstat (limited to '.local/bin')
-rwxr-xr-x.local/bin/csv2INSERT.sh6
-rwxr-xr-x.local/bin/csv2sql.sh13
-rwxr-xr-x.local/bin/emojis.sh80
l---------.local/bin/sxmo_dmenu.sh1
-rwxr-xr-x.local/bin/uniq:16
-rwxr-xr-x.local/bin/wl-copy2
6 files changed, 118 insertions, 0 deletions
diff --git a/.local/bin/csv2INSERT.sh b/.local/bin/csv2INSERT.sh
new file mode 100755
index 0000000..1e20a67
--- /dev/null
+++ b/.local/bin/csv2INSERT.sh
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+read line
+echo "INSERT INTO $1 ($line) VALUES"
+csv2sql.sh | head -c -2
+echo ";"
diff --git a/.local/bin/csv2sql.sh b/.local/bin/csv2sql.sh
new file mode 100755
index 0000000..7f4a8d5
--- /dev/null
+++ b/.local/bin/csv2sql.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Quote everything,
+tr , "\t" |
+sed 's/\t\([^"\t]\+\)/\t"\1"/g' |
+sed 's/\([^"\t]\+\)\t/"\1"\t/g' |
+# replace empty with null,
+sed 's/\t\t/\tnull\t/g' |
+sed 's/\t\t/\tnull\t/g' |
+sed 's/\t$/\tnull/g' |
+sed 's/^\t/null\t/g' |
+tr "\t" , |
+# and add parens around each line
+sed 's/^/(/g' | sed 's/$/),/g'
diff --git a/.local/bin/emojis.sh b/.local/bin/emojis.sh
new file mode 100755
index 0000000..9ba19ad
--- /dev/null
+++ b/.local/bin/emojis.sh
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+# http://www.unicode.org/Public/emoji/14.0/emoji-test.txt
+# alpine package unicode-character-database installs this here:
+# title="😀 Emoji Input"
+input=/usr/share/unicode/emoji/emoji-test.txt
+
+prefix=$1
+
+topmenu(){
+	menu=$(grep ' group: ' "$input" | cut -d: -f2 |sed 's/^ //g'|awk 'BEGIN{print "All Emojis"}(1){print}END{print "exit"}'| $prefix sxmo_dmenu.sh -i --header Emojis)
+	case "$menu" in
+	"exit" | "")
+		exit;;
+	"All Emojis" )
+		emojis;;
+	* )
+		submenu "$menu";;
+	esac
+}
+submenu(){
+	menu="$1"
+	submenu=$(grep group: "$input" |awk "BEGIN{print \"*\n..\"}
+		/ group:/{
+			if (pr){pr=0; exit}
+		}
+		(pr){print}
+		/ group: $menu/{pr=1}
+		END{print \"exit\"}
+		" |cut -d: -f2|sed 's/^ //g'| $prefix sxmo_dmenu.sh -i --header "$menu")
+	case "$submenu" in
+	"exit" | "" )
+		exit;;
+	".." )
+		topmenu;;
+	"*" )
+		emojis "$menu";;
+	* )
+		emojis "$menu" "$submenu";;
+	esac
+}
+emojis(){
+	menu="$1"
+	submenu="$2"
+	start="group:"
+	end="# Status Counts"
+	if test "$submenu"; then
+		start="subgroup: $submenu"
+		end="group:"
+	elif test "$menu"; then
+		start=" group: $menu"
+		end=" group:"
+	fi
+	emoji=$(awk "BEGIN{print \"..\"}
+	/$end/{
+		if (pr){pr=0; exit}
+	}
+	(pr){print}
+	/$start/{pr=1}
+	END{print \"exit\"}
+	" < $input | cut -d'#' -f2 | grep . | grep -v 'subtotal:' | grep -v 'group:' | sed 's/E\d\+.\d\+ *//g' | sed 's/^ //g' | grep -v ':.*skin'| $prefix sxmo_dmenu.sh -i --header "${submenu:-${menu:-All Emojis}}"| cut -d' ' -f1)
+	case "$emoji" in
+	"exit" | "" )
+		exit;;
+	".." )
+		if test "$menu"; then
+			submenu "$menu"
+		else
+			topmenu
+		fi
+		;;
+	* )
+		wl-ime-type "$emoji" &
+		printf %s "$emoji" | wl-copy
+		emojis "$menu" "$submenu"
+		;;
+	esac
+}
+
+topmenu
diff --git a/.local/bin/sxmo_dmenu.sh b/.local/bin/sxmo_dmenu.sh
new file mode 120000
index 0000000..b97ccfa
--- /dev/null
+++ b/.local/bin/sxmo_dmenu.sh
@@ -0,0 +1 @@
+/usr/bin/fzf
\ No newline at end of file
diff --git a/.local/bin/uniq: b/.local/bin/uniq:
new file mode 100755
index 0000000..50fcfa8
--- /dev/null
+++ b/.local/bin/uniq:
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3
+
+import fileinput
+import sys
+
+
+def main():
+    old = ''
+    for line in fileinput.input():
+        linenew = line.split(':')[0]
+        if old != linenew:
+            print(line, end='')
+        old = linenew
+
+if __name__ == '__main__':
+    sys.exit(main())
diff --git a/.local/bin/wl-copy b/.local/bin/wl-copy
new file mode 100755
index 0000000..a53757b
--- /dev/null
+++ b/.local/bin/wl-copy
@@ -0,0 +1,2 @@
+#!/bin/sh
+xclip -in -selection clipboard