Posts tagged: bash

All posts with the tag "bash"

31 posts latest post 2025-11-26
Publishing rhythm
Nov 2025 | 1 posts

Vaulted Secrets Without Git Churn

Ansible Vault keeps secrets out of sight, but the ciphertext changes on every encrypt. That turns Git diffs into noise and makes it hard to tell if anything actually changed. Decrypting, editing, and re-encrypting often leaves uncertainty about whether any plaintext changed. This is amplified when secret repos are tightly coupled to dependent repositories. A typical cycle includes decrypting, adding a key, updating a value, applying changes, and returning later with little clarity about what changed while secrets were in plaintext.

Today a new workflow was created with @gpt-5.2-codex to keep diffs clean and avoid re-encrypting when the plaintext is identical.

Re-encrypting a file with the same content produces different ciphertext. A simple decrypt/encrypt cycle can look...

...

setting COLUMNS env var to a number greater than 0 will make the terminal resize to that number of columns.

COLUMNS=80 uvx --from rich-cli rich myscript.py

I discovered this when I was trying to make a low effort readme generated from the code, but did not depend on the size of terminal it was ran on.

Today I learned how to use tar over ssh to save hours in file transfers. I keep all of my projects in ~/git (very creative I know, I’ve done it for years and haven’t changed). I just swapped out my main desktop from bazzite to hyprland, and wanted to get all of my projects back. Before killing my bazzite install I moved everything over (16GB of many small files), it took over 14 hours, maybe longer. I had started in the morning and just let it churn.

This was not going to happen for re-seeding all of my projects on my new system, I knew there had to be a better way, I looked at rsync, but for seeding I ran into this tar over ssh technique and it only took me 6m51s to pull all of my projects off of my remote server.

big fan of eza and dust, I like these aliases to have some common commands at my fingertips. I often use the tree command and yes it sometimes goes too deep to actually be useful.

I am a linux user through and through. Desktop, server, vms, containers, everything except my phone is linux. With this I spend a lot of time in the terminal, and have been a long time user of !! to rerun the last command, but with the ability to tack something on at the beginning or end.

TIL about fc, which opens the last command in your shell history in your $EDITOR or pass in your editor -e nvim.

man fc

!! pronounces bang bang and will run the last command in your history.

...

You can unset multiple environment variables at once. I did not know this was a thing, its something that ended up happening organically on a call and asking someone to run unset. They had never done it before and did not know how it works, but did exactly as I said instead of what I meant. I like this handy shortcut doing it in one line rather than each one individually, I will be using this in the future. You might need this for something like running aws cli commands with localstack.

I found this nugget in thechangelogs justfile, it lets you add color to your justfile with variables quite easily.

# https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/ _BOLD := "$(tput bold)" _RESET := "$(tput sgr0)" _BLACK := "$(tput bold)$(tput setaf 0)" _RED := "$(tput bold)$(tput setaf 1)" _GREEN := "$(tput bold)$(tput setaf 2)" _YELLOW := "$(tput bold)$(tput setaf 3)" _BLUE := "$(tput bold)$(tput setaf 4)" _MAGENTA := "$(tput bold)$(tput setaf 5)" _CYAN := "$(tput bold)$(tput setaf 6)" _WHITE := "$(tput bold)$(tput setaf 7)" _BLACKB := "$(tput bold)$(tput setab 0)" _REDB := "$(tput setab 1)$(tput setaf 0)" _GREENB := "$(tput setab 2)$(tput setaf 0)" _YELLOWB := "$(tput setab 3)$(tput setaf 0)" _BLUEB := "$(tput setab 4)$(tput setaf 0)" _MAGENTAB := "$(tput setab 5)$(tput setaf 0)" _CYANB := "$(tput setab 6)$(tput setaf 0)" _WHITEB := "$(tput setab 7)$(tput setaf 0)"

Usage

Today I discovered the Urllink function in bash from the ujust tool from ublue.it. Seems like a cool trick, but might not work everywhere.

I’ve had a couple of uploads to twitter fail recently and has been a pain. I tried some online converters for convenience, but none of them worked. I reached out to chatgpt and found succeess with this ffmpeg command.

