From 899c6a9227cea23cc226148bc0b6afaa2780d81d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jul 2023 17:54:33 +0200 Subject: remove temp file --- bin/common/wt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'bin/common') diff --git a/bin/common/wt b/bin/common/wt index 0568b99..d19539b 100755 --- a/bin/common/wt +++ b/bin/common/wt @@ -1,10 +1,7 @@ #!/bin/sh - -echo "$@" > /tmp/truewhile.tmp while true do - sh /tmp/truewhile.tmp - sleep 1 clear + $@ + sleep 1 done -rm /tmp/truewhile.tmp -- cgit v1.2.3 From d5158bec4773adc8b08b85fd9dfbc517ab2450c9 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jul 2023 17:54:49 +0200 Subject: added amount --- bin/common/amount | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 bin/common/amount (limited to 'bin/common') diff --git a/bin/common/amount b/bin/common/amount new file mode 100755 index 0000000..8d235e4 --- /dev/null +++ b/bin/common/amount @@ -0,0 +1,36 @@ +#!/bin/sh + +tmp="$(mktemp)" + +die () +{ + echo "$1" >&2 +} + +clear +lsblk -o name,size,type,mountpoints +die "───────────────────────────────────" +lsblk --ascii -o name,mountpoint | + grep '^.-' | + while read line +do + words="$(printf "$line" | wc -w)" + test $words -gt 1 && continue + i=$((${i:-0}+1)) + printf "%s. %s\n" "$i" "$(printf "$line" | cut -f 2- -d '-')" +done | tee "$tmp" + +read -p '>' choice + +dev="$(grep "^$choice\." "$tmp" | cut -f 2- -d ' ')" +if test -n "$dev" +then + die "mounting /dev/$dev on /media/$dev" + sudo mount --mkdir /dev/$dev /media/$dev > /dev/null 2>&1 && + die 'Mounted succesfully.' || + die 'Failed to mount.' + die 'Press [Enter] to continue.' + head -n 1 > /dev/null +fi + +rm -f "$tmp" -- cgit v1.2.3 From c4bc0df99da917564bb6e402ee643f19a497bfdc Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jul 2023 17:55:00 +0200 Subject: simplified y2feed --- bin/common/y2feed | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'bin/common') diff --git a/bin/common/y2feed b/bin/common/y2feed index 196ecb7..e30bccf 100755 --- a/bin/common/y2feed +++ b/bin/common/y2feed @@ -1,12 +1,5 @@ #!/bin/sh -ua="$(yt-dlp --dump-user-agent)" - -test -z "${url:=$1}" && - url="$(cat /dev/stdin)" - -url="http://youtube.com/$(echo "$url" | - awk -F '/' '{print $NF}')" -echo "url: $url" >&2 - -curl -L -s -H "$ua" "$url" | - pup 'link[title=RSS] attr{href}' +echo "url: $1" >&2 +curl -L -s "$1" | + pup 'link[title=RSS] attr{href}' | + tee /dev/stderr -- cgit v1.2.3 From ac369f0c9d0e4362dc229eccbc2d4692538f5553 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jul 2023 18:21:29 +0200 Subject: minor fixes --- bin/common/amount | 2 +- stowdots | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'bin/common') diff --git a/bin/common/amount b/bin/common/amount index 8d235e4..71fc6ae 100755 --- a/bin/common/amount +++ b/bin/common/amount @@ -8,7 +8,7 @@ die () } clear -lsblk -o name,size,type,mountpoints +lsblk -o name,size,type,mountpoint die "───────────────────────────────────" lsblk --ascii -o name,mountpoint | grep '^.-' | diff --git a/stowdots b/stowdots index 1c72f80..dc056f4 100755 --- a/stowdots +++ b/stowdots @@ -1,6 +1,6 @@ #!/bin/sh -trap "echo -e '\nbye'; exit 1" EXIT +trap "exit 1" EXIT INT die () { echo "$@" 1>&2 @@ -22,7 +22,7 @@ else die "E: MACH not set" >&2 die "Enter valid value for 'MACH'" die "d(esktop) | s(erver) | l(aptop)" - echo -n ">" >&2 + die -n ">" read MACH fi -- cgit v1.2.3 From ca93eb95d535e30207aba84982475fbd9749d933 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jul 2023 18:32:54 +0200 Subject: don't use sudo if root --- bin/common/amount | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin/common') diff --git a/bin/common/amount b/bin/common/amount index 71fc6ae..9053b62 100755 --- a/bin/common/amount +++ b/bin/common/amount @@ -26,7 +26,9 @@ dev="$(grep "^$choice\." "$tmp" | cut -f 2- -d ' ')" if test -n "$dev" then die "mounting /dev/$dev on /media/$dev" - sudo mount --mkdir /dev/$dev /media/$dev > /dev/null 2>&1 && + test "$(id -u)" != "0" && sudo="sudo" + mkdir -p /media/$dev + $sudo mount /dev/$dev /media/$dev > /dev/null 2>&1 && die 'Mounted succesfully.' || die 'Failed to mount.' die 'Press [Enter] to continue.' -- cgit v1.2.3 From a4011543565cb769d82b5ef3ac9bda7a5298f14c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 19 Jul 2023 11:35:58 +0200 Subject: replaced amount with aumount --- bin/common/amount | 38 ----------------------- bin/common/aumount | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 38 deletions(-) delete mode 100755 bin/common/amount create mode 100755 bin/common/aumount (limited to 'bin/common') diff --git a/bin/common/amount b/bin/common/amount deleted file mode 100755 index 9053b62..0000000 --- a/bin/common/amount +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -tmp="$(mktemp)" - -die () -{ - echo "$1" >&2 -} - -clear -lsblk -o name,size,type,mountpoint -die "───────────────────────────────────" -lsblk --ascii -o name,mountpoint | - grep '^.-' | - while read line -do - words="$(printf "$line" | wc -w)" - test $words -gt 1 && continue - i=$((${i:-0}+1)) - printf "%s. %s\n" "$i" "$(printf "$line" | cut -f 2- -d '-')" -done | tee "$tmp" - -read -p '>' choice - -dev="$(grep "^$choice\." "$tmp" | cut -f 2- -d ' ')" -if test -n "$dev" -then - die "mounting /dev/$dev on /media/$dev" - test "$(id -u)" != "0" && sudo="sudo" - mkdir -p /media/$dev - $sudo mount /dev/$dev /media/$dev > /dev/null 2>&1 && - die 'Mounted succesfully.' || - die 'Failed to mount.' - die 'Press [Enter] to continue.' - head -n 1 > /dev/null -fi - -rm -f "$tmp" diff --git a/bin/common/aumount b/bin/common/aumount new file mode 100755 index 0000000..790106d --- /dev/null +++ b/bin/common/aumount @@ -0,0 +1,90 @@ +#!/bin/sh + +tmp="$(mktemp)" +test "$(id -u)" != "0" && sudo="sudo" + +die () +{ + echo "$@" >&2 +} + +# Read one character +read_char () +{ + die -n ">" + old_stty_cfg=$(stty -g) + stty raw + dd ibs=1 count=${1:-1} 2> /dev/null + stty $old_stty_cfg + die "" +} + +# mount the device with $1 as the choice +mount () +{ + dev="$(grep "^$1\." "$tmp" | cut -f 2- -d ' ')" + test -z "$dev" && exit + + die "mounting /dev/$dev on /media/$dev" + mkdir -p /media/$dev + $sudo mount /dev/$dev /media/$dev > /dev/null 2>&1 || + return 1 +} + +# eject the device with $1 as the choice +eject () +{ + printf "$1" | grep -q "[0-9]" || exit 1 + mountpoint="$(sed -n "${1}p" "$tmp" | + awk '{print $3}')" + test -z "$mountpoint" && exit 1 + + # Get device for mountpoint with df + dev="$(df -P "$mountpoint" | + tail -n +2 | head -n 1 | # skip headers + awk '{print $1}')" + + die "ejecting $dev" + $sudo eject "$dev" && + die "Succesfully ejected." || + die "Failed to eject." +} + +# print lsblk, use $1 to print only devices with mountpoints or without +pr_lsblk () +{ + clear + lsblk -o name,size,type,mountpoint + die "───────────────────────────────────" + lsblk --ascii -o name,mountpoint | + grep '^.-' | + while read line + do + words="$(printf "$line" | wc -w)" + test $words -eq ${1:-1} && continue + printf "%s\n" "$line" + done | + cut -f 2- -d "-" | + awk '{print NR ". " $0}' | + tee "$tmp" >&2 +} + +cleanup () +{ + rm -f "$tmp" +} + +trap cleanup EXIT INT + +die "m(ount) e(ject) ?" +choice="$(read_char)" + +case $choice in + "m") i=2; cmd=mount ;; + "e") i=1; cmd=eject ;; + *) exit 1 ;; +esac + +pr_lsblk $i +choice="$(read_char)" +$cmd $choice -- cgit v1.2.3 From 4b20907a634a47e578d97df24cd7b632c1c06786 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 19 Jul 2023 11:41:43 +0200 Subject: umount instead of eject --- bin/common/aumount | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'bin/common') diff --git a/bin/common/aumount b/bin/common/aumount index 790106d..f7f1ecb 100755 --- a/bin/common/aumount +++ b/bin/common/aumount @@ -25,29 +25,23 @@ mount () dev="$(grep "^$1\." "$tmp" | cut -f 2- -d ' ')" test -z "$dev" && exit - die "mounting /dev/$dev on /media/$dev" + die "Mounting /dev/$dev on /media/$dev" mkdir -p /media/$dev $sudo mount /dev/$dev /media/$dev > /dev/null 2>&1 || return 1 } -# eject the device with $1 as the choice -eject () +# umount the device with $1 as the choice +umount () { printf "$1" | grep -q "[0-9]" || exit 1 mountpoint="$(sed -n "${1}p" "$tmp" | awk '{print $3}')" test -z "$mountpoint" && exit 1 - # Get device for mountpoint with df - dev="$(df -P "$mountpoint" | - tail -n +2 | head -n 1 | # skip headers - awk '{print $1}')" - - die "ejecting $dev" - $sudo eject "$dev" && - die "Succesfully ejected." || - die "Failed to eject." + die "Unmounting $mountpoint" + $sudo umount "$mountpoint" || + return 1 } # print lsblk, use $1 to print only devices with mountpoints or without @@ -76,15 +70,17 @@ cleanup () trap cleanup EXIT INT -die "m(ount) e(ject) ?" +die "m(ount) u(mount) ?" choice="$(read_char)" case $choice in "m") i=2; cmd=mount ;; - "e") i=1; cmd=eject ;; + "u") i=1; cmd=umount ;; *) exit 1 ;; esac pr_lsblk $i choice="$(read_char)" -$cmd $choice +$cmd $choice && + die "Successful." || + die "Failed." -- cgit v1.2.3 From 7533d26a043df25183a78eba5cce5ca5c3d0cbe6 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 19 Jul 2023 14:46:46 +0200 Subject: added eject option to aumount --- bin/common/aumount | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'bin/common') diff --git a/bin/common/aumount b/bin/common/aumount index f7f1ecb..19b33e0 100755 --- a/bin/common/aumount +++ b/bin/common/aumount @@ -19,11 +19,16 @@ read_char () die "" } +get_dev () +{ + grep "^$1\." "$tmp" | cut -f 2- -d ' ' +} + # mount the device with $1 as the choice mount () { - dev="$(grep "^$1\." "$tmp" | cut -f 2- -d ' ')" - test -z "$dev" && exit + dev="$(get_dev "$1")" + test -z "$dev" && exit 1 die "Mounting /dev/$dev on /media/$dev" mkdir -p /media/$dev @@ -34,7 +39,6 @@ mount () # umount the device with $1 as the choice umount () { - printf "$1" | grep -q "[0-9]" || exit 1 mountpoint="$(sed -n "${1}p" "$tmp" | awk '{print $3}')" test -z "$mountpoint" && exit 1 @@ -44,6 +48,16 @@ umount () return 1 } +ejekt () +{ + dev="$(get_dev "$1" | sed 's/.$//')" + test -z "$dev" && exit 1 + + die "Ejecting /dev/$dev" + $sudo eject /dev/$dev > /dev/null 2>&1 || + return 1 +} + # print lsblk, use $1 to print only devices with mountpoints or without pr_lsblk () { @@ -70,17 +84,19 @@ cleanup () trap cleanup EXIT INT -die "m(ount) u(mount) ?" +die "m(ount) u(mount) (e)ject ?" choice="$(read_char)" case $choice in "m") i=2; cmd=mount ;; "u") i=1; cmd=umount ;; + "e") i=2; cmd=ejekt ;; *) exit 1 ;; esac pr_lsblk $i choice="$(read_char)" +printf "$choice" | grep -q "[0-9]" || exit 1 $cmd $choice && die "Successful." || die "Failed." -- cgit v1.2.3 From 0cbd27042a2ab45f3691bb86e0c5b030768a4619 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 24 Jul 2023 13:10:59 +0200 Subject: don't use tee if root --- bin/common/drop_cache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/common') diff --git a/bin/common/drop_cache b/bin/common/drop_cache index 4833597..e4fc039 100755 --- a/bin/common/drop_cache +++ b/bin/common/drop_cache @@ -4,5 +4,5 @@ then echo "Please run as root." exit 1 fi -echo 3 | tee /proc/sys/vm/drop_caches >/dev/null +echo 3 > /proc/sys/vm/drop_caches echo "cache cleared." -- cgit v1.2.3 From 1460eae0d754818dffdaadb744571cbfce1a8378 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 29 Jul 2023 11:46:22 +0200 Subject: use script instead of alias --- bin/common/cx | 2 ++ config/essentials/zsh/aliases.sh | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100755 bin/common/cx (limited to 'bin/common') diff --git a/bin/common/cx b/bin/common/cx new file mode 100755 index 0000000..88fb817 --- /dev/null +++ b/bin/common/cx @@ -0,0 +1,2 @@ +#!/bin/sh +[ -x "$1" ] && chmod -x "$1" || chmod +x "$1" diff --git a/config/essentials/zsh/aliases.sh b/config/essentials/zsh/aliases.sh index 1d742a9..53c8da0 100644 --- a/config/essentials/zsh/aliases.sh +++ b/config/essentials/zsh/aliases.sh @@ -167,7 +167,6 @@ alias penv='python3 -m venv env' alias phttp='python3 -m http.server' alias pipreq='pip install -r requirements.txt' -alias cx='chmod +x' alias ch='chown ${USER}:${USER} -R' alias kll='killall' alias pi='ping archlinux.org -c4' -- cgit v1.2.3 From 55378ac493716f15fd68d73fb77fcade4a667d99 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 29 Jul 2023 11:48:39 +0200 Subject: added saf --- bin/common/saf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 bin/common/saf (limited to 'bin/common') diff --git a/bin/common/saf b/bin/common/saf new file mode 100755 index 0000000..0c6fbc4 --- /dev/null +++ b/bin/common/saf @@ -0,0 +1,24 @@ +#!/bin/sh + +# Simple Ass Fetch by futxlii + +red="$(printf '\033[31m')" +green="$(printf '\033[32m')" +blue="$(printf '\033[34m')" +reset="$(printf '\033[0m')" + +for file in /etc/os-release /usr/lib/os-release +do + [ -f "$file" ] && . "$file" && break +done + +KERNEL="$(uname -r)" +UPTIME="$(uptime -p)"; UPTIME="${UPTIME##up }" +SHELL="$(basename "$SHELL")" + +cat < Date: Sat, 29 Jul 2023 11:48:57 +0200 Subject: added toush --- bin/common/toush | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 bin/common/toush (limited to 'bin/common') diff --git a/bin/common/toush b/bin/common/toush new file mode 100755 index 0000000..dd675b9 --- /dev/null +++ b/bin/common/toush @@ -0,0 +1,14 @@ +#!/bin/sh +# fork of +# https://codeberg.org/futxlii/bin/toush :) + +shebang='#!/bin/sh' + +usage() { >&2 printf 'Usage: %s' "${0##*/}"; exit 1 ;} + +[ "$1" ] || usage +while [ "$1" ]; do + [ -f "$1" ] && usage + printf '%s\n\n' "$shebang" > "$1" && chmod +x "$1" + shift +done -- cgit v1.2.3 From eeb2fac3028837fae0db3d816acf6d8bd0050120 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sat, 29 Jul 2023 11:49:08 +0200 Subject: added sync-install.sh --- bin/common/sync-install.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 bin/common/sync-install.sh (limited to 'bin/common') diff --git a/bin/common/sync-install.sh b/bin/common/sync-install.sh new file mode 100755 index 0000000..e26c74d --- /dev/null +++ b/bin/common/sync-install.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +die () +{ + echo "$@" >&2 +} + +read_char () +{ + old_stty_cfg=$(stty -g) + stty raw -echo + dd ibs=1 count=1 2> /dev/null + stty $old_stty_cfg +} + +confirm () +{ + printf "$1 " + read_char | grep "[yY]" +} + +usage() +{ + >&2 printf 'Usage: %s \n' "${0##*/}" +} + +[ $# -lt 2 ] && usage && exit 1 +REMOTE="$1" +DEST="$2" +SCRIPT="${3:-sync.sh}" + +if ! ssh $REMOTE test -w $DEST 2> /dev/null +then + die "Not a valid remote or destination." + exit 1 +fi + +die "─────────────────────────────────────────────────────────────" +cat <&2 +#!/bin/sh + +THISDIR="\$(dirname "\$(readlink -f "\$0")")" +inotifywait -m -e create,modify,delete --format "%f" "\$THISDIR" | +while read FILE +do + rsync -aP "\$THISDIR/" "$REMOTE:$DEST" + sleep 1m +done +EOF +die "─────────────────────────────────────────────────────────────" +die "located at $(readlink -f "$SCRIPT")" + +if confirm "good?" +then + chmod +x "$SCRIPT" +else + rm -f "$SCRIPT" +fi -- cgit v1.2.3