Skip to content

Repository files navigation

Bash Scripts Repository

README pt-br 🇧🇷

A collection of my daily used Bash scripts, which include multimedia processing, development environment setup, and productivity tasks. Note that some scripts contain hardcoded values and may need to be edited to work in other environments.

Repository Structure

bash-scripts/
├── Root scripts (multimedia & utilities)
├── ambiente-desenvolvimento/     # Development environment setup
│   ├── setup.sh                 # Main setup menu
│   ├── scripts/                 # Individual setup scripts
│   └── arquivos/                # Supporting files and binaries
└── lista-presença/              # Student attendance management

Root Scripts

1. baixar-videos.sh - Batch Video Downloader

Downloads videos from a list of URLs and saves them as 720p MP4 files.

Usage:

./baixar-videos.sh <file-with-urls>

Arguments:

  • <file-with-urls>: Text file with one URL per line

Requirements:

  • yt-dlp - YouTube and video downloader

Example:

# Create a file with URLs
echo "https://example.com/video1" > urls.txt
echo "https://example.com/video2" >> urls.txt

./baixar-videos.sh urls.txt

2. converter-webp.sh - Image to WebP Converter

Converts an image to WebP format with metadata stripping and file deletion.

Usage:

./converter-webp.sh <image-file>

Arguments:

  • <image-file>: Path to the image file (jpg, png, etc.)

Requirements:

  • ImageMagick (magick command)

Features:

  • Removes EXIF metadata and color profiles for smaller file size
  • Deletes original file after successful conversion

Example:

./converter-webp.sh photo.jpg  # Creates photo.webp and removes photo.jpg

3. gerar-favicon.sh - Favicon Generator

Generates a favicon.ico file from an image with multiple resolutions.

Usage:

./gerar-favicon.sh <image-logo>

Arguments:

  • <image-logo>: Path to the image file to use as favicon source

Requirements:

  • ImageMagick (magick command)

Features:

  • Generates favicon with multiple resolutions: 64x64, 48x48, 32x32, 16x16
  • Ensures transparent background

Example:

./gerar-favicon.sh logo.png  # Creates favicon.ico in current directory

4. gerar-og.sh - Open Graph Image Generator

Creates optimized Open Graph (OG) images for social media sharing (1200x630px).

Usage:

./gerar-og.sh <original-image>

Arguments:

  • <original-image>: Path to the original image

Requirements:

  • ImageMagick (magick command)

Features:

  • Resizes to 1200x630px (standard OG dimensions)
  • Center-crops to maintain aspect ratio
  • Removes EXIF metadata
  • Optimized compression (quality 85)
  • Progressive JPEG encoding for faster loading

Output:

  • Creates <original-image-name>_og.jpg

Example:

./gerar-og.sh banner.png  # Creates banner_og.jpg

5. limpar-exercicios.sh - Exercise Folder Cleaner

Cleans exercise folders by keeping only C source files (.c) and headers (.h).

Usage:

./limpar-exercicios.sh

Requirements:

  • Must be run from the parent directory containing exercise folders
  • find command

Features:

  • Recursively removes all files except .c and .h
  • Processes all subdirectories
  • Prints status for each folder

Example:

# Directory structure
# exercices/
#   ├── ex1/
#   │   ├── main.c
#   │   ├── helper.h
#   │   ├── output.o      (will be deleted)
#   │   └── README.txt    (will be deleted)

./limpar-exercicios.sh
# Result: Only .c and .h files remain in each exercise folder

6. reset-container.sh - Docker Container Reset

Stops and resets a Docker container for a specific project.

Usage:

./reset-container.sh

Requirements:

  • Docker installed and running
  • Project: $HOME/Documentos/Projetos/matrix-blur-filter

Features:

  • Stops the running container
  • Removes the old container
  • Rebuilds the Docker image
  • Creates and runs a new container on port 3000

Configuration (hardcoded):

  • Project path: $HOME/Documentos/Projetos/matrix-blur-filter
  • Image name: matrix-blur-app
  • Container name: blur-app
  • Port: 3000:3000

7. transcrever.sh - Audio/Video Transcription

Transcribes audio or video files to text using OpenAI's Whisper model.

Usage:

./transcrever.sh <input-file>

Arguments:

  • <input-file>: Audio or video file (mp3, wav, mp4, etc.)

Requirements:

  • whisper.cpp - Built binary at $HOME/whisper.cpp/build/bin/whisper-cli
  • ggml-small.bin model at $HOME/whisper.cpp/models/ggml-small.bin
  • ffmpeg - For audio conversion if input is not WAV format

Features:

  • Automatically converts non-WAV files to WAV format (16kHz, mono)
  • Uses Portuguese language model
  • Temporary files are cleaned up automatically
  • GPU acceleration support (-dev 1 flag)

Installation:

Example:

./transcrever.sh lecture.mp4
./transcrever.sh podcast.mp3

Development Environment Setup

8. ambiente-desenvolvimento/setup.sh - Interactive Setup Menu

Interactive menu for setting up the development environment. Allows installing components individually or all at once.

Usage:

