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 / 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`
@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 / check-systemd-service.sh
Last active January 19, 2018 19:37
Script to be remotely invoked by nagios that returns a service's status and can trigger an alarm when down or failed
#!/bin/bash
## Checks a systemd controlled service for status and start failures
SVC_NAME='servicename'
COUNT_FILE='/tmp/checkservice.counter'
# load counter from previous checks
[ -f $COUNT_FILE ] && { COUNT=`cat $COUNT_FILE` ; } || { COUNT=0 ; }
@erincerys
erincerys / xmr-mining-scheduler.sh
Last active October 11, 2017 21:41
Schedule CPU utilization of your cryptocurrency miner around your personal computer use patterns
#!/bin/bash
#
# usage: $0 <cpu-threads>
#
# i use this script to schedule times of day when my computer is not in use can max out cpu on the miner
#
# example cron entries:
# 00 06 * * * /path/to/xmr-mining-scheduler.sh 3
# 00 23 * * * /path/to/xmr-mining-scheduler.sh 4