Skip to content

Instantly share code, notes, and snippets.

@rgm
Created October 25, 2023 16:58
Show Gist options
  • Save rgm/4d7dbd42fe95d5d4560ec288ddce172b to your computer and use it in GitHub Desktop.
Save rgm/4d7dbd42fe95d5d4560ec288ddce172b to your computer and use it in GitHub Desktop.
helper for overmind
#!/usr/bin/env bash
# travel upwards to find the nearest `.overmind.sock` so you can issue
# eg `ov r` or `ov c` from any subdir in a project, instead of having to
# cd up to where the Procfile is.
set -e
dnif () {
# https://stackoverflow.com/a/24642735
# Recursively list a file from PWD up the directory tree to root
local THERE=$PWD RC=2
while [[ $THERE != / ]]
do [[ -e $THERE/${2:-$1} ]] && { ls ${2:+$1} $THERE/${2:-$1}; RC=0; }
THERE=$(dirname $THERE)
done
[[ -e $THERE/${2:-$1} ]] && { ls ${2:+$1} /${2:-$1}; RC=0; }
return $RC
}
sock=$(dnif ".overmind.sock")
set -x
overmind $1 $2 -s $sock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment