diff options
| author | Xiao Pan <gky44px1999@gmail.com> | 2023-10-25 06:45:08 +0000 | 
|---|---|---|
| committer | Xiao Pan <gky44px1999@gmail.com> | 2023-10-25 06:45:08 +0000 | 
| commit | e4db0b25bf6540386e737594a47cb92a83c0cbea (patch) | |
| tree | 70f85967663aa539fabe40e40803fa638acfae00 /home/xyz/.local/bin | |
| parent | 12bda1ac3390f2d16a401d895faf0ef2418f874c (diff) | |
update
Diffstat (limited to 'home/xyz/.local/bin')
| -rwxr-xr-x | home/xyz/.local/bin/cfg | 1 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gita | 2 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gitfork | 8 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gitpu | 19 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/gitsetup | 6 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mmi | 2 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mvln | 3 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/mvtr | 3 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/o | 2 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/time-uuid (renamed from home/xyz/.local/bin/time.uuid) | 2 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/upd | 99 | ||||
| -rwxr-xr-x | home/xyz/.local/bin/wh | 2 | 
12 files changed, 26 insertions, 123 deletions
| diff --git a/home/xyz/.local/bin/cfg b/home/xyz/.local/bin/cfg index 3f7ec29d..92a097e7 100755 --- a/home/xyz/.local/bin/cfg +++ b/home/xyz/.local/bin/cfg @@ -1,5 +1,6 @@  #!/bin/sh +umask 077  while getopts lsmM opt; do  	case $opt in  		#c)		 diff --git a/home/xyz/.local/bin/gita b/home/xyz/.local/bin/gita index 27b45549..9e445761 100755 --- a/home/xyz/.local/bin/gita +++ b/home/xyz/.local/bin/gita @@ -11,7 +11,7 @@ while getopts cls f; do  done  shift $((OPTIND-1)) -mes="${1:-refactor}" +mes="${1:-update}"  $cmd add -u  $cmd commit -m "$mes" diff --git a/home/xyz/.local/bin/gitfork b/home/xyz/.local/bin/gitfork deleted file mode 100755 index cefc4f68..00000000 --- a/home/xyz/.local/bin/gitfork +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -git clone "$1" -cd "$(basename "$1" .git)" || exit -git remote add upstream "$2" -git branch fly -git checkout fly -git push --set-upstream origin fly diff --git a/home/xyz/.local/bin/gitpu b/home/xyz/.local/bin/gitpu deleted file mode 100755 index fcc32be9..00000000 --- a/home/xyz/.local/bin/gitpu +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -if [ -z "$1" ]; then -	git checkout master  -	git pull upstream master -	git push -	git checkout fly -	git merge --no-edit master -	git push -else -	for dir ; do -		git -C "$dir" checkout master  -		git -C "$dir" pull upstream master -		git -C "$dir" push -		git -C "$dir" checkout fly -		git -C "$dir" merge --no-edit master -		git -C "$dir" push -	done -fi diff --git a/home/xyz/.local/bin/gitsetup b/home/xyz/.local/bin/gitsetup deleted file mode 100755 index 56f91d76..00000000 --- a/home/xyz/.local/bin/gitsetup +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -git clone "$1" -cd "$(basename "$1" .git)" || exit -git remote add upstream "$2" -git checkout fly diff --git a/home/xyz/.local/bin/mmi b/home/xyz/.local/bin/mmi index cad872cc..350fe505 100755 --- a/home/xyz/.local/bin/mmi +++ b/home/xyz/.local/bin/mmi @@ -19,7 +19,7 @@ shift $((OPTIND-1))  if [ -z "$1" ]; then  	eval "$cmd"  else -	for dir ; do +	for dir; do  		cd "$dir" || exit  		eval "$cmd"  		cd "$origin" || exit diff --git a/home/xyz/.local/bin/mvln b/home/xyz/.local/bin/mvln index fb540390..54cef541 100755 --- a/home/xyz/.local/bin/mvln +++ b/home/xyz/.local/bin/mvln @@ -25,6 +25,3 @@ else  		shift  	done  fi - -# for test -#rm -rf ~/test/A\ A/; mkdir -p ~/test/A\ A/; cp -r ~/test/0t/ ~/test/A\ A/1t/; mvln ~/test/A\ A/1t/* ~/test/A\ A/; tree ~/test/A\ A/ diff --git a/home/xyz/.local/bin/mvtr b/home/xyz/.local/bin/mvtr index 850f8dba..28eebf0f 100755 --- a/home/xyz/.local/bin/mvtr +++ b/home/xyz/.local/bin/mvtr @@ -9,6 +9,3 @@  # -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 '{}' \; - -# for test -#mkdir -p ~/test/A\ A/; rm -rf ~/test/A\ A/1t/; cp -r ~/test/0t/ ~/test/A\ A/1t/; time mvtr ~/test/A\ A/1t/; tree ~/test/A\ A/1t/ diff --git a/home/xyz/.local/bin/o b/home/xyz/.local/bin/o index d70a6d76..8fb066c7 100755 --- a/home/xyz/.local/bin/o +++ b/home/xyz/.local/bin/o @@ -13,6 +13,8 @@  # 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 diff --git a/home/xyz/.local/bin/time.uuid b/home/xyz/.local/bin/time-uuid index 11cc67ad..bdaf4b3d 100755 --- a/home/xyz/.local/bin/time.uuid +++ b/home/xyz/.local/bin/time-uuid @@ -3,4 +3,4 @@  # 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}')" +echo "$(date '+%s-%N')-$(uuidgen -t | awk -F- '{OFS="-"; print $3,$2,$1,$4,$5}')" diff --git a/home/xyz/.local/bin/upd b/home/xyz/.local/bin/upd index 8fd6f24b..4552db43 100755 --- a/home/xyz/.local/bin/upd +++ b/home/xyz/.local/bin/upd @@ -2,34 +2,13 @@  all () {  	fast +	clean  	usb -	#qb -	#kg -	#ncm  	refl -	#gall  }  clean () { -	#nsxiv -c -	# my ways -	# -exec can't replace -execdir here -	#find "$XDG_CACHE_HOME/nsxiv/" -depth -type d -empty -execdir rmdir -- '{}' \+ -	# -exec can replace -execdir here -	#find "$XDG_CACHE_HOME/nsxiv/" -depth -type d -execdir rmdir --ignore-fail-on-non-empty -- '{}' \+ -	# nsxiv man page way -	#find "$XDG_CACHE_HOME/nsxiv/" -depth -type d -empty ! -name '.' -exec rmdir -- '{}' \; - -	#rm "$HOME/.mozilla/firefox/xxxxxxxx.fly/prefs.js.backup."* - -	# https://unix.stackexchange.com/questions/92095/reset-atq-list-to-zero -	sudo systemctl stop atd -	echo 0 | sudo tee /var/spool/atd/.SEQ > /dev/null -	sudo systemctl start atd - -	#rm -rf "$XDG_VIDEOS_DIR/recordings/tmp/" - -	sudo pacman -Sc --noconfirm +	paru -aSc --noconfirm  }  # basic daily stuff @@ -38,100 +17,60 @@ fast () {  	misc  } -gall () { -	gallery-dl --download-archive "$XDG_DOCUMENTS_DIR/database/gallery-dl.sqlite3" -d "$XDG_PICTURES_DIR/anime/gallery-dl/" -i "$XDG_CONFIG_HOME/myconf/gallery_urls" -} - -userjs () { -	kill $(pidof "$BROWSER") -	"$HOME/.mozilla/firefox/xxxxxxxx.fly/prefsCleaner.sh" -s -	"$HOME/.mozilla/firefox/xxxxxxxx.fly/updater.sh" -us -} - -kg () { -	curlkg -u649b9e82272a348b -- "$XDG_MUSIC_DIR/not_pure/lan_lan/kg/" -	#curlkg -u64949d822c25328c -- "$XDG_MUSIC_DIR/not_pure/cheng_ruan/kg/" -} -  misc () { -	"$EDITOR" +PlugUpgrade +PlugClean! +PlugUpdate +qa -	tldr --update -	sudo hardcode-fixer -	sudo units_cur -	awk '!a[$0]++' "$XDG_DATA_HOME/sdcv_history" | sponge "$XDG_DATA_HOME/sdcv_history" - -	# temperory solution before find a way of using git submodule or subtree with `cfg -l` -	#git --git-dir=/home/xyz/.mozilla/firefox/xxxxxxxx.fly/chrome/firefox-csshacks/.git/ --work-tree=/home/xyz/.mozilla/firefox/xxxxxxxx.fly/chrome/firefox-csshacks/ pull - -	#userjs -	clean -} - -ncm () { -	curlncm -a48860966 -- "$XDG_MUSIC_DIR/not_pure/lan_lan/ncm/artist/" -	#curlncm -a46703185 -- "$XDG_MUSIC_DIR/not_pure/cheng_ruan/ncm/artist/" -	#curlncm -a30382647 -- "$XDG_MUSIC_DIR/not_pure/qi_tian_sakura/ncm/artist/" - -	curlncm -r793052426 -- "$XDG_MUSIC_DIR/not_pure/lan_lan/ncm/djradio/" -	#curlncm -r792968433 -- "$XDG_MUSIC_DIR/not_pure/cheng_ruan/ncm/djradio/" -	#curlncm -r792042397 -- "$XDG_MUSIC_DIR/not_pure/qi_tian_sakura/ncm/djradio/" +	"$EDITOR" +PlugClean! +PlugUpdate +qa +	rustup update  }  pac () {  	pacpacs="$(sudo pacman --noconfirm -Syu | tee /dev/tty | grep '^Packages' | cut -d' ' -f3-)" -	aurpacs="$(paru --noconfirm -aSyu | tee /dev/tty | grep '^Aur' | cut -d' ' -f3-)" +	aurpacs="$(paru --noconfirm -aSu | tee /dev/tty | grep '^Aur' | cut -d' ' -f3-)"  	# part steal from aur comment  	# sometimes "ERROR: Failure while downloading": https://github.com/neovim/neovim/issues/15709  	# echo 1, printf 1 and yes 1 all works? not sure why  	# aur neovim-nightly-bin has some issue on 12/26/2021? switch to community repo neovim temporary  	#rm -rf ~/.cache/paru/clone/neovim-nightly-bin/ && echo 1 | PARU_PAGER=cat paru --rebuild --redownload neovim-nightly-bin -	sudo pacman -Fy +	pacman -Qqme > "$XDG_CONFIG_HOME/myconf/pacman_Qqme" +	pacman -Qqne > "$XDG_CONFIG_HOME/myconf/pacman_Qqne" +	systemctl list-unit-files --state=enabled > "$XDG_CONFIG_HOME/myconf/sye" +	systemctl --user list-unit-files --state=enabled > "$XDG_CONFIG_HOME/myconf/syue"  	# pacdiff default use pacman database, so no need `sudo -E` for find, but will be a little bit slower  	log="$log  updated pacman packages: $pacpacs  updated aur packages: $aurpacs  pacdiff: $(pacdiff -o | tr '\n' ' ') +checkrebuild: $(checkrebuild)  "  } -qb () { -	rm -r -- "$HOME/programs/qbittorrent_search_plugins/" -	curlqb "$HOME/programs/qbittorrent_search_plugins/" -} -  refl () { -	sudo reflector --verbose --save /etc/pacman.d/mirrorlist --score 50 --fastest 45 +	# why not use http: +	# https://www.reddit.com/r/archlinux/comments/kx149z/should_i_use_http_mirrors/ +	# https://www.reddit.com/r/archlinux/comments/ej4k4d/is_it_safe_to_use_not_secured_http_pacman_mirrors/ +	# rsync may need to change XferCommand in /etc/pacman.conf +	# https://www.reddit.com/r/archlinux/comments/mynw6e/rsync_mirrors_with_pacman/ +	# need --delay so no super out of sync mirrors +	sudo reflector --verbose --save /etc/pacman.d/mirrorlist --country us --protocol https --delay 1 --latest 25 --score 25 --fastest 10  }  usb () { -	cfg -l push usb  	cfg -s push -	git --git-dir="$XDG_DOCUMENTS_DIR/notes/.git/" --work-tree="$XDG_DOCUMENTS_DIR/notes/" push usb -	git --git-dir="$HOME/programs/reminders/.git/" --work-tree="$HOME/programs/reminders/" push usb -	# not sure if useful or not -	sync  }  if [ $# -eq 0 ]; then  	fast  else -	while getopts acfgjkmnpqru opt; do +	while getopts acfmpru opt; do  		case $opt in  			a)all;;  			c)clean;;  			f)fast;; -			g)gall;; -			j)userjs;; -			k)kg;;  			m)misc;; -			n)ncm;;  			p)pac;; -			q)qb;;  			r)refl;;  			u)usb;;  			\?)exit 1;;  		esac  	done  fi - -printf '%s' "$log" +[ "$log" ] && printf '%s' "$log" | tee "$XDG_DOCUMENTS_DIR/logs/upd.log" diff --git a/home/xyz/.local/bin/wh b/home/xyz/.local/bin/wh index 4206c363..d20f0de6 100755 --- a/home/xyz/.local/bin/wh +++ b/home/xyz/.local/bin/wh @@ -8,4 +8,4 @@ sgr0="$(tput sgr0)"  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 +done | "$PAGER" | 
