Skip to content

Instantly share code, notes, and snippets.

View primeapple's full-sized avatar

Toni Müller primeapple

View GitHub Profile
@primeapple
primeapple / vault_token_helper.sh
Last active February 28, 2025 10:06
Vault Token helper
#!/bin/bash
# Inspired by https://developer.hashicorp.com/vault/docs/commands/token-helper#example-token-helper
# Install via
# echo 'token_helper = "/absolute/path/to/vault_token_helper.sh"' >> "$HOME/vaulttest"
function write_error(){ >&2 echo "$@"; }
# Customize the hash key for tokens. Currently, we remove the strings
# 'https://', '.', and ':' from the passed Vault address
@primeapple
primeapple / abbreviations.fish
Created January 11, 2025 10:23
Fish abbreviations for default git branches, allows single abbreviation for `master` and `main`
for tuples in gc,'git checkout' gm,'git merge' grb,'git rebase'
echo $tuples | read -d , abb cmd
function _abbr_git_default_branch_$abb --inherit-variable cmd
if git rev-parse --verify main &> /dev/null
echo $cmd main
else
echo $cmd master
end
end
abbr --add $abb'm' --function _abbr_git_default_branch_$abb
@primeapple
primeapple / on-exit-sync.sh
Created January 14, 2023 21:40
Taskwarrior asynchonous sync on create/update/delete
#!/bin/sh
# This hooks script syncs task warrior to the configured task server.
# The on-exit event is triggered once, after all processing is complete.
# Make sure hooks are enabled
check_for_internet() {
# check for internet connectivity
nc -z 8.8.8.8 53 >/dev/null 2>&1
if [ $? != 0 ]; then