Authentication from cli tools can be a bit of a bear, and I have to look it up every time. This is my reference guide for future me to remember how to easily do it.

I set up a fastapi server running on port 8000, it uses a basic auth with waylonwalker as the username and asdf as the password. The server follows along with what comes out of the docs. I have it setup to take basic auth, form username and password, or a bearer token for authentication.

The og of command line url tools.

# basic auth curl -u 'waylonwalker:asdf' -X POST localhost:8000/token # basic auth with password prompt curl -u 'waylonwalker' -X POST localhost:8000/token # token curl -H 'Authorization: bearer...

...

jpillora/installer is the install script generator I have been looking for. It downloads binaries for your machine from GitHub releases and unzips them for you. It grabs the latest release, so you can easily update them. I have tried scripting these installs in the past and struggled to consistently get the latest version for every package and unpack it correctly.

Also these pre-compiled binaries install rediculously fast compared to building them from source.

Check out some example links.

opening in a browser will show metadata

...

Give github actions the -e flag in the shebang #! so they fail on any one command failure. Otherwise each line will set the exit status, but only the last one will be passed to ci.

#!/bin/bash -e

What is -e #

The -e flag to the bash command allows your script to exit immediately if any command within the script returns a non-zero exit status. This can be useful for ensuring that your script exits with an error if any of the commands it runs fail, which can help you identify and debug issues in your script. For example, if you have a script that runs several commands and one of those commands fails, the script will continue running without the -e flag, but will exit immediately if the -e flag is present. This can make it easier to troubleshoot your script and ensure that it runs correctly.

In windows the solution is not quite as simple. You can define a function in a Windows batch script that wraps an if statement to check the exit status of a command and handle any errors that may have occurred. Here is an example of how you might define a function called “check_error”...

...

I am often editing my own scripts as I develop them. I want to make a better workflow for working with scripts like this.

Currently I am combining nvim with a which subshell to etit these files like this.

for now lets use my todo command as an example

nvim `which todo`

First pass #

On first pass I made a bash function to do exactly what I have been doing.

...

This morning I was trying to install a modpack on my minecraft server after getting a zip file, and its quite painful when I unzip everything in the current directory rather than the directory it belongs in.

So I’ve been struggling to get mods installed on linux lately and the easiest way to download the entire pack rather than each mod one by one seems to be to use the overwolf application on windows. Once I have the modpack I can start myself a small mod-server by zipping it, putting it in a mod-server directory and running a python http.server

python -m http.server

Downoading on the server #

Then I go back to my server and download the modpack with wget.

wget 10.0.0.171:8000/One%2BBlock%2BServer%2BPack-1.4.zip

Unzip to the minecraft-data directory #

Now I can unzip my mods into the minecraft-data directory.

...

There is GNU coreutils command called mktemp that is super handy in shell scripts to make temporary landing spots for files so that they never clash with another instance, and will automatically get cleaned up when you restart, or whenever /tmp gets wiped. I’m not sure when that is, but I don’t expect it to be long.

Here are some examples of making temp directories in different places, my favorite is mktemp -dt mytemp-XXXXXX.

# makes a temporary directory in /tmp/ with the defaul template tmp.XXXXXXXXXX mktemp # makes a temporary directory in your current directory mktemp --directory mytemp-XXXXXX # shorter version mktemp -d mytemp-XXXXXX # same thing, but makes a file mktemp mytemp-XXXXXX # makes a temporary directory in your /tmp/ directory (or what ever you have configured as your TMPDIR) mktemp --directory --tmpdir mytemp-XXXXXX # shorter version mktemp -dt mytemp-XXXXXX # same thing, but makes a file mktemp --tmpdir mytemp-XXXXXX # shorter version mktemp -t mytemp-XXXXXX

Use Case #

Here is a sample script that shows how to capture the tempdir as...

...

Reading eventbridge rules from the command line can be a total drag, pipe it into visidata to make it a breeze.

I just love when I start thinking through how to parse a bunch of json at the command line, maybe building out my own custom cli, then the solution is as simple as piping it into visidata. Which is a fantastic tui application that had a ton of vim-like keybindings and data features.