Bash

Bash: Using '$_' and '$1' to Manage Repetitive Command Line Tasks

A few examples of how you can recycle arguments in Bash commands using the '$_' and '$1' shorthand aliases. This is a great way to save time and keystrokes when working in Bash

Background: Just Too Many Keystrokes

The more time you spend on the command line, the more you realize much of your time there is occupied by typing out the same thing (i.e., a filename, or certain command) over and over. Bash shines in its ability to take long complicated commands and store them in aliases. No matter how many aliases you create, though, you'll still need to dedicate a little brain power to your command line surfing. Sometimes, aliases just don't apply.

Bash: Interactive Script to Bring Window to Front or Open App

Ever find yourself rotating between multiple applications within the same single workflow? For me, I like to call it the holy trinity: VS Code, GitKraken and Firefox. When I'm working on a site, I'll inevitably spend almost as much time cycling from one of these applications to the other as I do writing code. I finally got so sick and tired of this that I decided to write a little Bash script to make rotating between applications just a little less cumbersome. Since VS Code has a terminal emulator, I can run the script from there to jump quickly to the next application(s) in my workflow.

Background: Multitasking Wears You Down!

Web development is a conglomeration of tasks; there's really no way around it. Having two monitors is a good way to get a bird's-eye view of everything going on within your workflow. If you like to maximize your windows, though, you're only ever going to get two applications to work with at any given time. On an average day, I'll have roughly 3 Firefox windows, a terminal, VS Code (with its own terminal emulator), GitKraken, Koala (SASS compiler) and maybe Virtual Box--all open at the same time.

Bash: Automate Verbose Error Loggin in Drupal

Turning on verbose error logging in Drupal is an important tool for diagnosing any number of problems. Unless you have the PHP syntax memorized, though, it's a bit of a pain to enable. Even if you keep the $config line commented out in your settings.php file, opening a file editor every time you need to turn it on can also be a pain. Here's a short Bash script that will automatically edit your settings.php file and turn on verbose error logging..

I have a real knack for hitting the WSOD on my localhost--usually when juggling databases and code in between remote and local. As a result, I like to keep verbose error logging commented out in my settings.php. It's generally the last line in the file, somewhere after the $databases array. For privacy reasons I won't screen grab the actual file, but the commented line (for both D8 and D9) should be this:

Bash: A Simple Script for Automating Git Reset

Don't you just hate doing Git Log, sifting through a bunch of commit hashes and then copy-pasting--all so you can reset to an earlier commit? I do--particularly the part where I need to select, copy and then paste the stupid hash. Today was a breaking point, actually. I finally wrote a script that will find the hash I want and pass it to Git Reset for me. My day is finally looking up.

Background

I needed to un-merge a branch today (stakeholders backed out--it happens). This meant reverting my preview branch to a commit just before the merge. This is exactly the kind of thing, I think, that pushes so many devs to graphical Git clients (like, GitKraken, et. al.); doing a reset on the command line is kind of pain. You need to run git log, find the earlier hash for a commit you want to reset to, copy it, and then paste it into a git reset command.

Web Developer Workflow: More Useful Linux Bash Aliases

More Bash Alias fun. This time we'll look at Git, Drush and a few others.

Intro

This is a followup to another recent post discussing bash aliases meant to make your web-developer life easier. If this is your first Tango with Bash Aliases, head to that post for an intro to working with aliases. Otherwise--the list goes on!

Bash: A Simple Script for Checking out New Git Branches

I'm feeling particularly nerdy today and I had a little extra time in my schedule. I recently discussed the utility of Bash Aliases; today, I decided go a step further and put together a Bash Script that allows me to build on that power even more. A Bash Script is basically an Alias on steroids, and if you've had any experience with PHP or JavaScript, there's a lot of overlap. Put on your nerd glasses and let's have a look.

Background - Repetitive Processes w/ Git

You may or may not find this script particularly useful--this post is really about the power of bash scripts to help manage workflow. I do, however, find myself checking out new Git branches somewhat frequently. So, with the extra time in my schedule, I decided to have a little fun and see if I could automate some of that Git workflow with a simple script. Checking out a branch with git isn't a particularly complicated process: git checkout -b <branchname>.