From 06696ca201682f63ea50da3ab41d992ed6b61816 Mon Sep 17 00:00:00 2001 From: ene Date: Sat, 25 Feb 2023 07:54:37 +0100 Subject: Feat(packages): Add my scripts --- .../packages/scripts/deprecated/clear_systemd | 27 ++++++++++ home-manager/packages/scripts/deprecated/comp | 32 ++++++++++++ home-manager/packages/scripts/deprecated/csd | 11 ++++ home-manager/packages/scripts/deprecated/dua | 6 +++ home-manager/packages/scripts/deprecated/dua-up | 3 ++ .../packages/scripts/deprecated/enhanched_neofetch | 3 ++ home-manager/packages/scripts/deprecated/git-init | 11 ++++ .../packages/scripts/deprecated/java_compiler/clpa | 15 ++++++ .../packages/scripts/deprecated/java_compiler/fmt | 16 ++++++ .../packages/scripts/deprecated/java_compiler/jc | 34 +++++++++++++ .../packages/scripts/deprecated/java_compiler/jj | 58 ++++++++++++++++++++++ .../packages/scripts/deprecated/java_compiler/lib | 41 +++++++++++++++ .../packages/scripts/deprecated/java_compiler/new | 37 ++++++++++++++ .../deprecated/java_compiler/no-pack/jc-no-pack | 22 ++++++++ .../deprecated/java_compiler/no-pack/jj-no-pack | 57 +++++++++++++++++++++ .../packages/scripts/deprecated/remove_start | 29 +++++++++++ .../scripts/deprecated/shell_script_os_setup/lo | 11 ++++ 17 files changed, 413 insertions(+) create mode 100755 home-manager/packages/scripts/deprecated/clear_systemd create mode 100755 home-manager/packages/scripts/deprecated/comp create mode 100755 home-manager/packages/scripts/deprecated/csd create mode 100755 home-manager/packages/scripts/deprecated/dua create mode 100755 home-manager/packages/scripts/deprecated/dua-up create mode 100755 home-manager/packages/scripts/deprecated/enhanched_neofetch create mode 100755 home-manager/packages/scripts/deprecated/git-init create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/clpa create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/fmt create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/jc create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/jj create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/lib create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/new create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack create mode 100755 home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack create mode 100755 home-manager/packages/scripts/deprecated/remove_start create mode 100755 home-manager/packages/scripts/deprecated/shell_script_os_setup/lo (limited to 'home-manager/packages/scripts/deprecated') diff --git a/home-manager/packages/scripts/deprecated/clear_systemd b/home-manager/packages/scripts/deprecated/clear_systemd new file mode 100755 index 00000000..56cfe95e --- /dev/null +++ b/home-manager/packages/scripts/deprecated/clear_systemd @@ -0,0 +1,27 @@ +#! /bin/bash + +tmp=$(mktemp) +tmp2=$(mktemp) +tmp3=$(mktemp) + +cat /mnt/pack > $tmp +cat /mnt/pack2 > $tmp2 + +if [ $(cat $tmp2 | wc -l) -gt $(cat $tmp | wc -l) ];then + cat $tmp2 > $tmp3 + cat $tmp > $tmp2 + cat $tmp3 > $tmp +fi + +for ((i=1; i<=$(cat $tmp | wc -l) ; i++)) +do + if grep -Fxq "$(awk -v n=$i 'NR==n' $tmp)" $tmp2; then + : + else + echo "$(awk -v n=$i 'NR==n' $tmp)" + fi +done + +rm $tmp +rm $tmp2 +rm $tmp3 diff --git a/home-manager/packages/scripts/deprecated/comp b/home-manager/packages/scripts/deprecated/comp new file mode 100755 index 00000000..e29cae5c --- /dev/null +++ b/home-manager/packages/scripts/deprecated/comp @@ -0,0 +1,32 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +file=$HOME/hi +tmp=$(mktemp) + +file2=$HOME/hi2 +tmp2=$(mktemp) +cat $file | awk -F "," '{ + for (i = 1; i <= 100; i++) { + if ($i == 0) { + } else { + print $i + } + } +}' | clean > $tmp + +cat $file2 | awk -F "," '{ + for (i = 1; i <= 100; i++) { + if ($i == 0) { + } else { + print $i + } + } +}' | clean > $tmp2 + +diff -y $tmp $tmp2 + +rm $tmp +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/deprecated/csd b/home-manager/packages/scripts/deprecated/csd new file mode 100755 index 00000000..33105314 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/csd @@ -0,0 +1,11 @@ +#! /bin/zsh +function cd () { + if (( ${#argv} == 1 )) && [[ -f ${1} ]]; then + [[ ! -e ${1:h} ]] && return 1 + print "Correcting ${1} to ${1:h}" + builtin cd ${1:h} + else + builtin cd "$@" + fi +} + diff --git a/home-manager/packages/scripts/deprecated/dua b/home-manager/packages/scripts/deprecated/dua new file mode 100755 index 00000000..628fa6f2 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/dua @@ -0,0 +1,6 @@ +#! /bin/bash + +tmp=$(mktemp) +cat $DUA_DATABASE > $tmp + +cat $tmp | awk '{print $1}' | sort diff --git a/home-manager/packages/scripts/deprecated/dua-up b/home-manager/packages/scripts/deprecated/dua-up new file mode 100755 index 00000000..2201f351 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/dua-up @@ -0,0 +1,3 @@ +#! /bin/bash +sudo btrfs filesystem du --raw / > $DUA_DATABASE +echo "done" diff --git a/home-manager/packages/scripts/deprecated/enhanched_neofetch b/home-manager/packages/scripts/deprecated/enhanched_neofetch new file mode 100755 index 00000000..2026341f --- /dev/null +++ b/home-manager/packages/scripts/deprecated/enhanched_neofetch @@ -0,0 +1,3 @@ +#! /bin/bash + +export ENHANCHED_NEOFETCH='$(pacman -Qn | wc -l) (pacman), $(pacman -Qm | wc -l) (aur), $(($(cargo install --list | wc -l ) / 2)) (cargo)' diff --git a/home-manager/packages/scripts/deprecated/git-init b/home-manager/packages/scripts/deprecated/git-init new file mode 100755 index 00000000..fd1f5399 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/git-init @@ -0,0 +1,11 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +cp -R $HOME/.local/share/git-template/* "$(pwd)" +[ -d ./.git ] || git init + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/deprecated/java_compiler/clpa b/home-manager/packages/scripts/deprecated/java_compiler/clpa new file mode 100755 index 00000000..c33ed025 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/clpa @@ -0,0 +1,15 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +pw=$(pwd) +[ "$n" = "n" ] || cd .. +noColor=yes . ./lib + +unset CLASSPATH + +while IFS= read -r i;do + export CLASSPATH=$CLASSPATH$i: +done < "$(tmp cat "$(tmp "find $(pwd)/libs | sed 1d") $(tmp "find $(pwd)/scr | sed 1d")")" +cd $pw + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/deprecated/java_compiler/fmt b/home-manager/packages/scripts/deprecated/java_compiler/fmt new file mode 100755 index 00000000..4dce0c02 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/fmt @@ -0,0 +1,16 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +cd ..; +pw=$(pwd); +cd ..; + +while IFS= read -r i;do + java -jar google-java-format-1.15.0-all-deps.jar -i $i +done < "$(tmp "find $pw/scr | sed 1d")" + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/deprecated/java_compiler/jc b/home-manager/packages/scripts/deprecated/java_compiler/jc new file mode 100755 index 00000000..8f95108c --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/jc @@ -0,0 +1,34 @@ +#!/bin/sh +# shellcheck disable=SC2086 + +cd .. +noColor=yes . ./lib + +export CLASSPATH= +scr=$(mktemp) + +while IFS= read -r a;do + export CLASSPATH=$CLASSPATH$a: +done < "$(tmp "find libs/ | sed 1d")" + +while IFS= read -r a;do + echo "$a" >> $scr +done < "$(tmp "find scr/ | sed 1d")" + +n=n . ./clpa + +#while IFS= read -r a;do +# rm "$a" +#done < "$(tmp "find target/ | sed 1d")" + +javac -d target/ $(cat $scr | tr '\n' ' ') +if [ "$1" = "r" ];then + cd target || die "bug" + java Main + cd .. +else + ./jj target/ libs/ +fi + +rm $scr +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/deprecated/java_compiler/jj b/home-manager/packages/scripts/deprecated/java_compiler/jj new file mode 100755 index 00000000..6d6a5aed --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/jj @@ -0,0 +1,58 @@ +#!/bin/sh +# shellcheck disable=SC2086 +noColor=yes . ./lib + +help() { +cat << EOF +Add all dirs with trailing / + +\$1 = java .class files dir +\$2 = java .jar files dir + +if you want to update libs delete this: +$wd/libs.cache + +EOF +exit 0 +} + + +class=$(mktemp) +jar=$(mktemp) +pwd=$(pwd) + +mkdir "$pwd"/out/cache 2> /dev/null +wd="$pwd"/out/cache +[ "$1" = "-h" ] && help +[ "$1" = "--help" ] && help + +[ -z "$1" ] && error "no args" && help && exit 1 +[ -z "$2" ] && error "no args" && help && exit 1 + +while IFS= read -r i;do + cp "$i" $wd/"$(basename $i)" +done < "$(tmp "find $1 | sed 1d" )" + +while IFS= read -r i;do + if ! grep "^$i$" "$wd"/libs.cache;then + echo "$i" | sed "s|$2||" >> "$wd"/libs.cache + cd $wd + jar -xf "$pwd"/"$i" + cd $pwd + fi +done < "$(tmp "find $2 | sed 1d" )" + +while IFS= read -r a;do + echo "$a" | sed "s|$wd/||" >> $jar +done < "$(tmp "find $wd | sed 1d")" + + + +cd "$wd" || die "No $wd" +jar -c -f myJar.jar -e Main $(cat $jar | tr '\n' ' ') + +mv myJar.jar "$pwd"/out/myJar.jar + +rm $jar +rm $class +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/deprecated/java_compiler/lib b/home-manager/packages/scripts/deprecated/java_compiler/lib new file mode 100755 index 00000000..8446d1ce --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/lib @@ -0,0 +1,41 @@ +#!/bin/sh +# shellcheck disable=SC2059,SC2066 + + + +out() { printf "$1 $2\n" "$(out2 "$@")"; } +out2() { shift 2; for i in "$*";do printf "$i";done; } + + +if [ "$noColor" = "yes" ];then +error() { >&2 out "==> ERROR:" "$*"; } >&2 +warning() { >&2 out "==> WARNING:" "$*"; } >&2 +msg() { out "==>" "$*"; } +msg2() { out " ->" "$*"; } + +readp() { printf "..> $1"; read -r "$2"; } + +else +error() { >&2 out "\033[1;91m==> ERROR:\033[0m" "\033[1;93m$*\033[0m"; } >&2 +warning() { >&2 out "\033[1;91m==> WARNING:\033[0m" "\033[1;93m$*\033[0m"; } >&2 +msg() { out "\033[1;96m==>\033[0m" "\033[1;93m$*\033[0m"; } +msg2() { out "\033[1;96m ->\033[0m" "\033[1;93m$*\033[0m"; } + +readp() { printf "\033[1;96m..>\033[0m \033[1;93m$1\033[0m"; read -r "$2"; } +fi + + + + + +dien() { error "$@" "failed"; exit 1; } +die() { error "$@"; exit 1; } + +clean() { awk '{if (NF) {if (!/^#/) {if (!/^[[:blank:]]*#/) {print $0}}}}' "$1"; } +# shellcheck disable=SC2294 +tmp() { + [ -d /tmp/LIB_FILE_TEMP_DIR/ ] || mkdir /tmp/LIB_FILE_TEMP_DIR/ + tmp=$(mktemp -p /tmp/LIB_FILE_TEMP_DIR/); + eval "$@" 1> "$tmp"; + echo "$tmp"; +} diff --git a/home-manager/packages/scripts/deprecated/java_compiler/new b/home-manager/packages/scripts/deprecated/java_compiler/new new file mode 100755 index 00000000..577558b0 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/new @@ -0,0 +1,37 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ./lib + + +[ -z "$1" ] && die "Requires name" +mkdir "$1" +pw="$1" + +ln -sr jc ./$pw/jc +ln -sr jj ./$pw/jj +ln -sr clpa ./$pw/clpa +ln -sr lib ./$pw/lib +ln -sr fmt ./$pw/fmt + +cd $pw +mkdir libs +mkdir -p out/cache +mkdir scr +mkdir target + +cat > scr/Main.java << EOL +public class Main { + public static void main(String[] args) { + System.out.println("Hello, world!"); + } +} +EOL +cat > .gitignore << EOL +/target +.gitignore +/out +EOL +git init > /dev/null +[ -d /tmp/LIB_FILE_TEMP_DIR/ ] && rm -r /tmp/LIB_FILE_TEMP_DIR/ +exit 0 diff --git a/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack new file mode 100755 index 00000000..bc9db9de --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jc-no-pack @@ -0,0 +1,22 @@ +#!/bin/sh +# shellcheck disable=SC2086 + +. ./lib +cd .. + +export CLASSPATH= +scr=$(mktemp) + +while IFS= read -r a;do + export CLASSPATH=$CLASSPATH$a: +done < "$(tmp "find libs/ | sed 1d")" + +while IFS= read -r a;do + echo "$a" >> $scr +done < "$(tmp "find scr/ | sed 1d")" + +javac -d target/ $(cat $scr | tr '\n' ' ') +../jj target/ libs/ +[ "$1" = "r" ] && java -jar out/myJar.jar + +rm $scr diff --git a/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack new file mode 100755 index 00000000..90a9e74e --- /dev/null +++ b/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack @@ -0,0 +1,57 @@ +#!/bin/sh +# shellcheck disable=SC2086 +. ./lib + +help() { +cat << EOF +Add all dirs with trailing / + +\$1 = java .class files dir +\$2 = java .jar files dir + +if you want to update libs delete this: +"$wd"/libs.cache + +EOF +exit 0 +} + + +class=$(mktemp) +jar=$(mktemp) +pwd=$(pwd) + +mkdir "$pwd"/out/cache 2> /dev/null +wd="$pwd"/out/cache +[ "$1" = "-h" ] && help +[ "$1" = "--help" ] && help + +[ -z "$1" ] && echo "no args" && help && exit 1 +[ -z "$2" ] && echo "no args" && help && exit 1 + +while IFS= read -r i;do + cp "$i" $wd/"$(basename $i)" +done < "$(tmp "find $1 | sed 1d" )" + +while IFS= read -r i;do + if ! grep "^$i$" "$wd"/libs.cache;then + echo "$i" | sed "s|$2||" >> "$wd"/libs.cache + cd $wd + jar -xf "$pwd"/"$i" + cd $pwd + fi +done < "$(tmp "find $2 | sed 1d" )" + +while IFS= read -r a;do + echo "$a" | sed "s|$wd/||" >> $jar +done < "$(tmp "find $wd | sed 1d")" + + + +cd "$wd" || die "No $wd" +jar -c -f myJar.jar -e Main $(cat $jar | tr '\n' ' ') + +mv myJar.jar "$pwd"/out/myJar.jar + +rm $jar +rm $class diff --git a/home-manager/packages/scripts/deprecated/remove_start b/home-manager/packages/scripts/deprecated/remove_start new file mode 100755 index 00000000..b745a4d1 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/remove_start @@ -0,0 +1,29 @@ +#! /bin/bash + +cd "$i" || exit 1 +rm -r /tmp/scr +mkdir /tmp/scr/ +star='#!/bin/sh\n\n# shellcheck source=/dev/null\n. /root/.local/lib/shell/lib' + +for i in "$1"/*;do + awk ' + !/out2\(/ && + !/readp\(/ && + !/# shellcheck/ && + !/^#!\/bin\/sh/ && + !/^#! \/bin\/sh/ && + !/^#! \/bin\/bash/ && + !/^#!\/bin\/bash/ && + !/^out\(/ && + !/^error\(/ && + !/^warning\(/ && + !/^msg\(/ && + !/msg2\(/ && + !/^die\(/ && + !/^dien\(/ + ' "$i" > /tmp/scr/"$(basename "$i")" + sed -i "1 s|.*|$star\n&|" /tmp/scr/"$(basename "$i")" + +done + + diff --git a/home-manager/packages/scripts/deprecated/shell_script_os_setup/lo b/home-manager/packages/scripts/deprecated/shell_script_os_setup/lo new file mode 100755 index 00000000..eb204b94 --- /dev/null +++ b/home-manager/packages/scripts/deprecated/shell_script_os_setup/lo @@ -0,0 +1,11 @@ +#!/bin/sh + +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +stty -ctlecho +sudo loadkeys $HOME/keymap.map + +sh -c "$*" +sudo loadkeys "$(awk 'BEGIN {FS="="} {if (NR==1) {print $2;}}' /etc/vconsole.conf)" -- cgit 1.4.1