Skip to content

Instantly share code, notes, and snippets.

View tj-smith47's full-sized avatar
🏠
Working from home

TJ Smith tj-smith47

🏠
Working from home
  • Salesloft
  • Remote (US)
  • 19:07 (UTC -07:00)
View GitHub Profile
@tj-smith47
tj-smith47 / yqi.sh
Last active April 2, 2025 17:38
yqi | retain newlines & list indentation with `yq e -i`
get_yamlfmt_config() {
# $1 == file
cat <<EOF
formatter:
indentless_arrays: $(
first_list=$(grep -m 1 -B 1 '^ .* -' $1)
# If the first entry whitespace is not in (or is larger than) the list name whitespace - it's indented.
if ! grep -q "$(tail -n 1 <<<"$first_list" | cut -d'-' -f 1)" <<<"$(head -n 1 <<<"$first_list")"; then
echo "false"
else