Skip to content

Instantly share code, notes, and snippets.

@erincerys
erincerys / better-ls.sh
Created June 18, 2026 13:31
Overrided la defaults to output long-ISO timestamps, color, and puts directories first. Fork of better-ls.sh in andresgongora/synth-shell.
#!/usr/bin/env bash
# Source: https://github.com/andresgongora/synth-shell/blob/master/synth-shell/better-ls.sh
## +-----------------------------------+-----------------------------------+
## | |
## | Copyright (c) 2018-2020, Andres Gongora <mail@andresgongora.com>. |
## | |
## | This program is free software: you can redistribute it and/or modify |
@erincerys
erincerys / better-eza.sh
Last active June 18, 2026 13:29
Overrided eza defaults to output long-ISO timestamps, color, and puts directories first. Fork of better-ls.sh in andresgongora/synth-shell.
#!/usr/bin/env bash
## +-----------------------------------+-----------------------------------+
## | |
## | Copyright (c) 2018-2020, Andres Gongora <mail@andresgongora.com>. |
## | |
## | This program is free software: you can redistribute it and/or modify |
## | it under the terms of the GNU General Public License as published by |
## | the Free Software Foundation, either version 3 of the License, or |
## | (at your option) any later version. |
@erincerys
erincerys / fixPacman.sh
Created December 1, 2025 10:02
Unbork pacman - correct time, update certificates, refresh keyring, reduce package cache, upgrade pacman and AUR helper
#!/bin/bash
function updateSystemClock() {
# timedatectl timesync-status; echo
_log stdout 'Synchronizing clock'
sudo systemctl restart systemd-timesyncd || return 1
sleep 2; echo
# systemctl status systemd-timesyncd; echo
journalctl --lines=1 -xru systemd-timesyncd; echo
}
@erincerys
erincerys / kill-locks.sh
Last active October 6, 2025 12:08
Kill processes holding locks on a given file path by progressively issuing higher severity signals for each PID.
#!/bin/bash
# shellcheck disable=SC2086
#
# DESCRIPTION:
# 'safely' kill processes holding file locks for a file path
# useful for managing mountpoints with user session state changes
#
# USAGE:
# $0 <file-path>
@erincerys
erincerys / safe-kill.sh
Created October 5, 2025 13:58
Issues progressively more severe kill signals to one or more PIDs
#!/bin/bash
test -z "$1" && exit 1
declare -a _PGREP; _PGREP+=('pgrep')
test ${#1} > 15 && _PGREP+=('--full')
_PGREP+=('--ignore-ancestors' "$1")
mapfile -t _PIDS < <("${_PGREP[@]}")
test ${#_PIDS[@]} = 0 && exit 1
_SIGNALS=(15 1 3 6 9)
@erincerys
erincerys / git-pull-recursively.sh
Created October 5, 2025 13:55
Recursively traverses directories to update Git repositories from remote
#!/bin/bash
#
# DESCRIPTION:
# iterates through a directory and its subdirectories
# updating any git repositories from remote
#
set +e
for d in *; do
@erincerys
erincerys / migration-irssi-logs.sh
Created August 8, 2017 04:05
Merge irssi log directories, deleting small files
#!/bin/bash
# migrate.sh
# DESCRIPTION: Parse two directories of logfiles.
# FUNCTION: Append new files with old ones, delete files that are small, and move new files that aren't present to the old directory.
# USAGE: bash migrate.sh /path/to/old_logdir /path/to/new_logdir
# ELABORATION:
# Settings
minlines=15 # Threshhold number of lines to delete a logfile
@erincerys
erincerys / create-memtest-usb.sh
Created December 21, 2015 00:39
Prepare a USB flash drive with syslinux and memtest86+ for RAM testing
#!/bin/bash
# Install dependencies for creating filesystem and installing bootloader
## This script is mostly system-independent, except for this part. Replace yaourt and the args with your own package manager
yaourt -S --noconfirm mtools syslinux dosfstools
# Plug in the flash drive, and find its device. Don't mount it.
lsblk
while [[ $(echo $FLASHDEV | grep -c \/dev\/sd[a-z]) -lt 1 && -b "$FLASHDEV" ]] ; do
read -p 'Which device (e.g. /dev/sdf)? ' FLASHDEV
@erincerys
erincerys / restic-b2-cronjob.sh
Last active February 2, 2020 16:15
Backup given sources via restic to B2 at regularity using SNS to notify of result
#!/bin/bash
# Requires:
# - restic (system package)
# - AWS account with SNS topic configured and API keys created
# - awscli (pip) with API keys configured (aws configure)
# - Backblaze B2 account with API keys
# - cron implementation (system package)
ResticBinaryPath=`which restic`
@erincerys
erincerys / s3-b2-cronjob.sh
Created February 2, 2020 16:13
Backup given sources via restic to AWS S3 at regularity using AWS SNS to notify of result
#!/bin/bash
# Requires:
# - restic (system package)
# - AWS account with SNS topic configured, S3 bucket created, and API keys created
# - awscli (pip) with API keys configured (aws configure)
# - cron implementation (system package)
ResticBinaryPath=`which restic`
AwsCliBinaryPath=`which aws`