Posts tagged: cli

All posts with the tag "cli"

25 posts latest post 2025-06-17
Publishing rhythm
Jun 2025 | 1 posts

TLDR

I have a use case for nesting directories with cascading .envrc files. and ran into an issue where the parent environment was being reset by the child environment. The fix is source_up

Context

I manage some infrastructure at home with a folder like this:

.
├── homelab
│   ├── .envrc
│   └── stack1
│       ├── .envrc

I do this so that the “homelab-wide” terraform variables can be exported with TF_VAR_the_variable in the homelab/.envrc and then the stack specific variables in stack1/.envrc get exported like TF_VAR_stack_specific_var.

For example, my cloudflare account id is needed in every stack, but the cloudflare zone id is different per stack - so instead of copying the account id var to every stack (however the vars are managed), I can set it in a parent .envrc and share it in nested stack directories

Problem #

# homelab/.envrc
#!/bin/bash
export VAR_FOO=BAR

So when I cd homelab I get

nic in /tmp/homelab   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ direnv allow
direnv: loading /tmp/homelab/.envrc
direnv: export +VAR_FOO

nic in /tmp/homelab   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ env | grep VAR
VAR_FOO=BAR

You can see VAR_FOO is set… but now I’ll cd stack1

nic in /tmp/homelab   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ cd stack1
direnv: error /tmp/homelab/stack1/.envrc is blocked. Run `direnv allow` to approve its content

nic in /tmp/homelab/stack1   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ direnv allow
direnv: loading /tmp/homelab/stack1/.envrc
direnv: export +VAR_BAZ

nic in /tmp/homelab/stack1   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ env | grep VAR
VAR_BAZ=BAM

As you can see VAR_FOO was unset, and VAR_BAZ is set… so homelab/.envrc was blown away!

Fix #

Edit stack1/.envrc with a source_up command

# stack1/.envrc # NEW
#!/bin/bash
source_up  # source the parent environment
export VAR_BAZ=BAM

After the edit

nic in /tmp/homelab/stack1   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ vim .envrc
direnv: error /tmp/homelab/stack1/.envrc is blocked. Run `direnv allow` to approve its content

nic in /tmp/homelab/stack1   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET  took 5s
⬢ [devbox] ❯ direnv allow
direnv: loading /tmp/homelab/stack1/.envrc
direnv: loading /tmp/homelab/.envrc
direnv: export +VAR_BAZ +VAR_FOO

nic in /tmp/homelab/stack1   (dev) 󰒄 󱔎 NO PYTHON ENVIORNMENT SET
⬢ [devbox] ❯ env | grep VAR
VAR_FOO=BAR
VAR_BAZ=BAM

Both vars are set!

I was wrecked by a weird combo of » and -e

TL;DR # If state matters then check it in the beginning or handle it on a failure… Let me explain I ran into some trouble recently almost losing some encrypted data… Now this would be the second time I’ve had that happen, so I’m going to write a little bit about it now that I figured it out The Stage # Here’s the scenario - I use to keep some sensitive data in a few public repos, and I keep the keys I use in Bitwarden Secrets Manager. I use as a command runner and have common and recipes throughout many justfiles. It might look something like this Spoiler # Above is a good example of the 2 recipes, but prior to this morning they looked like this Problem # So here’s the story - in real life I started using distrobox when I ran into this and I thought it was an issue with different versions of ansible installed in distrobox and on my desktop. After a few more odd deployment workflows I think I’ve determined that the real problem is that appends to a file (see the issue yet?), but if my r…

I am moving a hefty amount of data to a new ZFS pool due to some corruption and I want to avoid using zfs send/recv for this just to make sure I don’t propagate any corrupted data to my new pool.

I’ve used rsync for simple things before but I needed this to be a little smarter and I wanted to see simple progress without flooding my terminal with a billion filenames.

TLDR #

TLDR: rsync -aHAX --chmod=Da+s --info=progress2 --inplace --exclude='encrypted/docker/frigate-media' /tank/ /harbor/

Explanation #

-aHAX: Preserves attributes (archive mode, hard links, ACLs, extended attributes). –chmod=Da+s: Ensures the setgid bit is applied to directories. –info=progress2: Provides detailed progress information, including overall data transfer stats. –inplace: Writes directly to the destination file, avoiding temporary files (useful for large files). –exclude=‘encrypted/docker/frigate-media’: Excludes the specified path (relative to the /tank root). /tank/ /harbor/: Ensures the contents of /tank are copied directly into /harbor.

hostnamectl is apparently a linux utility for easily changing your hostname in a variety of ways


❯ hostnamectl --help
hostnamectl [OPTIONS...] COMMAND ...

Query or change system hostname.

Commands:
  status                 Show current hostname settings
  hostname [NAME]        Get/set system hostname
  icon-name [NAME]       Get/set icon name for host
  chassis [NAME]         Get/set chassis type for host
  deployment [NAME]      Get/set deployment environment for host
  location [NAME]        Get/set location for host

Options:
  -h --help              Show this help
     --version           Show package version
     --no-ask-password   Do not prompt for password
  -H --host=[USER@]HOST  Operate on remote host
  -M --machine=CONTAINER Operate on local container
     --transient         Only set transient hostname
     --static            Only set static hostname
     --pretty            Only set pretty hostname
     --json=pretty|short|off
                         Generate JSON output

See the hostnamectl(1) man page for details.

I learned there’s transient and static hostnames, so that’s cool…

The thing I needed was hostnamectl --static hostname babyblue-aurora

pretty sweet tool

Plasma shits the bed a little too often on Fedora for me right now but I finally have a quick fix…


sudo killall plasmashell

kstart plasmashell

To customize k9s use the skins from catppuccin or the ones k9s supplies

OUT="${XDG_CONFIG_HOME:-$HOME/.config}/k9s/skins"
mkdir -p "$OUT"
curl -L https://github.com/catppuccin/k9s/archive/main.tar.gz | tar xz -C "$OUT" --strip-components=2 k9s-main/dist

Then edit your k9s config

# ~/.config/k9s/config.yml
k9s:
  ui:
    skin: catppuccin-mocha
    # ...or another flavor:
    # skin: catppuccin-macchiato
    # skin: catppuccin-frappe
    # skin: catppuccin-latte

    # ...or the transparent variants:
    # skin: catppuccin-mocha-transparent
    # skin: catppuccin-macchiato-transparent
    # skin: catppuccin-frappe-transparent
    # skin: catppuccin-latte-transparent

Other k9s skins are available here

I started deploying a website to Cloudflare on a branch called pages. Similar to one of the GH Pages deployment patterns. But when my CI was pushing the branch I couldn’t see it locally…

git fetch -a wasn’t pulling any new branches, and git branch -a was only showing my development and main branches at the remote… so what gives?

I checked my git config, and to this moment I have no idea how this happened but check out my fetch config:

git config --get remote.origin.fetch
+refs/tags/*:refs/tags/*

So to fix this:

git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

Now git fetch -a works again

> git fetch -a

From github.com:DigitalHarbor7/DigitalHarbor
   357a28a..969b027  develop    -> origin/develop
   c052ac9..6d40210  main       -> origin/main
 * [new branch]      pages      -> origin/pages

git config –add –local core.sshCommand ‘ssh -i «<PATH_TO_SSH_KEY»>’

I’ve been using paperless-ngx to manage all my documents, but every once in a while I’ll get a .docx file to deal with…

Turns out Libreoffice has a headless mode a pdf converter built-in!

libreoffice --headless --convert-to pdf /path/to/file.docx --outdir /path/to/output/directory

Note that --outdir is in fact a directory, not the path to a file