Skip to content

Instantly share code, notes, and snippets.

@atomicstack
atomicstack / print-figlet-fonts.sh
Last active January 30, 2022 04:45
print examples of every installed figlet font. nicer than showfigfonts as it uses --termwidth and --filter border
#!/bin/bash
for f in /usr/share/figlet/*; do
font_name=$(basename "$f" | awk -F '.' '{print $1}')
message=" $font_name "
banner=$(toilet --filter border --font $font_name --termwidth "$message" 2>/dev/null)
[[ -z "$banner" ]] && continue
echo -e "$font_name:\n$banner\n"
done
lepton ~/bash_perl  zmodload zsh/sched
lepton ~/bash_perl  sched --help
lepton ~/bash_perl  sched
lepton ~/bash_perl  echo $zsh_scheduled_events
lepton ~/bash_perl  sched -o +10 echo hello world
lepton ~/bash_perl  echo $zsh_scheduled_events
1640831449:-o:echo hello world
lepton ~/bash_perl 
lepton ~/bash_perl  echo $zsh_scheduled_events
https://github.com/atomicstack/setup-scripts/blob/main/rebuild-tmux.sh
@atomicstack
atomicstack / VolumeUp.scpt
Last active August 28, 2021 22:25
AppleScript one-liner to increase volume by 10%, for use with Stream Deck and OSA script plugin (Note: app restart required after any script update in the Stream Deck configurator, see https://github.com/gabrielperales/streamdeck-osascript/issues/2)
set volume output volume ((get output volume in (get volume settings)) + 10)
@atomicstack
atomicstack / prune-invalid-git-refs.sh
Created July 19, 2021 13:24
fixes annoying "error: refs/remotes/origin/${branch_name} does not point to a valid object!"
#!/bin/bash
git for-each-ref --format="%(refname)" | while read ref; do
git show-ref --quiet --verify $ref 2>/dev/null || git update-ref -d $ref
done
@atomicstack
atomicstack / ssh_config
Last active June 15, 2021 11:44
example Match stanza for ssh_config, which executes echo "hello world" before connecting to a (specific) host as a specific username. note: redirection to STDERR is necessary; using STDOUT will result in no output
Match host $HOSTNAME exec "echo 'hello world' 1>&2"
User $USERNAME
@atomicstack
atomicstack / root_ps1.zsh
Created June 14, 2021 12:11
zsh root PS1
export PS1='%F{226}%m%f %F{33}%d%f %F{160}%#%f '
@atomicstack
atomicstack / cleanup_zsh_history_archive.sh
Created June 4, 2021 12:20
cleans up duplicate zsh_history files from $PWD (double check paths before use!)
ls | egrep --line-buffered 'zsh_history.*xz$' | xargs sha256sum | pv -l -s $( ls | egrep --line-buffered 'zsh_history.*xz$' | wc -l | xargs ) | /usr/local/bin/sponge | perl -naE '$seen{$F[0]}++ or next; unlink $F[1] and say qq{unlinked $F[1]}'
@atomicstack
atomicstack / backup_zsh_history.sh
Last active June 4, 2021 12:21
back up my zsh history (via crontab) (double check paths before use!)
/bin/cat $HOME/.zsh_history | /usr/local/bin/xz > $HOME/.zsh_history.d/zsh_history.$(/usr/local/bin/gdate +%F-%T).xz
@atomicstack
atomicstack / ssh_warning.sh
Created June 2, 2021 21:37
a zsh thing to run at login time and check whether the user has an ssh-agent
red=$(tput setaf 1)
reset=$(tput sgr0)
if [[ -n "${SSH_TTY}" || -n "${TTY}" ]]; then
if [[ $UID == 0 ]]; then
return
fi
if [[ -z "$SSH_AUTH_SOCK" || ! -S "$SSH_AUTH_SOCK" ]]; then
echo -e "${red}no ssh-agent found :(${reset}"
elif ssh-add -l | grep -q "no identities"; then