cd ambiente-desenvolvimento
bash setup.sh

Features:

  • Interactive menu with 6 options
  • Install components individually or all together

Menu Options:

1) Install APT packages
2) Install Kate editor
3) Install LazyGit
4) Install FiraCode Nerd Font
5) Update all Snaps
6) Install everything

9. scripts/pacotes-apt.sh - APT Package Installer

Installs system packages from a predefined list.

Usage:

bash scripts/pacotes-apt.sh

Requirements:

  • sudo privileges
  • apt package manager (Debian/Ubuntu-based systems)

Features:

  • Reads package list from arquivos/pacotes-apt.txt
  • Updates package cache
  • Installs all packages automatically

10. scripts/fira-code-nerd-font.sh - FiraCode Font Installer

Installs FiraCode Nerd Font from a ZIP archive.

Usage:

bash scripts/fira-code-nerd-font.sh

Requirements:

  • unzip command
  • Font ZIP file at arquivos/FiraCode.zip

Features:

  • Extracts to ~/.local/share/fonts/FiraCode
  • Rebuilds font cache with fc-cache

11. scripts/kate.sh - Kate Editor Installer

Installs Kate text editor via Flatpak with configuration backup.

The purpose of choosing Kate is that it is a lightweight editor with Clangd LSP and Vim motions support, making it a perfect choice for usage in my college's C classes.

Usage:

bash scripts/kate.sh

Requirements:

  • flatpak installed
  • User-level execution (no sudo/root)
  • arquivos/org.kde.kate.flatpakref file
  • arquivos/org.kde.kate.tar.gz configuration backup

Features:

  • Installs Kate for the current user only
  • Restores configuration from backup
  • Sets up proper Flatpak permissions
  • Prevents permission corruption by refusing to run as root

Note: This script will fail if run with sudo to prevent home directory permission issues.


12. scripts/lazygit.sh - LazyGit Installer

Installs LazyGit CLI tool from a prebuilt binary.

Usage:

bash scripts/lazygit.sh

Requirements:

  • sudo privileges
  • LazyGit binary at arquivos/lazygit

Features:

  • Installs to /usr/local/bin/ for system-wide access
  • Uses prebuilt binary (no compilation needed)

13. scripts/snap-update.sh - Snap Package Updater

Updates all installed Snap packages.

Usage:

bash scripts/snap-update.sh

Requirements:

  • sudo privileges
  • snapd installed

Features:

  • Refreshes all installed snaps to latest versions

Student Attendance Management

14. lista-presença/gerar-lista-presenca.sh - Attendance List Generator

Generates attendance reports from a student list.

Usage:

cd lista-presença

# View student list with numbers
./gerar-lista-presenca.sh

# Generate attendance list for present students
./gerar-lista-presenca.sh 1 3 5 7

# Generate attendance list for absent students (reverse mode)
./gerar-lista-presenca.sh --reverse 2 4 6

Arguments:

  • <student-numbers>: Space-separated student line numbers
  • --reverse: Generate list of absent students instead of present

Input File:

  • alunos.txt - One student name per line

Output:

  • Lista de Presença <DD.MM>.txt - Generated attendance file with current date

Features:

  • Displays numbered student list without arguments
  • Supports normal mode (list present students)
  • Supports reverse mode (list absent students)
  • Automatically formats output filename with current date

Example:

# Input: alunos.txt
# 1    João Silva
# 2    Maria Santos
# 3    Carlos Costa

# Show all students
./gerar-lista-presenca.sh
# Output:
#      1  João Silva
#      2  Maria Santos
#      3  Carlos Costa

# Generate attendance for students 1 and 3
./gerar-lista-presenca.sh 1 3
# Creates: Lista de Presença 11.06.txt with João Silva and Carlos Costa

# Generate attendance for absent students (2)
./gerar-lista-presenca.sh --reverse 1 3
# Creates: Lista de Presença 11.06.txt with Maria Santos

Global Requirements Summary

Requirement Scripts Installation
ImageMagick converter-webp, gerar-favicon, gerar-og sudo apt install imagemagick
yt-dlp baixar-videos pip install yt-dlp or sudo apt install yt-dlp
Docker reset-container Official Docker installation guide
whisper.cpp transcrever Build from source (see script section)
ffmpeg transcrever sudo apt install ffmpeg
flatpak kate sudo apt install flatpak
unzip fira-code-nerd-font sudo apt install unzip
Standard tools Most scripts find, sed, date, bash (pre-installed)

Installation

  1. Clone or download this repository:
git clone https://github.com/carvdev/bash-scripts.git
cd bash-scripts
  1. Make scripts executable:
chmod +x *.sh
chmod +x ambiente-desenvolvimento/*.sh
chmod +x ambiente-desenvolvimento/scripts/*.sh
chmod +x lista-presença/*.sh
  1. Install required dependencies for scripts you'll use

  2. Run desired scripts


License

This project is licensed under the MIT License

Contributing

I do not expect for contribuitions in this repository, but feel free to do it, if you want.

About

A collection of my daily used Bash scripts, which include multimedia processing, development environment setup, and productivity tasks

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages