Bash Script

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: An Easier Way to Check File Permissions (Octal Mode & Stat)

File permissions on Linux can be a pain. You can either understand them in symbolic mode (basically, alphabet soup--i.e., drwxrwxrwx), or you can master them in octal mode (i.e., 777--which roughly translates to "Open the gates of Mordor!"). While symbolic mode might acutually be the more human-readable format; octal mode feels a bit more intuitive, and in my experience is what I see referenced more often on the interwebz (i.e., StackOverflow). The problem?--Linux generally defaults to symbolic mode on the command line--such as when you run ls -l. Here's a short script that helps cope with this. Run it, and it'll give you the permissions for a file, directory, or contents of a directory in octal mode.

Lost in Translation

First off: I'll assume this isn't your first time dancing the permissions tango--i.e., you have a basic understanding of symbolic and octal permissions. So, I won't go into the nitty gritty, here, of what each and every number combination means--let alone the existential implications of what your permissions should be for any given use-case.

Bash: A Simple Script for Copying Files and Directories with SCP

This is a followup, of sorts, to an earlier post on file sharing in Xubuntu--which can be kind of a pain. I never looked seriously at SCP as a solution for file sharing because it's honestly tedious--true for both in-network and out-of-network sharing. With a little Bash scripting, though, SCP can be made a lot more practical. Here are a couple of short scripts that take the edge off.

Background

SCP is a command-line tool for passing files from one computer to another with SSH. That makes it a valuable tool no matter where those computers are: inside your home network, or off on some remote. The trouble I've always had with it, though, is remembering addresses: I can never remember the IP address of each and every device on my network, and some of the remotes I work with have really convoluted sub-domains. If it weren't for this, SCP would be a really great way to pass files from one place to another.

Bash: A Simple Script for Changing Display Brightness with XRANDR

I run two external displays on my laptop; the brightness keys on the laptop don't affect them. I could probably find an app or extension for Xubuntu to handle dimming the displays, but since I spend a lot of time on the command line, it's just as easy to dim them from there with the help of XRANDR and a simple Bash script. This post outlines how to set the script up. I'll also cover an optional "night mode" that reduces blue gamma from the display.

If you're on Xubuntu, Ubuntu, or just about any other flavor of Linux, you're probably using the X server to handle your display configurations. That should also mean that you have XRANDR available on the command line. XRANDR can change display configurations in any number of ways, but today I wanna look at it for controlling brightness. Here's the deal, though: I don't wanna have to memorize yet another command line syntax just to dim my monitors. Whichever way XRANDR handles the dimming, I'm gonna move it into a Bash script and alias it so I can adjust brightness on the fly!

Git: Add, Commit and Push All at Once (Bash Function)

Git is a powerful tool, but sometimes the redundant keystrokes are a pain in the butt. Should you really Add, Commit and Push all in one fell swoop?--No. There are plenty of good reasons not to. Can you? Yes. All it takes is a little scripting with Bash.

Use Case

I love Git. It can sometimes suck the life out of you, though. That may not be the case for everyone. How much time you spend banging your fingers on the command-line kind of depends on your workflow. If you're a front-end dev, for example, and you spend a lot of time tweaking CSS (or SASS, or whatever), a good way to minimize your use of Git is to simply leverage your browser's Developer Tools more efficiently. Another good strategy is to focus on your localhost--reducing the number of pushes you need to make.

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>.