From 94ac5d4ac7fa4820ba27065cdad9f1db174fca07 Mon Sep 17 00:00:00 2001 From: Maciej Bator Date: Tue, 13 Jan 2026 12:32:50 +0100 Subject: [PATCH] 100% vibecoded initial commit --- .gitignore | 16 ++++++ LICENSE | 21 ++++++++ Makefile | 15 ++++++ PKGBUILD | 18 +++++++ README.md | 75 +++++++++++++++++++++++++++ čd | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 294 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 PKGBUILD create mode 100644 README.md create mode 100755 čd diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a85932 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Editor files +*~ +*.swp +*.swo +.idea/ + +# AUR build files +*.tar.gz +*.tar.xz +pkg/ +src/ +*.pkg.tar.* + +# Build artifacts +*.o +*.a diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..818126f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 mab122 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fddb7b8 --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +PREFIX ?= /usr/local +BINDIR = $(PREFIX)/bin + +.PHONY: install uninstall + +install: + @echo "Installing čd to $(BINDIR)..." + @mkdir -p $(BINDIR) + @install -m 755 čd $(BINDIR)/čd + @echo "Installation complete! Run 'čd' to see the motorak." + +uninstall: + @echo "Removing čd from $(BINDIR)..." + @rm -f $(BINDIR)/čd + @echo "Uninstallation complete." diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..8a33e1b --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,18 @@ +# Maintainer: mab122 maciek+ceskadraha@mbator.pl +pkgname=cd-ceskadraha +pkgver=1.0.0 +pkgrel=1 +pkgdesc="A fun terminal animation of a Czech Railways motorak - Czech version of sl" +arch=('any') +url="https://github.com/mab122/ceskadraha" +license=('MIT') +depends=('bash' 'ncurses') +source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz") +sha256sums=('SKIP') # Update this after creating the first release + +package() { + cd "${srcdir}/ceskadraha-${pkgver}" + + # Install the script + install -Dm755 čd "${pkgdir}/usr/bin/čd" +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..55ccc5f --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# čd (České dráhy) + +A fun terminal animation of a Czech Railways motorak (railcar) - the Czech version of the classic `sl` command. + +``` + ___ + | |___ + _____________ |___|___| _______________ + | ___ ___ |=|_________|==|___ ___ | + | | | | || O O | | | | | | + |_|___|__|___||___\_____/___|__|__|__|___|__| + \_O_/ \_O_/ \_______/ \_O_/ \_O_/ + + České dráhy - Motorák 810 +``` + +Inspired by the legendary `sl` command, but featuring the iconic ČD Class 810/810.0 "Orchestrion" motorak. + +## Installation + +### From AUR (Arch Linux) + +```bash +yay -S cd-czechrailways +# or +paru -S cd-czechrailways +``` + +### Manual Installation + +```bash +git clone https://github.com/YOUR_USERNAME/ceskadráha.git +cd ceskadráha +sudo make install +``` + +### Manual (without make) + +```bash +sudo cp čd /usr/local/bin/ +sudo chmod +x /usr/local/bin/čd +``` + +## Usage + +```bash +čd # Run the animation (left to right) +čd -r # Run in reverse (right to left) +čd -h # Show help +``` + +## Features + +- Animated Czech Railways Class 810 motorak +- Reverse direction support +- Animated exhaust/smoke +- Terminal width aware +- Thank you message in Czech: "Děkujeme, že jste cestovali s Českými drahami!" + +## Why? + +Just like the original `sl` command was created to punish users who mistype `ls`, this is for Czech railway enthusiasts who want a bit of fun in their terminal. Or maybe you just really like Czech motoráks. + +## Requirements + +- Bash +- `tput` command (usually part of ncurses) + +## License + +MIT License - See LICENSE file for details + +## Credits + +Inspired by the classic `sl` (Steam Locomotive) command by Toyoda Masashi. diff --git a/čd b/čd new file mode 100755 index 0000000..f44f39a --- /dev/null +++ b/čd @@ -0,0 +1,149 @@ +#!/bin/bash + +# čd - Czech motorak animation (Czech Railways version of sl) +# Usage: čd [options] + +# Parse options +DELAY=0.03 +REVERSE=0 + +while getopts "hr" opt; do + case $opt in + h) + echo "čd - Czech motorak animation" + echo "Usage: čd [-h] [-r]" + echo " -h Show this help" + echo " -r Reverse direction" + exit 0 + ;; + r) + REVERSE=1 + ;; + esac +done + +# Get terminal width +COLS=$(tput cols) + +# Czech motorak (ČD Class 810/810.0 "Orchestrion") +MOTORAK=( +" " +" ___ " +" | |___ " +" _____________ |___|___| _______________ " +" | ___ ___ |=|_________|==|___ ___ | " +" | | | | || O O | | | | | | " +" |_|___|__|___||___\_____/___|__|__|__|___|__| " +" \_O_/ \_O_/ \_______/ \_O_/ \_O_/ " +" " +" České dráhy - Motorák 810 " +) + +# Smoke/exhaust variants +EXHAUST1=( +" ( ) ( ) " +" ( ) " +" ( ) ( ) " +) + +EXHAUST2=( +" ( ) ( ) " +" ( ) " +" ( ) ( ) " +) + +# Reverse the motorak if needed +if [ $REVERSE -eq 1 ]; then + # Flip the motorak horizontally + NEW_MOTORAK=() + for line in "${MOTORAK[@]}"; do + reversed=$(echo "$line" | rev) + NEW_MOTORAK+=("$reversed") + done + MOTORAK=("${NEW_MOTORAK[@]}") +fi + +# Animation function +animate() { + local position=$1 + local use_exhaust1=$2 + + # Move cursor to home position + tput cup 0 0 + + # Determine which exhaust to use + local exhaust + if [ $use_exhaust1 -eq 1 ]; then + exhaust=("${EXHAUST1[@]}") + else + exhaust=("${EXHAUST2[@]}") + fi + + # Print exhaust lines + for line in "${exhaust[@]}"; do + if [ $REVERSE -eq 0 ]; then + # Left to right + printf "%${position}s%s" "" "$line" + tput el # Clear to end of line + echo + else + # Right to left + local spaces=$(($COLS - $position - ${#line})) + if [ $spaces -gt 0 ]; then + printf "%${spaces}s%s" "" "$line" + fi + tput el + echo + fi + done + + # Print motorak lines + for line in "${MOTORAK[@]}"; do + if [ $REVERSE -eq 0 ]; then + # Left to right + printf "%${position}s%s" "" "$line" + tput el # Clear to end of line + echo + else + # Right to left + local spaces=$(($COLS - $position - ${#line})) + if [ $spaces -gt 0 ]; then + printf "%${spaces}s%s" "" "$line" + fi + tput el + echo + fi + done +} + +# Main animation loop +# Clear screen and hide cursor +clear +tput civis + +if [ $REVERSE -eq 0 ]; then + # Left to right + for ((pos=0; pos<=$COLS+60; pos++)); do + if [ $((pos % 2)) -eq 0 ]; then + animate $pos 1 + else + animate $pos 0 + fi + sleep $DELAY + done +else + # Right to left + for ((pos=$COLS+60; pos>=0; pos--)); do + if [ $((pos % 2)) -eq 0 ]; then + animate $pos 1 + else + animate $pos 0 + fi + sleep $DELAY + done +fi + +# Show cursor and clear +tput cnorm +clear +echo "Děkujeme, že jste cestovali s Českými drahami! 🚃"