Managing multiple AWS profiles in bash

Warning: I expect I’m going to want a little more control than this script provides shortly, because directory-level control of aws creds is probably not sufficient (if I want to deploy to dev/staging/prod, I’ll probably want different users to keep the environments completely isolated).  That will require some scripting, but for now, here’s what I’ve got.

  1. I’m going to use autoenv since I already use it for most of my development work anyway. Install that first
  2. AWS’s cli already supports the concept of profiles. Configure as desired
  3. Now, you can just drop a .env file in each directory with specific AWS credential needs, and include `AWS_DEFAULT_PROFILE=<your-profile>`


Ruptured Achilles – Some useful products post-op

I just had surgery to repair a completely ruptured Achilles tendon, and I thought I’d create some suggestions on how to get through post-op.

My surgeon wants my leg elevated over my heart 23hrs/day for the first two weeks, which is stricter than most, but his goal is to rapidly reduce swelling so I can begin rehab in just 2 weeks and avoid complications as well. So how to make those 2 weeks bearable?  Well I don’t know. This is only day 2. But here’s what I’ve got so far:

  1. AdapDeskadapdesk-ergoarc This thing is pretty slick. It’s the only device I found that could angle the laptop to the degree you see in the picture here. I’ve got it holding a macbook pro 15″. It works great for me, but be aware that the leg height is not adjustable (it’s all wood)  there is a metal tray that can screw on to the bottom of the device at 3 different heights, but critically you’ll want to make sure that you can type with your hands resting on the bed, or you’ll wind up exhausted. If it’s too high, you’ll probably want to get some kind of narrow prop for your elbows. Either that, or perhaps an external keyboard for your lap, if you’re a good enough touch typist to never look at it. I haven’t used the add-ons. Might try the cup holder for coffee tomorrow, but I just use the trackpad on my mac.
  2. camelbackSpill Proof Water Bottle w/ straw There are a lot of pills (antibiotics, pain meds, pro biotics etc), and I didn’t want to jeopardize all of my electronics with open glasses (especially with little kids around). This is large enough that it minimizes how much my wife has to dote on me as well. I already had a camelback.
  3. Contigo autoseal mugContigo AutoSeal Travel Coffee Mug Theoretically, you could put tea in here is well. Or something from one of those freeze-dried coffee-food makers. But if either of those is the case, just go away. You probably deserved your injury.
  4. iwalk 2.0iWalk2.0 For some reason, this doesn’t seem to have caught on. Even walking into the Rothman institute, it seemed that this was a novelty. But it’s a no-brainer purchase. Regular crutches, in addition to be bad for the nerves in your arm pit, and painful to use (because of the pinching, rather than any strength requirements), also don’t let you use your hands. You can go from Point A to Point B, but you can’t carry anything while you go, until you figure out how to use just 1 crutch. And even then, you’re basically hopping. With the iWalk, both of your hands are free, and there’s much basically no pain. There are a few negatives though.  a) it takes some work to set up initially (have help). b) Getting it on takes about 20 seconds. So it can be more trouble than its worth if you’re going a short distance. c) the strap behind your knee can dig in. d) if you have a partial cast, you’ll need to add some more padding to keep your knee level. e) You adjust it for height, but wearing a shoe on your good foot alters that height.  All that said, I could make breakfast, pick up my kids, walk for long distances (slowly) more easily go up stairs (down still stinks), and you’re an eye patch away from being a pirate.

Since it’s only day 2, I can’t give a meaningful recommendation about the elevation pillows I picked up. I’ll update those in a few days if they wind up being good purchases.  I’ve also got some adjustable dumb bells that I’m hoping I’ll be able to employ as well, but again, this is just day 2.

Logging to the console and a file from a Bash script


We’re going to provide a drop in script component that will allow you to log output (stdout and stderr) to a file, as well as the screen. In a follow-up, we’ll show how this can also be run through a filter so that your output could be timestamped. We’ll also put in some simple error handling to ensure the logging destination exists.

Script with log


Place this at the top of your script

exec &> >( tee "$LOGFILE" )


$LOGFILE=output.log ./

How it works

This is a pretty dense line. Here are the concepts:

exec &>

Redirects the stderr & stdout of the entire script. man exec `&>` is shorthand for redirecting both stderr and stdout.

>( ... )

The process (the command in parenthesis) receives its input from exec (stdin & stderr) Read more on Process Substitution


Tee is one of those rare bash commands with a name that actually makes sense. It reads from standard input, and writes it to standard output and files. It basically takes input from 1 place, and can write it to multiple output destination. man tee


Shell Parameter Expansion Shell parameter expansion doesn’t have to use {}, and in this case it shouldn’t matter, but it’s a best practice.  The quotes will make sure that file names with a space won’t break the logging

I’d like to call out Michael Hormer’s answer as being especially instructive as I was sorting this out.


How to (productively) use 15 minutes of time

all-waiting-at-airportI’ve got 2 little boys at home.  My wife and I enjoy spending a lot of time with them.  We’re also jumping into the real estate game, since that seems to be the way to achieve financial independence for our generation.  Adding to that a full time job and exercise, and my free time is in pretty short supply.
That doesn’t leave much room for my pre-family interests. Software development and entrepreneurship in my case. I’ve been struggling with how to keep those interests alive in some form. Here’s a little of what I’ve learned so far

First, the easy stuff:

Exercise & Sleep

Both of these are critical, and I’ll not regurgitate the endless amount of research that has proven it to be so. If you haven’t noticed how much smarter you are when you’re healthy and well-rested, then keep a diary for a month, and rate your productivity 1-10, and along side that, note how much sleep and exercise you got that day. That ought to be sufficient to prove this to you.

Yes, this cuts even further into the amount of time you have. I didn’t say it wasn’t tough. Just necessary. In addition to being stronger and with more endurance, you’ll be happier, smarter and have more will power than before. (Time permitting, I’ll see if I can find the various sources to cite.)

Seriously, exercise is probably the most powerful drug out there. Take it.

Time Management

When you’re dealing with small blocks of non-contiguous time, you must set realistic, specific goals.  Gone are the days where you can say: “This weekend, I’ll learn X”.  That’s frustrating, but you can focus more intensely when you know you only have a little time.

For me, the trick seems to be to slice my tasks to fit these meager time blocks.  Ruthlessly. If you have to scope your work down to 15 minute intervals (I can already hear my youngest starting to whine), you’ll probably find that you can’t just create your typical todo lists. For instance, I broke this blog post into 3 parts:

  1. Draft 1st post on 15 minutes slices, pt1
  2. Draft 1st post on 15 minutes slices, pt2
  3. Complete and publish 1st post on 15 minutes slices

This might seem excessive, but it’s really important.  It can be really easy to feel like you’re not making any progress.  Giving yourself these tiny deliverables, and then checking them off helps you in 2 ways:

  1. It makes you FEEL accomplished. The act of checking something off is powerful, and keeps you moving
  2. When you have a short period of time separated by hours or days from your last period, you can easily waste a lot of it trying to figure out what to do. Next thing you know, you’ve done nothing. Frustrating! Having the list of tasks that are SUPER focused ahead of time means that you’ve put a lot of the context of your problem / goal into your task list. So you can pick it up and go quicker.
  3. “You have 15 minutes to write this task: Go!”  There’s power in deadlines.  Impose them on yourself.  Force yourself to go faster than you’re comfortable going.  You’ll get more done.

Realize that small efforts every day are habit-forming.  Aristotle said: “We are what we repeatedly do. Excellence, then, is not an act, but a habit.”


© 2018 Jeff Deville

Theme by Anders NorenUp ↑