10 Mac Terminal Tips And Tricks For Pro Users

Spread the love

Over the past few months, I’ve written several articles on terminal tips and tricks for Mac:

I’m proud of these posts and think they’re a great place to start learning more about your Mac’s inner workings.

This post, however, is going to be a lot less… practical. I am going to teach you interesting and somewhat useful terminal tips and tricks. However, you’ll notice a clear difference between the lessons being taught in this post versus the previous posts (Spoiler: If you’re a Star Wars fan, you’re going to like this post).

Let’s get into it!

10 Mac terminal tips and tricks

1. Drag files and folders into the terminal to automatically get their path

Out of everything I’ve learned while researching for this terminal tips and tricks post, this is by far the most useful. When working in the terminal, you’re constantly needing to enter custom file paths. If you don’t know where files are located, you’re screwed. And even if you do know where files are, copying down the whole file path is a pain.

As it turns out, Apple built a solution into the terminal just for this! All you need to do to copy an exact file path into the terminal is to drag and drop that file into the terminal.

It’s that easy! This works for folders too. You can drag and drop paths into the terminal mid command, so you can use this all the time. Awesome!

2. Make your Mac talk to you

This is one of my favorite terminal tips and tricks. It’s a great way to impress your friends and it’s so easy that you’ll never have to worry about remembering it.

Just type say "Type whatever you want here" into your Mac terminal and press return.

After a brief second, you should hear your Mac start speaking to you! I have no idea what practical application this serves, but it’s fun to show off and would make for a funny gag in a YouTube video.

3. Keep your Mac awake using simple terminal tips and tricks

Alright, back to some more useful terminal tips and tricks. This is one I’ve used before, it’s pretty helpful. By default, your Mac or MacBook will put itself to sleep to conserve power and prevent others from messing with your Mac while you’re out of the room.

While this feature is great, there are times when you need your Mac to stay awake. Maybe you’re downloading something or watching an app for a long period, etc. However, you don’t feel like digging around in your settings to disable your Mac’s sleep feature and you don’t want to have to remember to reenable it.

Here’s a workaround! Just open the terminal on Mac, type caffeinate, and press return. This will override your Mac’s sleep settings for as long as you have this terminal window open. To go back to normal, just quit the terminal, or press control + c (not cmd + c) to cancel the caffeinate command.

If you want to have caffeinate run for a set amount of time, you can use the command caffeinate -u -t [seconds], like so:

4. Copy files in one folder to a new folder

Another helpful item on our list of terminal tips and tricks is copying files inside of one folder into a new folder. For this one, you will need to know how to navigate in and out of folders using the terminal. I recommend reading this previous guide for a quick rundown on the basics.

As the heading says, this command will let you copy the contents of one folder into another folder. To do this, navigate to the folder enclosing the two folders you want to copy files between. If these folders are on your Desktop, for example, cd to your Desktop.

Once there, type ditto [Folder A] [Folder B] and press return. This will copy the contents of Folder A into Folder B. Make sure that if there are any spaces in your folder names that you use quotation marks when writing the name of each folder. For example, your command might look like ditto "Folder A" "Folder B".

Here’s an example where you can see the before and after of this process:

If that looks like Greek to you, be sure to check out this guide!

Another neat component of the ditto command is that if Folder B doesn’t exist, ditto will create it for you. So for this command to work you only need Folder A. Try it out!

5. Hold down a key to repeat characters instead of choosing an alternate character

A feature that I liked gaining in my switch from Windows to Mac was the ability to hold down a key and get suggestions for variations of that same key:

The drawback of this feature, though, is that you lose the ability to type repeating characters. On Windows, when you hold down any of the character keys on your keyboard, you’ll see that key repeated over and over. You can do this with the spacebar on Mac to see what I mean – hold it down in any text field on your Mac.

For some, not being able to type repeating characters is frustrating. You don’t use alternate characters very often, and when you do you could just copy those from Wikipedia.

Luckily, one of today’s terminal tips and tricks is to trade the alternate characters feature for repeating characters.

To do this, type defaults write -g ApplePressAndHoldEnabled -bool FALSE into your terminal and press return.

You’ll probably have to quit any open applications to get this to take effect. Try restarting Apple Pages on your Mac and after entering this command and give it a go!

If you change your mind, just type the same command into the terminal but add TRUE instead of FALSE at the end. Then restart your apps and see if it worked!

6. Hide folders and files in Finder using terminal tips and tricks

Let’s face it – we all have a folder or two on our Mac that we would like for no one to ever see. Maybe it’s something as simple as a creative project you want to keep to yourself, something as personal as lewd photos, or something as serious as corporate secrets.

Whatever your reasoning, here’s a terminal trick that has you covered.

In the terminal, type chflags hidden [path of the folder you want to hide]. Just use the first tip in this terminal tips and tricks to easily drag and drop the folder path after you type chflags hidden.

Instantly, the folder will disappear. You can still find this folder in the terminal – just navigate to its enclosing folder and use the ls and cd commands to see its contents.

When you want to bring this folder back from hiding, use the command chflags nohidden [path of the folder you want to unhide]. This will instantly bring it back.

Also, you don’t have to use the folder’s path if you’re in its enclosing folder. For instance, if you’re trying to hide the folder Hidden Folder on your Desktop and you’re in your Desktop in the terminal, just type chflags hidden "Hidden Folder" to hide it.

7. Turn text into an ASCII banner

Alright, back to the pointless and fun terminal tips and tricks!

You can make ASCII banners in the terminal using a very simple command. Type banner [your text here] into the terminal and press return.

As you can see above, this will create a massive rendering of your text in the terminal using the ‘#’ symbol. If yours look nonsensical, you probably need to make your terminal fullscreen.

You can also control the width of your banner by adding -w to the command. For instance, if I wanted a width of thirty on a “Hello there” banner, I would type banner -w 30 "Hello there" into the terminal.

And that’s it!

8. Watch Star Wars on your Mac terminal

Honestly, this one blew my mind a bit. I have a feeling this is going to be one of those computing relics that eventually peters off into obscurity. But that isn’t going to happen today!

The title of this heading is exactly as described – there is a terminal command that will play Star Wars: Episode IV – A New Hope in your Mac terminal using ASCII artwork.

This was made by people, not an algorithm that converted the shots to ASCII. So not every shot is exactly like the original, and the story has been condensed a bit. But let’s be real, no one cares – this is awesome.

There are two ways to do this. On Macs running macOS Sierra and later (i.e., most of us) you’re going to want to use the command nc towel.blinkenlights.nl 23.

If you’re running macOS software that’s older than macOS Sierra, then you’ll use the command telnet towel.blinkenlights.nl.

When you’re ready to stop the animation, press cmd + q to quit the terminal.

To my understanding, this is made possible thanks to some creative developers who have a server with this animation stored on it. When you type that command into the terminal, it connects you to the server and starts playing the ASCII Star Wars animation on your Mac. So one day, when that server is shut down and forgotten about, this feature will probably be forgotten. But for now, it’s a wonderful thing to enjoy.

9. Add a custom message to your login screen on Mac

This is another relatively pointless item in our list of terminal tips and tricks, but I’d be lying if I said I didn’t use it. All it does is add a message to your login screen. You can leave any message you like, such as:

  • Your phone number
  • Your name
  • A quote
  • A joke
  • 42

To add a custom message to your Mac’s login screen, use the command sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Your message here". Bear in mind that if you don’t replace "Your message here" with something else, that’s the message that’s going to show up on your Mac!

I’ve said it before – you should always be cautious before entering a sudo command off of the internet. For your sake, I tried this on my Mac to make sure it was legitimate and it has worked. So you should be safe!

If you ever want to remove the message, type sudo defaults delete /Library/Preferences/com.apple.loginwindow into your terminal and press return.

10. Add the ability to Quit the Finder app with simple terminal tips and tricks

Last up on your list of terminal tips and tricks for Mac is adding the ability to quit the Finder app. You may have never noticed before, but this is one of the few apps that your Mac will not allow you to quit. cmd + q doesn’t do anything, and pressing the red ‘x‘ in the top-left of the Finder window only closes its window – the app is still running in the background.

There’s a good reason for this. Most of the time, you’ll never have any reason to quit the Finder application. On the contrary, truly quitting it (as opposed to closing it) can create some confusing effects on Mac for the average user.

But if you’re reading this post, you’re probably not the average user, so let’s experiment.

In the Mac terminal, type defaults write com.apple.finder QuitMenuItem -bool true and press return. This adds the ability to quit the Finder application. For it to take effect, though, you need to kill the Finder first. To do that, type killall Finder in the terminal and press return.

When you reopen Finder, click Finder in the Menu Bar and you’ll see a new Quit option available.

Also, you’ll find that cmd + q now quits Finder as well.

If you have any files on your Desktop, you’ll see them instantly disappear when you quit the Finder. Don’t worry! They are not deleted. The Desktop just runs through the Finder app, so when you quit the app, you stop seeing files on the Desktop along with any other Finder windows you have open. When you start Finder again, you’ll see that all of your files are right where you left them.

To remove the Quit function from Finder once more, just enter the same command as before only swapping true for false this time. So it should look like defaults write com.apple.finder QuitMenuItem -bool true.

Start learning more terminal tips and tricks on macOS

And that’s it! Hopefully, you found plenty of fun and useful things to use in the terminal on Mac in the future. These terminal tips and tricks are all fascinating, but they only scratch the surface of things you can do. Be sure to read more tutorials on the Mac terminal. And, if you want to become even more of an Apple pro user, be sure to check out the rest of the posts on the AppleToolBox blog.

Leave a Reply