macOS Command Line Tips

As previously mentioned, one of my favorite exercises is to avoid using system transfers when I move to a new MacBook, and instead start over from scratch, as I learn something new every time.

One big difference this time around has been that I am in the command line much more now than I have been in the past. I’ve been working actively on this as a skill, and as a result, it means more time sitting at a prompt.

The default terminal in macOS is fantastic, at least for the reason that it’s a modern OS with UNIX-like command line syntax—but there are some way it falls short, based on either its BSD roots or choices made by Apple.

The good news is that you can make up for a good number of those shortcomings with a bit of work, and find some neat tricks at the same time. I asked on Twitter for some additional tips:

I’ll be sharing any tips that I’m pointed to there for the first time in this post and subsequent edits, so if you have any tips of your own, drop me a reply on that tweet and I’ll check them out.

Optional Step One: Install a Terminal Replacement

This is very greatly a matter of personal preference, but I usually replace the Terminal app with an alternate solution. (This is where we pour one out for TotalTerminal a.k.a. Visor, of blessed memory.)

I prefer iTerm2 and its advanced features such as split panes, shell integration, and more intelligent buffering and options, but you may find something of your own you prefer. iTerm2 is also open source under the GPLv2.

Install Xcode Command Line Tools

Before we can do anything else of note with the command line, we should install some command line stuff that’s left out by default in macOS but very useful for a lot of the other things we’ll want to do. Thankfully, Apple made this bit pretty easy.

Open your command line and run:

xcode-select --install

You’ll be prompted to confirm this installation with a GUI dialogue. Accept it, and macOS will download the developer tools for you. (You will possibly end up upgrading some of these tools, but that’s OK. This will get you started and give you the basics you need.)

Get a Monospaced Font That’s Not Monaco

Monaco as a font is OK, but not great. There are two alternative options I usually recommend.

The first is the monospaced font that comes bundled in with the default Terminal app:SF Mono. Apple doesn’t distribute this font outside of either Terminal or Xcode from what I can tell, but you can extract it from the Terminal app if you would like. Get to the folder containing the font files using this:

open /Applications/Utilities/Terminal.app/Contents/Resources/Fonts/

Select all the files in that folder and open them, which will take you to Font Book to try and install them. Font Book will tell you there are problems with the font files. Font Book is lying. The installation will work, and I haven’t seen any reports of it being problematic.

(I think the warning is because doing this might possibly be against the terms of use for the font.)

If you would rather not pull SF Mono out of Terminal, or if the errors give you pause, another great option is to install Anonymous Pro, which has been my go-to fixed width font for years. It’s a great option and has a free license. You can download it here.

Get Homebrew for Package Management

Modern Linux distributions often use package managers to add and remove installed software with ease.

Now, when you run into a command line tool or other utility someone’s pointed out to you, you can usually install it more or less automatically with Homebrew. Here’s an example for wget, which quite honestly should be included with macOS, but isn’t:

pathfinder:nodecg ryanmarkel$ wget
-bash: wget: command not found
pathfinder:nodecg ryanmarkel$ brew install wget
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Deleted Formulae
kibana@4.1

==> Installing dependencies for wget: openssl@1.1
==> Installing wget dependency: openssl@1.1
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.0f.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.0f.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl@1.1/lib
    CPPFLAGS: -I/usr/local/opt/openssl@1.1/include

==> Summary
🍺  /usr/local/Cellar/openssl@1.1/1.1.0f: 6,421 files, 15.5MB
==> Installing wget
==> Downloading https://homebrew.bintray.com/bottles/wget-1.19.1_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring wget-1.19.1_1.sierra.bottle.tar.gz
🍺  /usr/local/Cellar/wget/1.19.1_1: 11 files, 1.6MB

Suggested Homebrew Packages

You can get pretty fancy with Homebrew. My colleague Jeremy Herve has a great script he uses to run it when spinning up a new system, and he posted about that here. I don’t install that many things via Homebrew, but there are a handful of things available through it that I use with some regularity.

If you know of any cool utilities I don’t; feel free to ping me on Twitter and tell me about them.

mas

(source on GitHub; MIT license)

mas is a great utility that helps you with both installing and maintaining apps you have installed through the Mac App Store (which, admittedly, is fewer and fewer apps over time). You can even use it to search for apps and manage your authentication status.

pathfinder:nodecg ryanmarkel$ mas list
409183694 Keynote (7.2)
408981434 iMovie (10.1.6)
485812721 TweetDeck (3.9.889)
443987910 1Password (6.7)
904280696 Things3 (3.0.3)
803453959 Slack (2.6.2)
442007571 AntiRSI (3.3.0)
557168941 Tweetbot (2.5.1)
407963104 Pixelmator (3.6)
409201541 Pages (6.2)
682658836 GarageBand (10.2.0)
409203825 Numbers (4.2)
692867256 Simplenote (1.1.8)

cloc

(source on GitHub; GPLv2 license)

At work, we do a lot of code review and scheduling those code reviews. If I have a bundle of code and I want to size it up quickly to see what it does, I use cloc to do this. It’s a great first-look at how much work a review could end up being.

