This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ~/.bashrc - Update terminal title with current directory, last command, and hostname | |
| _mytitle_get_cmd() { | |
| local cmd="$1" | |
| # Strip leading whitespace | |
| cmd="${cmd#"${cmd%%[![:space:]]*}"}" | |
| # Discard leading environment variable assignments (e.g., FOO=bar BAZ=123 cmd) | |
| while [[ "$cmd" =~ ^[a-zA-Z_][a-zA-Z0-9_]*= ]]; do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # kk: File backup, move, and undo utility using .kk extension | |
| if [ "$1" = "-m" ]; then | |
| shift | |
| target="$1" | |
| if [ -z "$target" ]; then | |
| echo "Error: No file specified." >&2 | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/python | |
| # merge-pdfs.py - Concatenates PDFs and images in subdirectories, adding the relative path as a header | |
| import os | |
| import fitz # PyMuPDF | |
| def main(): | |
| root_dir = "." | |
| output_file = "merged-files.pdf" | |
| merged_pdf = fitz.open() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| IFS=':' read -ra ADDR <<< "$PATH"; (for dir in "${ADDR[@]}"; do [ -d "$dir" ] && ls -1 "$dir"; done) | sort -u | fzf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # backup.sh - Daily backup script with GFS retention policy | |
| SOURCE_DIR="/home/snowball/Trillian-bkp/home" | |
| BACKUP_DIR="/home/snowball/Trillian-bkp/archive" | |
| DATE=$(date +%Y-%m-%d) | |
| BACKUP_FILE="${BACKUP_DIR}/backup_${DATE}.tar.gz" | |
| mkdir -p "${BACKUP_DIR}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # search_projects.sh - Recursively search for git repos and small code directories, including inside archives. | |
| #!/bin/bash | |
| SEARCH_DIR="/mnt/externo" | |
| # Awk script to parse file paths, count files per directory, and detect targets | |
| AWK_SCRIPT=' | |
| { | |
| filepath = $0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _update_prompt() { | |
| local error=${GLOBAL_EXIT_CODE:-$?} | |
| local c | |
| local g | |
| if [ $error -eq 0 ]; then | |
| c="\[\e[1;92m\]🗹" | |
| else | |
| c="\[\e[1;31m\]🗵" | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| explain_current_line() { | |
| local tokens=($READLINE_LINE) | |
| local wrappers=("sudo" "su" "runuser" "chroot" "doas" "time" "watch" "timeout" "stdbuf" "nohup" "xargs" "exec" "env" "strace" "nice" "runcon" "setpriv" "bash" "sh") | |
| for token in "${tokens[@]}"; do | |
| if [[ "$token" == *"="* ]]; then continue; fi | |
| local is_wrapper=false | |
| for w in "${wrappers[@]}"; do | |
| [[ "$token" == "$w" ]] && is_wrapper=true && break |