Key/Value Pair in BASH!?


A few nights ago, I was watching some television, drinking a beer, and skimming some articles on managing one’s unix config files with Git. Most of the articles phone it in. They would get to creating a directory with your config files and symlinking them.

Creating those manually!? Ain’t nobody got time for that!

My beer buzzing brain figured I should roll up my sleeves and write a little something to manage that. While thinking about how this would look, I screwed up my face at the giant Case statement growing in my mind. Gotta be a better way…

Key/Value pairs. Perfect for this script. A google search hit on this stackoverflow article very succinctly explaining them. Have a quick read. Seriously, it’s quick.

Welcome back! There’s a ton more info on it in the BASH man page. If you search with

Associative arrays are created using declare -A

you’ll find the good part.

Getting back to my story, with my trusty “key/value pair” A.K.A. “associative array” I knocked together a little script to setup symlinking in my Git managed “config” directory. You can check it out here, if you are so inclined. Edit: April 2021 - Nope. Dead. I use stow now. It was suggested, getting a config file with the key/value pairs would be bad ass. Maybe I’ll get to it. Right now, I should get to a beer.