pathfinder:Development ryanmarkel$ cloc ryanmarkel-v2/
    1933 text files.
    1905 unique files.
     146 files ignored.

github.com/AlDanial/cloc v 1.72  T=8.46 s (211.5 files/s, 32469.1 lines/s)
----------------------------------------------------------------------------------------
Language                              files          blank        comment           code
----------------------------------------------------------------------------------------
PHP                                    1305          18979          44697          79398
CSS                                      79           5329           2056          32684
JavaScript                              149           4631           5865          20148
PO File                                  73           8254          12486          20091
XML                                      74            869            926           5606
Markdown                                 40           1512              0           3896
JSON                                     31             14              0           3282
HTML                                      9             14              0           1444
Velocity Template Language                1             11              4            470
Bourne Shell                              6            114             40            468
Maven                                     1             30             21            305
YAML                                     10             52            111            262
Ant                                       1             19             30            140
INI                                       7             27             89             95
DTD                                       1             25             54             69
XSLT                                      1              5             14             19
make                                      1              1              0              3
----------------------------------------------------------------------------------------
SUM:                                   1789          39886          66393         168380
----------------------------------------------------------------------------------------

streamlink

(source on GitHub; BSDv2 license)

streamlink is a forked successor of livestreamer, which unfortunately became a dead project but is insanely useful. It uses command line instructions combined with (normally) an install of VLC to open streaming video using a method that tends to be much lighter-weight than using a browser. It will help you identify various transcodes as well, and can be used even to load authentication-required video for some services.

pathfinder:Development ryanmarkel$ streamlink https://twitch.tv/gamesdonequick
[cli][info] Found matching plugin twitch for URL https://twitch.tv/gamesdonequick
Available streams: audio_only, 160p (worst), 360p, 480p, 720p, 720p60 (best)

Bring Some Color to bash

Some of the tools that are included with macOS at the command line and its default configuration are slightly altered from defaults you may be used to in other UNIX-like environments. One that tends to bother me is that by default, ls doesn’t have any color indicators for output. By default, it looks like so:

This really isn’t helpful. Let’s add at least some color marking by adding this to our ~/.profile:

export CLICOLOR=1

Now, when I’m in a terminal session in any terminal app, I should see my directories like so:

You may also wish to customize your prompt using the information you can find here, but the number of options there are a bit much for me to get into.

Using pbcopy/pbpaste

Mark Jaquith replied to me with this tip:

Straight up: I did not even know about pbcopy and pbpaste, but reading the man pages for them, it’s crazy I went this long without knowing what they were and how to use them.

You can use the commands to move text back-and-forth between your terminal session and the macOS Clipboard. This should be self-explanatory, but for example, I just realized that I could have used it to put large chunks of the output from commands in this very post without having to select it and copy it.

What Am I Forgetting?

If there’s a neat trick or setup tip you think I’m missing, please let me know! Drop a reply to either the tweet for this post or the one I posted earlier and let me know what I can add!

Preparing to Run Brackets at Large FGC Events

Combo Breaker 2017 is coming up in a handful of days, and I’ll be on the floor helping run brackets to do my part to make it a great experience for competitors.

I enjoyed my volunteer time a ton last year, and I’m happy to help make this year’s event a similar success. Assuming there are new volunteers this year who haven’t run brackets at a big event before, I thought I’d put together a list of things that have worked for me in running an efficient, well-organized bracket and getting the most out of my volunteer time.

So, here we go, in no particular order other than this first one, which is most important:

Attend the Volunteers Meeting before the Event

This is non-negotiable. Every event will have specific ways they do things. They are not always going to be the same from event to event or even year to year. They are almost certainly different from what you have been running for your locals, house events, or whatever you have run before. Your head TO or other bracket coordinator should have sent you a message with the meeting times. Show up.

When you are there, the most important thing you can do—even if you have been to a million of these—is to listen. Things may have changed from the previous year, and there will be others at the meeting who have not done this before. They need to be able to hear, and for that to happen, everyone in the meeting needs to be listening.

If you have questions, ask them at the meeting. It’s far more efficient for you to have your questions answered before a single bracket has started than to try to track down other staff once there are hundreds of people on the event floor and you are facing a time limit for running your pool.

Do Your Homework

You will have your pool assignments ahead of time so you know when you are needed and can schedule yourself accordingly. Players will have their pool assignments ahead of time so they can plan for their matches.

This means you should know who is in your pools before you get started. You’ll also know what games you will be running. Take the time to see who you’ll be working with, study the rules for the games you have been assigned, and make sure you know when you are supposed to be there.

Know who your game’s TO is and what they look like. Know who the head TO is and what they look like. You need to have this information in your head so you can quickly and efficiently get help if and when you need it. Come prepared.

Wear a Watch

You’ll be responsible for getting your brackets done on time. This means you will need to know the following at all times:

  • How long you have before your next bracket starts
  • Whether you are at the threshold of time for you to start DQ’ing players (varies by event)
  • How much longer you have to get the pool done to end on-time

You need to have a clock somewhere on your person the whole time you are staffing the event. A phone is fine, but phones can get dropped, run out of battery, be misplaced, or the like. (I carry a portable charging battery with me at all events in case my phone starts running low.)

