diff options
| author | Xiao Pan <gky44px1999@gmail.com> | 2024-01-09 15:15:54 +0000 | 
|---|---|---|
| committer | Xiao Pan <gky44px1999@gmail.com> | 2024-01-09 15:15:54 +0000 | 
| commit | a8b504f7f99f49420458a0e52bb8a4de0600b58e (patch) | |
| tree | 44830806ede1edfe998cbcdd1e88b6bb9c08a5ad | |
| parent | 3aa23f9d240e7bb29fc91e6ce81eb51665f8db0b (diff) | |
move to fsh
| -rwxr-xr-x | home/xyz/.local/bin/cfg | 29 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/chmodef | 6 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/curlqb | 27 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/dirnameall | 19 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gita | 17 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gitmetap | 17 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gitmetar | 7 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/lastarg | 5 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/loop | 15 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mmi | 27 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mpra | 35 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mvln | 27 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mvtr | 11 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mvtu | 13 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/o | 27 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/orgext | 18 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/pq | 11 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/px | 10 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/time-uuid | 6 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/vinfo | 4 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/wh | 11 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/xmq | 3 | 
22 files changed, 0 insertions, 345 deletions
| diff --git a/home/xyz/.local/bin/cfg b/home/xyz/.local/bin/cfg deleted file mode 100755 index 92a097e7..00000000 --- a/home/xyz/.local/bin/cfg +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -umask 077 -while getopts lsmM opt; do -	case $opt in -		#c)		 -		#	work_tree_dir="$HOME" -		#	meta_file="$XDG_CONFIG_HOME/myconf/cfg${opt}_meta" -		#	cmd="git --git-dir=$HOME/.cfg$opt/ --work-tree=$HOME" -		#	;; -		l|s)	 -			work_tree_dir=/ -			meta_file="/etc/myconf/cfg${opt}_meta" -			cmd="sudo -E git --git-dir=/etc/.cfg$opt/ --work-tree=/" -			;; -		m)		 -			sudo gitmetap "$cmd" "$work_tree_dir" "$meta_file" -			$cmd diff -			exit -			;; -		M)	 -			sudo gitmetar "$meta_file" -			exit -			;; -		\?)	exit 1;; -	esac -done -shift $((OPTIND-1)) -$cmd "$@" diff --git a/home/xyz/.local/bin/chmodef b/home/xyz/.local/bin/chmodef deleted file mode 100755 index 446bc230..00000000 --- a/home/xyz/.local/bin/chmodef +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# chmodef: CHMOD DEFault - -# https://wiki.archlinux.org/title/File_permissions_and_attributes#Numeric_method -find "$@" -type d -execdir chmod 755 -- '{}' \+ -find "$@" -type f -execdir chmod 644 -- '{}' \+ diff --git a/home/xyz/.local/bin/curlqb b/home/xyz/.local/bin/curlqb deleted file mode 100755 index d2851cd9..00000000 --- a/home/xyz/.local/bin/curlqb +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# need --no-clobber if don't want overwrite when same name -# if do this also need change .py.1 to .py else qbt will not accept -# also if a.py and a_1.py, qbt will not accept the latter, maybe need to change some .py codes inside -# now, I choose to let three files to be overwrited, those are "with categories" .py files that overwrite without categories .py files, which is what I want so I don't use --no-clobber -curl -s 'https://github.com/qbittorrent/search-plugins/wiki/Unofficial-search-plugins' | awk -F'"' ' -/user-content-plugins-for-private-sites/ {exit} -/\.py/ { -	url=$2 -	getline -	getline -	getline -	if($0 !~ /❗|✖/) -		print url -} -' | xargs curl -s -Z -L --remote-name-all --create-dirs --output-dir "$1" -- - -# an alternative awk command: -#awk -F'"' ' -#/require an account/ {exit} -#/\.py/ { -#	url=$2 -#	line=NR -#} -#url && NR==line+3 && !/❗|✖/ {print url} -#' diff --git a/home/xyz/.local/bin/dirnameall b/home/xyz/.local/bin/dirnameall deleted file mode 100755 index befd3478..00000000 --- a/home/xyz/.local/bin/dirnameall +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -while read -r line; do -	if [ "$paths" ]; then -		paths="$paths -$line" -	else -		paths="$line" -	fi -done - -dirs="$paths" -while [ "$dirs" != '.' ]; do -	[ "$dirs" ] && paths="$paths -$dirs" -	dirs="$(echo "$dirs" | tr '\n' '\0' | xargs -0 dirname | awk '!a[$0]++')" -done - -echo "$paths" | awk '!a[$0]++' | grep -v '^\.$' diff --git a/home/xyz/.local/bin/gita b/home/xyz/.local/bin/gita deleted file mode 100755 index ee003061..00000000 --- a/home/xyz/.local/bin/gita +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# note message string must come after options - -cmd=git - -while getopts ls f; do -	case $f in -		l|s) cmd="cfg -$f";; -		\?) exit 1;; -	esac -done -shift $((OPTIND-1)) - -mes="${1:-update}" - -$cmd commit --all -m "$mes" -$cmd push diff --git a/home/xyz/.local/bin/gitmetap b/home/xyz/.local/bin/gitmetap deleted file mode 100755 index c0589860..00000000 --- a/home/xyz/.local/bin/gitmetap +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -# GIT META Print - -# -rw-r--r-- == binary 110100100 == octal 644 -# https://stackoverflow.com/a/1796009 -$1 ls-tree -r --name-only --full-tree HEAD | dirnameall | awk -v a="$2/" '{printf("%s%s\n",a,$0)}' | tr '\n' '\0' | xargs -0 ls -ldA -- | awk '{ -	k=0 -	for(i=0;i<=8;i++) -		k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i)) -	if(k) { -		for(i=10;$i && $i!="->";i++) -			$9=$9" "$i -		printf("%0o %s %s %s\n",k,$3,$4,$9) -	} -}' > "$3" - -#$1 ls-tree -r --name-only --full-tree HEAD | awk -v a="$2/" '{printf("%s%s\n",a,$0)}' | tr '\n' '\0' | xargs -0 ls -ldA -- | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k){for(i=10;$i && $i!="->";i++)$9=$9" "$i;printf("%0o %s %s %s\n",k,$3,$4,$9)}}' > "$3" diff --git a/home/xyz/.local/bin/gitmetar b/home/xyz/.local/bin/gitmetar deleted file mode 100755 index 1bfdc150..00000000 --- a/home/xyz/.local/bin/gitmetar +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -# GIT META Read - -while read -r mod user group path; do -	chown -hc "$user:$group" -- "$path" -	[ "$mod" -ne 777 ] && chmod -c "$mod" -- "$path" -done < "$1" diff --git a/home/xyz/.local/bin/lastarg b/home/xyz/.local/bin/lastarg deleted file mode 100755 index b52afcdc..00000000 --- a/home/xyz/.local/bin/lastarg +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -# usage: lastarg "$@" - -shift $(($# - 1)) -echo "$1" diff --git a/home/xyz/.local/bin/loop b/home/xyz/.local/bin/loop deleted file mode 100755 index 6a578267..00000000 --- a/home/xyz/.local/bin/loop +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -while getopts t: opt; do -	case $opt in -		t) time="$OPTARG";; -		\?) exit 1;; -	esac -done -shift $((OPTIND-1)) - -while :; do -	# suggested by https://github.com/koalaman/shellcheck/wiki/SC2294 -	"$@" -	sleep "${time:-1}" -done diff --git a/home/xyz/.local/bin/mmi b/home/xyz/.local/bin/mmi deleted file mode 100755 index 350fe505..00000000 --- a/home/xyz/.local/bin/mmi +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -mi () { -	make -	sudo make install -} - -origin="$PWD" -cmd='mi' - -while getopts q opt; do -	case $opt in -		q) cmd='qmake6;mi';; -		\?) exit 1;; -	esac -done -shift $((OPTIND-1)) - -if [ -z "$1" ]; then -	eval "$cmd" -else -	for dir; do -		cd "$dir" || exit -		eval "$cmd" -		cd "$origin" || exit -	done -fi diff --git a/home/xyz/.local/bin/mpra b/home/xyz/.local/bin/mpra deleted file mode 100755 index 114c836b..00000000 --- a/home/xyz/.local/bin/mpra +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# MakePkg Repo-Add - -fn () { -	find . -maxdepth 1 -type f -name "*.pkg.tar.$ext*" -delete -	makepkg --sign -sf -	newpkg="$(find . -maxdepth 1 -type f -name "*.pkg.tar.$ext")" -	mv "$newpkg" "$newpkg.sig" .. -	# need manually repo-add new database for first time initialization -	repo-add -s -v -R "$(find .. -maxdepth 1 -type f -name '*.db.tar.gz')" "../$newpkg" -} - -ext='zst' - -upd -p - -while getopts a opt; do -	case $opt in -		# arch linux arm still using .xz instead of .zst as package compression format -		a) ext=xz;; -		\?) exit 1;; -	esac -done -shift $((OPTIND-1)) - -if [ $# -eq 0 ]; then -	fn  -else -	for dir; do -		cd -- "$(realpath -- "$dir")" || exit -		fn	 -	done -fi - -upd -p diff --git a/home/xyz/.local/bin/mvln b/home/xyz/.local/bin/mvln deleted file mode 100755 index 54cef541..00000000 --- a/home/xyz/.local/bin/mvln +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# edge cases give me headache - -lns () { -	# prevent `mvln file1 file1` or `mvln dir1/file1 dir1/` -	# which means `ln -s samename samename` or `ln -s dir/file dir/` -	# both $1 and $2 here are realpath -	[ "$1" != "$2" ] && ln -s -- "$1" "$2" -} - -mv -i -- "$@" -# consider `mvln file1 dir/file2` -if [ $# -eq 2 ] && ! [ -d "$2" ]; then -	# use realpath here -	lns "$(realpath "$2")" "$(realpath "$1")" 	 -else -	dir="$(realpath -- "$(lastarg "$@")")" -	# steal from https://unix.stackexchange.com/a/353833/459013 -	while [ $# -gt 1 ]; do -		to="$(realpath -- "$1")" -		# prevent `mvln dir1/ dir1/` -		if [ "$dir" != "$to" ]; then -			lns "$dir/$(basename "$1")" "$to" -		fi -		shift -	done -fi diff --git a/home/xyz/.local/bin/mvtr b/home/xyz/.local/bin/mvtr deleted file mode 100755 index 28eebf0f..00000000 --- a/home/xyz/.local/bin/mvtr +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# can use ls pipe to sed pipe to bash, similar to eval? see comment at link: -# link also show perl-rename approach -# https://linuxconfig.org/rename-all-files-from-uppercase-to-lowercase-characters -# if only change ' ' to '_' `rename` might be sufficient, for upper to lower case might need perl-rename if want concise - -# ./_filename will be renamed ./filename, not what I want, need improve -# -exec can't replace -execdir here, can write a -exec version - -find "$@" -depth -execdir sh -c 'dest="$(echo "$1" | tr -d "\047" | sed -E -e "s/([[:lower:]])([[:upper:]])/\1_\2/g" | tr "[:upper:] " "[:lower:]_" | tr -s "[:punct:]" | sed -E -e "s#/-#/#g" -e "s/_([[:punct:]])/\1/g" -e "s/([[:punct:]])_/\1/g" | tr -s "[:punct:]")"; [ -e "$dest" ] || mv -v -- "$1" "$dest"' shell '{}' \; diff --git a/home/xyz/.local/bin/mvtu b/home/xyz/.local/bin/mvtu deleted file mode 100755 index 6160507f..00000000 --- a/home/xyz/.local/bin/mvtu +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# MV Time-Uuid - -find "$@" -type f -execdir sh -c ' -	file="$(basename "$1")" -	ext="${file##*.}" -	if [ "$ext" != "$file" ]; then -		dest="$(time-uuid).$ext" -	else -		dest="$(time-uuid)" -	fi -	[ -e "dest" ] || mv -v -- "$1" "$dest" -' shell '{}' \; diff --git a/home/xyz/.local/bin/o b/home/xyz/.local/bin/o deleted file mode 100755 index 8fb066c7..00000000 --- a/home/xyz/.local/bin/o +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# useful links -# https://stackoverflow.com/questions/3430330/best-way-to-make-a-shell-script-daemon -# https://serverfault.com/questions/117152/do-background-processes-get-a-sighup-when-logging-off -# https://wiki.archlinux.org/title/default_applications - -# I don't care about errors, I don't want to handle errors, just shut up please. -# nohup seems not necessary if don't care about daemon SIGHUP requirement - -# when close a shell script's stdout or stderr with `>&-` or `2>&-`, `xsel -ib` in that script has no effect -# https://github.com/kfish/xsel/issues/43 -# using `>&-` or `2>&-` doesn't completely close mpv's output when run sth. like `o mpv file.mkv` -# base on above observations, I choose to use `>/dev/null 2>&1` instead - -# need ; before } when it is in the same line as { ? https://www.shellcheck.net/wiki/SC1056 - -if [ $# -eq 1 ] && [ -e "$1" ] && { ! [ -x "$1" ] || [ -d "$1" ];}; then -	case "$1" in -		# libreoffice, please don't let firefox eat your shit -		*.docx|*.pptx) cmd=libreoffice;; -		*) cmd=xdg-open;; -	esac -	nohup "$cmd" "$1" 0<&- >/dev/null 2>&1 & -else -	nohup "$@" 0<&- >/dev/null 2>&1 & -fi diff --git a/home/xyz/.local/bin/orgext b/home/xyz/.local/bin/orgext deleted file mode 100755 index 0143e62f..00000000 --- a/home/xyz/.local/bin/orgext +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -outdir () {  -	find . -type f -execdir mv -t "$PWD" -- '{}' \+ -	find . -mindepth 1 -maxdepth 1 -type d -execdir rmdir -- '{}' \+ -} - -indir () { -	# https://stackoverflow.com/questions/1842254/how-can-i-find-all-of-the-distinct-file-extensions-in-a-folder-hierarchy -	find . -maxdepth 1 -type f | awk -F. '!a[$NF]++{print $NF}' | xargs mkdir -- -	find . -mindepth 1 -maxdepth 1 -type d -execdir basename -az -- '{}' \+ | xargs -0 -I _ find . -maxdepth 1 -type f -name '*._' -execdir mv -t '_' -- '{}' \+ -} - -case "$1" in -	'-o') outdir;; -	'-i') indir;; -	*) outdir; indir;; -esac diff --git a/home/xyz/.local/bin/pq b/home/xyz/.local/bin/pq deleted file mode 100755 index 268e0021..00000000 --- a/home/xyz/.local/bin/pq +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Pacman Query, to manually determine remove the package or not - -[ "$1" ] && { -	#sed -n '/^Depends On/,/^Conflicts With/{/^Conflicts With/!p}; /^Description\|^URL\|^Groups\|^Installed Size\|^Install Reason/p' -	pacman -Qi "$1" | awk '/^Groups/{f=1} /^Conflicts With/{f=0} f||/^Description|^URL|^Installed Size|^Install Reason/' -	printf '\n' -	pacman -Ql "$1" | grep '/bin/[^$]' -	printf '\n' -	pactree -r "$1" -} | "$PAGER" diff --git a/home/xyz/.local/bin/px b/home/xyz/.local/bin/px deleted file mode 100755 index 1b4e849d..00000000 --- a/home/xyz/.local/bin/px +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -# Printf Xsel - -if [ $# -eq 0 ]; then -	/usr/bin/printf '%q' "$PWD" -else -	for dir; do -		/usr/bin/printf '%q ' "$(realpath -- "$dir")" -	done -fi | xsel -ib diff --git a/home/xyz/.local/bin/time-uuid b/home/xyz/.local/bin/time-uuid deleted file mode 100755 index bdaf4b3d..00000000 --- a/home/xyz/.local/bin/time-uuid +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -# echo current nanosecond since epoch and alpha-numerically ordered UUID -# https://stackoverflow.com/questions/28681650/generate-alpha-numerically-ordered-uuids-over-time?noredirect=1&lq=1 -# https://askubuntu.com/questions/342842/what-does-this-command-mean-awk-f-print-4 -echo "$(date '+%s-%N')-$(uuidgen -t | awk -F- '{OFS="-"; print $3,$2,$1,$4,$5}')" diff --git a/home/xyz/.local/bin/vinfo b/home/xyz/.local/bin/vinfo deleted file mode 100755 index 190de192..00000000 --- a/home/xyz/.local/bin/vinfo +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -# steal from https://github.com/HiPhish/info.vim -"$EDITOR" -RM +"Info $1 $2" +only diff --git a/home/xyz/.local/bin/wh b/home/xyz/.local/bin/wh deleted file mode 100755 index d20f0de6..00000000 --- a/home/xyz/.local/bin/wh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -# blue, see `man terminfo` -setaf="$(tput setaf 4)" -sgr0="$(tput sgr0)" - -# dash `command -V "$@"` will only output first command's type, same as `type`, but different than posix specification? so not use here -for cmd in type whatis whereis which "pacman -Qo --color always"; do -	printf '\n%s\n%s\n' "$setaf$cmd $*$sgr0" "$($cmd "$@" 2>&1)" -	#printf '\n\033[0;34m%s\033[0m\n%s\n' "$setaf$cmd $*$sgr0" "$($cmd "$@" 2>&1)" -done | "$PAGER" diff --git a/home/xyz/.local/bin/xmq b/home/xyz/.local/bin/xmq deleted file mode 100755 index 83eca0f6..00000000 --- a/home/xyz/.local/bin/xmq +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -xdg-mime query filetype "$1" | tee /dev/tty | xargs xdg-mime query default | 
