A collection of POSIX-compatible shell scripts and utilities to enhance your command-line experience.
A convenient Git commit function that includes optional spell-checking for commit messages.
Usage: gc <commit message>
Features:
- Automatic spell-checking using aspell (if installed)
- Colored output for better readability
- Confirmation prompt before committing
- Comprehensive error handling
Example:
gc "Fix typo in documentation"A process monitoring tool that can automatically kill processes exceeding CPU or memory thresholds. Supports both individual process monitoring and aggregate threshold monitoring for multi-process applications. Features time window tracking to prevent killing processes during brief resource spikes.
Usage: sb-mksep [-n PROCESS_NAME] [-c CPU_THRESHOLD] [-m MEMORY_THRESHOLD] [-s SLEEP_TIME] [-t] [-o] [-a] [-k KILL_COUNT] [-w VIOLATIONS/WINDOW]
Options:
-n PROCESS_NAME- Process name to monitor (default: all processes)-c CPU_THRESHOLD- CPU usage percentage threshold-m MEMORY_THRESHOLD- Memory usage percentage threshold-s SLEEP_TIME- Sleep time between checks in seconds (default: 30)-t- Test mode (shows what would be killed without actually killing)-o- Compact mode (only show processes with CPU/Memory >= 1%)-a- Aggregate mode (apply thresholds to combined usage of matching processes)-k KILL_COUNT- Number of processes to kill when aggregate threshold exceeded (requires-a)-w VIOLATIONS/WINDOW- Time window mode - kill only after X violations within Y checks (e.g., -w 3/5)
Modes:
- Individual mode (default): Each process is checked separately against thresholds
- Aggregate mode (-a): Combined usage of matching processes is checked against thresholds
- Time window mode (-w): Requires multiple violations before killing (works with both individual and aggregate modes)
Examples:
# Individual mode: Kill any Firefox process exceeding 90% CPU or 85% Memory
sb-mksep -n firefox -c 90 -m 85
# Time window: Kill Firefox only after 3 violations within 5 checks
sb-mksep -n firefox -c 90 -w 3/5
# Aggregate mode: Kill Chrome processes when their combined CPU exceeds 80%
sb-mksep -n chrome -a -c 80
# Aggregate with time window: Kill after 2 violations in 4 checks
sb-mksep -n chrome -a -c 80 -w 2/4
# Kill 2 highest memory processes when total system memory exceeds 90%
sb-mksep -a -m 90 -k 2
# Test mode: show all processes exceeding 95% CPU
sb-mksep -c 95 -t
# Monitor Chrome every 10 seconds with aggregate CPU threshold of 70%
sb-mksep -n chrome -a -c 70 -s 10Aliases:
mksep- Alias forsb-mksep
- Ensure that you have a POSIX-compatible shell installed on your system.
- Make sure you have the necessary permissions to create directories and copy files in your home directory.
-
Download the installation script and the
sb-shellscripts to your local machine. -
Open a terminal and navigate to the directory where the installation script is located.
-
Run the installation script by executing the following command:
./install.sh
-
The script will prompt you to confirm the installation. Enter
yto proceed ornto cancel the installation. -
If you choose to proceed, the script will perform the following actions:
- Check if the
$HOME/.sb-shelldirectory exists. If it doesn't, the script will create it. - If the
$HOME/.sb-shelldirectory already exists, the script will delete it and recreate it to ensure a clean installation. - Copy the
sb-shell.shscript and thescripts*directories to the$HOME/.sb-shelldirectory.
- Check if the
-
After copying the files, the script will provide instructions for adding sb-shell to your shell's configuration file.
-
If the installation is successful, you will see a confirmation message with instructions on how to complete the setup for your specific shell.
Once the installation is complete, you can start using the sb-shell scripts in your shell environment. The scripts will be available in the $HOME/.sb-shell directory.
To activate sb-shell, add the following line to your shell's configuration file (e.g., .bashrc, .zshrc, etc.):
source "$HOME/.sb-shell/sb-shell.sh"If you want to customize the scripts or add your own, you can modify the files in the $HOME/.sb-shell directory.
To uninstall the sb-shell scripts, simply delete the $HOME/.sb-shell directory and remove any references to it from your shell's configuration file.
If you encounter any issues during the installation or while using the sb-shell scripts, please check the following:
- Ensure that you have the necessary permissions to create directories and copy files in your home directory.
- Make sure that the installation script and the
sb-shellscripts are located in the correct directory. - Verify that your shell's configuration file is properly configured and sourced.
If the issue persists, please contact the script maintainer or seek further assistance.