YMMV on this suggestion, but I prefer a watch because it’s less obtrusive, easier to glance at when needed, and far more incident-proof than a phone.

Carry a Notebook

When you run into a sticky situation, or if you need to track what’s going on at any given point during your bracket, notes can save you from problems or time-delaying issues. Assume the following when you are running the bracket:

  • Someone will have to go to the bathroom and will (or should) tell you they are doing so to prevent being DQ’d
  • A player will ask you about the rules for the game you are running
  • You’ll need to look at your own schedule to keep things straight and report to the correct place
  • Someone not even in your bracket will see your staff shirt and ask you a question to which you may or may not immediately know the answer
  • Other staff people may have things they need your help with that you can’t get to immediately

A notebook is your lifeline in most of these situations. Things I recommend for your notebook:

  • Put your schedule in it so you can refer to it at any time
  • If someone asks you something and you need to get to it later, write it down so you don’t forget
  • Jot down the rules and default settings (or anything specific that’s different!) for the games you are running so you have it available instantly
  • Write down player names if they leave and inform you they are doing so, as well as what time they left the pool stations (when they leave, you should tell them how quickly they should be back to avoid a DQ situation)

Last year, I carried my Moleskine around in the venue, but it was overly bulky and not very practical. I recommend a smaller notebook style, like a Moleskine Cahier or a Field Notes notebook. They fit in a pants pocket and are easier to move around with.

Relatedly, when you take a pencil for writing on your brackets (because events use paper brackets), take two so you have a backup.

Early = On Time. Be On Time.

Find out what the expectations are for players and when they should report to a pool station for their brackets. Be there five minutes before that time so you are there when players arrive. Politely clear away any casuals at the station in advance of your brackets by setting time expectations with those players as you get things ready. Mark players on your bracket as they check in with you so you know who is there.

Take Care of Yourself

Don’t forget to eat something. Drink water like it’s going out of style. Wear comfortable shoes you can stand in for a couple of hours at a time without problems. Clear any bathroom breaks you might need before your bracket starts. Get some good sleep the night before.

If you are miserable, you are going to pass that savings on to your players, and they won’t have as good a time. Which brings me to my last point:

Have Fun. Help Players Have Fun.

This is your job when you help run an event.

Yes, you are there to enforce rules, make sure players are not being disruptive or otherwise problematic, and to run your brackets on time. You can do these things and still have a good time, which will result in your players also having a good time.

Bracket runners do not get salty. Be fair. Be calm. Encourage your players to have a good time. Answer their questions. Thank your players for being there when they are out of the pool. Congratulate the players who escape the pool to later brackets.

Anything Else?

If I missed something here you think is important, drop me a reply on Twitter and let me know. I’ll be happy to add things to this guide.

How to Replace a Balltop

A super-quick, cheap, and easy-to-install method for adding some personalization to your fightstick is to replace the stock balltop with a different one, maybe of a different color or from a different manufacturer.

Parts Used in This How To

For this how to, we’re using a MadCatz TE2, which comes with a Sanwa JLF-TP-8YT lever as a stock part. Those levers come with an LB-35 balltop.

  • Sanwa LB-35 Balltop (35mm, yellow)
  • Seimitsu LB-39 Balltop (35mm, blue)

Any 35mm balltop will work when following this tutorial. This includes stock balltops from Sanwa and Seimitsu, as well as the stock balltop on the Hori Hayabusa lever, and many custom balltop replacements. (The vast majority of balltops you can buy are 35mm.)

Tools Used in This How To

  • Flathead screwdriver (the tool included with the TE2 counts)

How To Replace the Balltop

OK, first, open up your stick or otherwise get it to the point where you can get at the underside of the mounting panel. On the TE2, use the catch button at the front of the stick and swing the panel up.

IMG_0952

Turn the stick so you can access either side of the mounting panel at the same time.

With one hand (I’m left-handed), grab the balltop that’s currently installed.

IMG_0954

With your other hand, take the flathead screwdriver and insert it into the screwhead on the bottom side of the joystick lever. Hold the screwdriver head there so you can apply torque to the joystic shaft without it rotating entirely. (If you want to see what that looks like, just rotate the balltop without having the screwdriver in place.)

IMG_0955

Using one hand on the balltop and the other hand on the screwdriver handle, rotate the two so the balltop starts separating from the shaft. After a few rotations, it should look like this:

IMG_0956

Once you have removed the balltop, set it aside. To stop it from rolling around on your work surface, set it down with the screw mount flat on the surface.

Grab the new balltop you want to install, and reverse the process you used to remove the previous one. With one hand on the balltop and the other on the screwdriver handle, rotate the two so the new balltop tightens on the lever.

IMG_0959

Slowly but firmly continue to screw the balltop onto the mount until you feel resistance. Give it one last gentle tighten and you’re done. Remove the screwdriver from the bottom of the lever assembly and check to make sure the new balltop is flush with either the shaft itself or the shaft cover if your stick has one.

IMG_0960

You’re done! Close the stick up and give it a test. It should freely rotate in your hand without coming away from the shaft.