I had almost given up posting such things on forums and/or other platforms bc many linux users are ungrateful and instead of a simple "thanks", I often received hate and curses for trying to help someone who might have come across the same problems I have or to simply make their linux life easier.
But when you read something like "I changed my "Like" reaction to "Love"", that changes everything and tells you there is a point in keep doing it. If it helps even one person, there IS a point to it and I'll keep doing it. I don't ask for money or donations, nor will I ever ask for such a thing. Everything I do or share is FOSS - forever. The only thing I do ask is this: if you find what I've posted useless FOR YOU, just skip it and move on. It may not be useful for you, but it may be useful for someone else.
You can have a look at my repositories on github - everything is FOSS with MIT License which means you're free to change things in any way you want, even without asking me. https://github.com/rado84-github?tab=repositories
So, after reading that line about changing the reaction to "love", I decided to open this topic where to share how to use case scripts (altough I already did that on my github) and share some useful cases and scripts meant mostly for lazy people like me in order to make the linux life easier. I know what you're thinking: how can a person who writes scripts be lazy but that's the thing - scripts are for automation of processes. You write it once, then activate it by alias and it does the rest with a minimal effort from you.
I went a long way since 2023 when I asked for a script to remove things from SRT subtitles. Back then I had a few hundred bash scripts that until a few months ago had reached the number of 280 .sh files and the aliases themselves used to be over 350. But then I found out about cases and learned how to use them. It turned out they're a lot easier than regular scripts, altough they do have some... peculiarities about them.
I'm well aware that everything you'll read in this post looks likе... an elite-level skill, but it's not. It just looks that way. All you need is just a little practice. Once you get used to it, you'll start coming up with your scripts and/or cases and you'll even be able to write them blindfolded. If I could learn all this in less than a month, so can you.
And nowadays the aliases and scripts I have were severely shrunk to these modest numbers, thanks to the cases:
From 350+ aliases and 280+ bash scripts to just 82/71 in less than a month. And yet my system has never felt so... powerful bc anything a regular person would spend 2-5 min clicking here and there, I do it in under 60 seconds.
I won't share ALL of the cases/scripts, only those that I think might be useful for someone. Once you know how to use cases, you're free to come up with your own cases.
Here's a detailed explanation about case scripts: https://github.com/rado84-github/case-scripts. I did my best to write it as clear as possible, along with some examples, but still, if you have any questions, feel free to ask - I'll do my best to answer as clearly as possible.
I can generate my own scripts and case scripts, so I think I should start with that. Basically, with a few letters in the terminal, you can generate a script or a case with predefined content (template) which then you can edit manually with your favorite text editor.
Bash script generator. It works when you open it in any specific directory. If you open the terminal without cd to a specific dir, it will create the script in your /home/$USER.
These 4 lines with options0/options9, rsf - they're not mandatory. They're just part of MY template and you're free to remove or modify them, depending on your workflow. If you do decide to use them, especially options0 and options9, keep in mind they're part of the syntax of the 7zip CLI tool for linux. AND if you decide to try options9, you better remove the part with "-md=460m" bc that's a dictionary size which is tailored for my hardware. Unless you have 62.62 GiB RAM and AT LEAST a 20-thread CPU, I don't recommend you to try this option, if you don't wanna crash your system when archiving things. Dictionary size of 460 MiB wil lead to your system use exactly 50.0 GiB RAM...
This script generator will create a bash file ('.sh') in the directory you've opened with a name you type before you hit Enter. I have an alias for this generator and I generate scripts like this:
In this case "meab" stands for "Mass Effect Andromeda backup". So, if I've opened the terminal in "/B/CLI/SCRIPTS", it will create meab.sh there and it will contain the above template. Then I can change it to create a script that would automatically backup the entire directory of "Mass Effect Andromeda".
-------------------------------
I also have a case generator which makes things a lot easier. Again, the generator is activated by an alias but the syntax is a little different. The destination is predefined in the header of the script (the variable named DEST) but you can change it to suit your purposes. Again, this is a template tailored for my system and workflow, but you can change it. The syntax to activate the case generator, including my alias, is like this:
which will create a script file with 12 empty cases in it which then you have to manually change. The number of cases depends on you. Just remember that the case generator accepts only positive integers and if you don't enter a desired number of cases, by default it will create a file with 5 cases. The above code creates "SYSTEM-CASE.sh" with 12 cases in it.
Here's the code for the generator itself:
This is it for now. When I find a script/case that might be useful for someone, I'll write it in a new post.
But when you read something like "I changed my "Like" reaction to "Love"", that changes everything and tells you there is a point in keep doing it. If it helps even one person, there IS a point to it and I'll keep doing it. I don't ask for money or donations, nor will I ever ask for such a thing. Everything I do or share is FOSS - forever. The only thing I do ask is this: if you find what I've posted useless FOR YOU, just skip it and move on. It may not be useful for you, but it may be useful for someone else.
You can have a look at my repositories on github - everything is FOSS with MIT License which means you're free to change things in any way you want, even without asking me. https://github.com/rado84-github?tab=repositories
So, after reading that line about changing the reaction to "love", I decided to open this topic where to share how to use case scripts (altough I already did that on my github) and share some useful cases and scripts meant mostly for lazy people like me in order to make the linux life easier. I know what you're thinking: how can a person who writes scripts be lazy but that's the thing - scripts are for automation of processes. You write it once, then activate it by alias and it does the rest with a minimal effort from you.
I went a long way since 2023 when I asked for a script to remove things from SRT subtitles. Back then I had a few hundred bash scripts that until a few months ago had reached the number of 280 .sh files and the aliases themselves used to be over 350. But then I found out about cases and learned how to use them. It turned out they're a lot easier than regular scripts, altough they do have some... peculiarities about them.
I'm well aware that everything you'll read in this post looks likе... an elite-level skill, but it's not. It just looks that way. All you need is just a little practice. Once you get used to it, you'll start coming up with your scripts and/or cases and you'll even be able to write them blindfolded. If I could learn all this in less than a month, so can you.
And nowadays the aliases and scripts I have were severely shrunk to these modest numbers, thanks to the cases:
Code:
[rado@arch]: ~>$ count cli
Total number of aliases is: 82.
Total number of bash scripts in '/B/CLI/SCRIPTS' is: 71.
From 350+ aliases and 280+ bash scripts to just 82/71 in less than a month. And yet my system has never felt so... powerful bc anything a regular person would spend 2-5 min clicking here and there, I do it in under 60 seconds.
I won't share ALL of the cases/scripts, only those that I think might be useful for someone. Once you know how to use cases, you're free to come up with your own cases.
Here's a detailed explanation about case scripts: https://github.com/rado84-github/case-scripts. I did my best to write it as clear as possible, along with some examples, but still, if you have any questions, feel free to ask - I'll do my best to answer as clearly as possible.
I can generate my own scripts and case scripts, so I think I should start with that. Basically, with a few letters in the terminal, you can generate a script or a case with predefined content (template) which then you can edit manually with your favorite text editor.
Bash script generator. It works when you open it in any specific directory. If you open the terminal without cd to a specific dir, it will create the script in your /home/$USER.
Code:
#!/usr/bin/env bash
DEST="$PWD"
cat <<EOF > "$DEST/$1.sh"
#!/usr/bin/env bash
options0="-mx0 -mmt20"
options9="-mx9 -mmt20 -md=460m"
rsf="rsync --info=progress2"
rsd="rsync -r --info=progress2"
EOF
chmod +x "$DEST/$1.sh"
gedit "$DEST/$1.sh" &
exit
These 4 lines with options0/options9, rsf - they're not mandatory. They're just part of MY template and you're free to remove or modify them, depending on your workflow. If you do decide to use them, especially options0 and options9, keep in mind they're part of the syntax of the 7zip CLI tool for linux. AND if you decide to try options9, you better remove the part with "-md=460m" bc that's a dictionary size which is tailored for my hardware. Unless you have 62.62 GiB RAM and AT LEAST a 20-thread CPU, I don't recommend you to try this option, if you don't wanna crash your system when archiving things. Dictionary size of 460 MiB wil lead to your system use exactly 50.0 GiB RAM...
This script generator will create a bash file ('.sh') in the directory you've opened with a name you type before you hit Enter. I have an alias for this generator and I generate scripts like this:
Code:
makesh meab
In this case "meab" stands for "Mass Effect Andromeda backup". So, if I've opened the terminal in "/B/CLI/SCRIPTS", it will create meab.sh there and it will contain the above template. Then I can change it to create a script that would automatically backup the entire directory of "Mass Effect Andromeda".
-------------------------------
I also have a case generator which makes things a lot easier. Again, the generator is activated by an alias but the syntax is a little different. The destination is predefined in the header of the script (the variable named DEST) but you can change it to suit your purposes. Again, this is a template tailored for my system and workflow, but you can change it. The syntax to activate the case generator, including my alias, is like this:
Code:
makecase 12 SYSTEM
which will create a script file with 12 empty cases in it which then you have to manually change. The number of cases depends on you. Just remember that the case generator accepts only positive integers and if you don't enter a desired number of cases, by default it will create a file with 5 cases. The above code creates "SYSTEM-CASE.sh" with 12 cases in it.
Here's the code for the generator itself:
Code:
#!/usr/bin/env bash
DEST="/B/CLI/SCRIPTS/CASES"
COUNT="${1:-5}" # Without an argument creates 5 cases by default. Accepts only positive integers.
OUTFILE="$DEST/$2-CASE.sh"
if [ -z "${2:-}" ]; then
echo "You have to enter file name. Better use dashes instead of spaces.\n"
exit 1
fi
if ! [[ "$COUNT" =~ ^[0-9]+$ ]]; then
printf "Use integers only. Task terminated.\nUsage: './bash-case-generator.sh 18' will create example-18-case.sh in the destination.\n"
exit 1
fi
{
cat <<HEADER
#!/usr/bin/env bash
set -euo pipefail
options0="-mx0 -mmt20"
options9="-mx9 -mmt20 -md=460m"
rsf="rsync --info=progress2"
rsd="rsync -r --info=progress2"
case "\$1" in
HEADER
for i in $(seq 1 "$COUNT"); do
cat <<EOF
option$i)
echo "Put here the code for option$i"
;;
EOF
done
cat <<FOOTER
*)
echo "Cases: ."
;;
esac
FOOTER
} > "$OUTFILE"
chmod +x "$OUTFILE"
echo "$OUTFILE with $COUNT cases was created."
This is it for now. When I find a script/case that might be useful for someone, I'll write it in a new post.
Last edited:

