Well, I’m going to start by saying that I’ve failed to make my 30-day mark. Somehow I managed to miss a day completely without even realizing I did it. It’s surprisingly difficult to actually post something every day, even once you do manage to get into a routine. However, that doesn’t mean I’m quitting! I’ve managed to make several personal breakthroughs in the last weeks, and I find that despite the obvious aggravations, maintaining a regular blog post is beneficial in some ways. So, the posts go on!

For those of you who know me well, you’ll know that I’ve been a die-hard Linux fan for… well… almost as long as it’s been around. However, despite my Linux preference, I’m currently working with the excellent team from ServerPress in a role which, among other things, has necessitated that I start using a Mac to some extent. My initial issues with Mac notwithstanding, I’ve managed to get past the learning curve and can now use it with some degree of familiarity.

In addition to being a Linux user, you may have noticed that I have a preference for the command line. Thankfully, being based on BSD, Mac can do much of what I am used to doing on the command line. There were, however, a few unique quirks which are the reason this article is worth writing! In short, this is to document the issues I ran into with the Mac Terminal app and how they can be overcome.

Quirky Bash Configs

While migrating my traditional .bashrc file to Mac was fairly simple; there were a few things that initially caught me off guard. First and foremost is the few issues users might run into regarding command flags. For me, I have a variety of aliases in my .bashrc that are generally designed to make my life easier. Take the following for example:

Copy to Clipboard

For those who are unfamiliar with Linux (and particularly Bash), this is a fairly straightforward and common command. The alias command allows you to create a shortcut which, when typed, runs the value of the alias. So, when I run the ls command, it actually runs ls --group-directories-first --color=auto -h. Simple, right? On Mac, not so simple. While the alias command works the same, many Mac commands are a version (or ten) behind their Linux equivalents. For example, as of the date of this writing, Ubuntu Linux (arguably the most popular distribution) is running Bash 4.x.x, while Mac is running Bash 3.2.64. That’s a major difference! In the case of the aforementioned ls command, the --group-directories-first and --color=auto weren’t added until Bash 4.0. This difference causes the console to throw errors both on load and when attempting to use the ls command. So how do you fix it? In this case, it’s simple:

Copy to Clipboard

Not every case is this simple to resolve, but the point is valid nonetheless. Figure out the offending command, convert to Mac equivalents, done! The second major issue regarding Bash configs is that if you drop in an actual .bashrc file, you might be surprised to notice that it never actually gets loaded! There’s a good reason for this. The core Bash configuration shipped with Mac doesn’t even look for it! Rather, it looks for another file that’s fairly standard on Linux, the .bash_prompt file. This oversight causes two fun quirks. The first is obvious: things don’t get loaded, and resolving it is equally obvious. In your .bash_profile file (it exists by default), add the following:

Copy to Clipboard

The second issue caused is significantly more difficult to identify and even more difficult to resolve if you don’t know the underlying cause. This actually caused me two full days of headaches before I finally tracked it down, primarily because it never threw an actual error. All in all, Bash worked as anticipated, but other applications which, in one way or another, used Bash would randomly fail or never fully load. After going through my .bashrc file line by line, I tracked it down to the lines regarding the configuration of my Bash prompt. This was troubling, as even setting PS1=' caused these failures. HOW CAN MAC SUPPORT CONFIGURABLE PROMPTS IF THEY BREAK EVERYTHING? Well, it’s not that it isn’t properly supported, it’s just not supported in a .bashrc file. Move the prompt configuration to .bash_profile, problem solved.

WTF Keybindings???

New Mac users will instantly not one obvious difference between a Mac keyboard and one designed for literally any other operating system. Rather than the normal Ctrl, Windows and Alt keys, Mac has Fn, Control, Option and Command keys. This initially throws off many transitioning users, but there’s one thing that is guaranteed to throw of transitioning Linux command-line commandos… the Home and End keys don’t work as expected! Rather than going to the beginning or end of a line in Terminal, they scroll to the top or bottom of the scrollback. Actually, super easy to fix.

First, launch Terminal and edit your current profile. Navigate to the “Keyboard” tab and add the following key/action combos:

  • Home\011
  • End\005

  • Page Up\033[5~
  • Page Down\033[6~

This modification will make Bash treat the keys as you’d expect it to, but this doesn’t follow for Vim users. If you use Vim like I do, you’ll have to do an additional tweak. If you have a .vimrc file, add the following to it. If you don’t, create a new one in your home directory and add it.

Copy to Clipboard

Just like that, Vim quirks fixed!

Above And Beyond

So once you have the necessary fixes in place, what next? I’ve managed to find replacements for pretty much every app I used on Linux, but I’m sure there are some essentials out there that I’ve missed. So, without knowing what I may or may not be looking for, what do you find essential? What apps are worth checking out? Let me know!

Share:

Leave A Comment