#!/bin/sh

genpassword() {
  length="${1-99}"
  tr -cd '[:alnum:]' < /dev/urandom | fold "-w$length" | head -n1 ||:
}

t() {
  expand   "$1" -t2 | sponge "$1"
}

ut() {
  unexpand "$1" -t2 | sponge "$1"
}

gvi() {
  if [ -e "$1" ]; then
    INIT="gpg -qd"
  else
    INIT="echo"
  fi
  $INIT "$1" | vipe | gpg -qer eu@euandre.org | sponge "$1"
}

disable_ci() {
  NAME="$(basename "$PWD")"
  rm -f ".git/hooks/$NAME/pre-push"
  ssh euandreh.xyz rm -f "/srv/git/$NAME.git/hooks/post-receive"
}
