moving tools from another repo

This commit is contained in:
Q
2024-10-11 21:35:44 +03:00
parent 8979ccf296
commit 3fbd5860e0
6 changed files with 125 additions and 0 deletions

1
bin/archive-extract2folder Symbolic link
View File

@@ -0,0 +1 @@
../files/archive-extract2folder

1
bin/split-q Symbolic link
View File

@@ -0,0 +1 @@
../files/split-q

1
bin/tsp-menu Symbolic link
View File

@@ -0,0 +1 @@
../shell/tsp-menu

29
files/archive-extract2folder Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
set -e
for arch in "$@"; do
case "$arch" in
*.tar) D="`basename "$arch" .tar`"; U="tar -x -v -f"; ;;
*.tar.gz) D="`basename "$arch" .tar.gz`"; U="tar -x -z -v -f"; ;;
*.tgz) D="`basename "$arch" .tgz`"; U="tar -x -z -v -f"; ;;
*.tar.Z) D="`basename "$arch" .tar.Z`"; U="tar -x -Z -v -f"; ;;
*.tar.z) D="`basename "$arch" .tar.z`"; U="tar -x -Z -v -f"; ;;
*.tar.bz2) D="`basename "$arch" .tar.bz2`"; U="tar -x -j -v -f"; ;;
*.zip) D="`basename "$arch" .zip`"; U="unzip"; ;;
*.rar) D="`basename "$arch" .rar`"; U="unrar x"; ;;
esac
if [[ -z "$FORCE_EXTRACT" ]]; then
echo "extract $arch to $PWD/$D/?"
read foo
else
echo "extracting $arch to $PWD/$D/"
fi
mkdir -p "$D"
archive=$( realpath "$arch" )
pushd "$D"
$U "$archive"
popd
done
sleep 1

35
files/split-q Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
CMD="split -d -a 4"
_help() {
split --help
echo ""
echo "My default switches for split utility"
echo "$CMD -b 500M FILE FILE."
}
_helpexit() {
_help
exit
}
for (( i=1; i<=$#; i++ )); do
[[ ${!i} = "-h" ]] && _helpexit
[[ ${!i} = "--help" ]] && _helpexit
done
args=( )
for (( i=1; i<=$#; i++ )); do
test -f "${!i}" && {
file="${!i}"
# file found, remove from arguments
set -- "${@:1:i-1}" "${@:i+1}"
}
[[ "${!i}" = "-b" ]] && SIZE_SET=1
done
[[ "$SIZE_SET" -eq 1 ]] || {
size="-b 500M"
}
test -f "$file" || { echo "No such file"; exit 1; }
set -x
pv "$file" | $CMD $size "$@" - "$file".

58
shell/tsp-menu Executable file
View File

@@ -0,0 +1,58 @@
#!/bin/bash
if [[ "$1" = "-h" ]]; then
echo "utility to control tsp with menu"
exit
fi
. qolop
_qCol export _
function fkey_colorize() {
for word in $@; do
echo -ne "${_G}${word:0:1}${_Z}${word:1} "
done
echo
}
function get_id() {
tsp -l
echo -e "${_Y}"
read -i "$id" -e -p "id? " id
echo -e "${_Z}"
if [[ "$id" = q ]]; then
exit
fi
}
function shuffle_jobs() {
ids=( $( tsp -l | tail -n +2 | grep queued | cut -d' ' -f1 ) )
ids_len=${#ids[@]}
for src in ${ids[@]}; do
new=${ids[$(( $RANDOM % $ids_len ))]}
if [[ $new -eq $src ]]; then
continue
fi
tsp -U "${src}-${new}"
done
}
while true; do
echo '$ 'tsp $cmd $id
eval tsp $cmd $id
id=""
cmd=""
echo
fkey_colorize list console info remove kill Clear Slots shuffle Killall quit
read -p"tsp " -n1 menu
echo
case "$menu" in
q) break;;
l) cmd=-l;;
c|i|r|k) cmd=-"$menu"; get_id; ;;
C) id=""; cmd=-C; ;;
S) cmd=""; echo Current:; tsp -S; read -p "new? " -i 1 -e num; tsp -S $num; ;;
K) read -p "sure? ctrl-c " foo; id=""; cmd=-K; ;;
s) shuffle_jobs; ;;
*) break;;
esac
done