macOS Terminal Tips

Master macOS with these simple terminal tips. 

Let us run through some great interface and user tweaks to customize MacOS. These tricks are simple and can improve your workflow beyond what the System Preferences window allows.

 

Finder

Show hidden files

Want to see all the hidden files and folders in MacOS — or you simply can't find a file you hid? Just use this command in Terminal:

  defaults write com.apple.finder AppleShowAllFiles -bool TRUE
  killall Finder

To re-hide all your files, just change the TRUE to FALSE.

 

Copy contents of a folder from one place to another

There may be times when you need to copy the entire contents of one folder to another. If you want to simplify the process use this terminal trick.

   ditto -V ~/original/folder/ ~/new/folder/
 

Download without using a browser

Have a URL to a file but don’t want or have access to a browser? You can do it through the terminal with the following commands:

    cd ~/Downloads/
    curl -o http://www.domain.com/thefile.zip

The first command changes your current location to the downloads folder; The second initiates the download from the web to that folder.

 

ScreenShots

Change your screenshot’s file format

By default, macOS saves its screenshots as PNG files, but there are lots of services out there that want them as JPGs or PDF’s. If you using one of these services on a regular basis you may want to improve your workflow with the following terminal command:

    defaults write com.apple.screencapture type jpg
 

Disable drop shadows on a screenshot

Focus on what's needed and disable drop-shadows on your screenshots, only displaying the window you’ve snapped:

    defaults write com.apple.screencapture disable-shadow -bool TRUE
    killall SystemUIServer

The first command enables or disables the drop shadow, however, this does not take effect until you restart the SystemUIServer which is what the second command does

 

Create a new default name scheme for your screenshots

Apple tends to use “Screen Shot date - time”, but you can change the word screen shot to any word you would like with:

    defaults write com.apple.screencapture name "New Screen Shot Name"
    killall SystemUIServer

You can go back to default with the following:

    defaults write com.apple.screencapture name ""
    killall SystemUIServer
 

Change the location of your screenshots

Your screenshots by default are saved to your Desktop. But if you’d prefer they were saved elsewhere it’s an easy terminal trick: 

    defaults write com.apple.screencapture location ~/your/location/here
    killall SystemUIServer

I personally use my dropbox folder and have instantly shareable links

 

System

Create custom login messages

There are many great uses for changing the welcome message one of which is “in the case of loss” contact information. Personalize this message with this terminal command:

    sudo defaults write /Library/Preferences/com.apple.loginwindow
    LoginwindowText "In the case of loss, call 123-456-7890."

The first command enables you to write login window file and prompts for your password in order for the next command to change the content of the welcome message.

 

Quickly keep your Mac awake

There will come a time where you just need to prevent macOS from going to sleep either, you’re running a long test or screencasting. There is an easy command to remember just for that task:

    caffeinate

Once you're in caffeine mode and you want to end your poor macOS’s suffering, you can use **Control-C** to end it You can also use the following options to the command to assign a set number of seconds before macOS goes to sleep.

    caffeinate -u -t 5400
 

Make macOS automatically restart after a crash

Freezes and crashes don’t happen too often on a Mac but if you want to get back to work as soon as possible have macOS reboot after a crash or as soon as it senses a full system freeze with the following command:

    sudo systemsetup -setrestartfreeze on
 

DOCK

Add spacers to your Dock

You can organize your dock by creating blank spaces with the following command:

    defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
    killall Dock

You can repeat this command as many times as you like. In the event you want to remove a spacer, simply drag it off the dock until you see the poof icon.

 

Dull hidden apps in your Dock

This command will lower the opacity of icons which are not visible on your screen. It’s a great way to see what you haven't used lately, as well as what’s cluttering up your screen.

    defaults write com.apple.Dock showhidden -bool TRUE
    killall Dock
 

Hide non-active apps in your Dock

Like the idea of dulling hidden apps but want to take it a step further. Use the following command to hide any closed apps from your dock at all times.

    defaults write com.apple.dock static-only -bool TRUE
    killall Dock
 

How about having some fun in the terminal

Here’s a fun one for you old school gamers: Play Tetris, Snake or Pong with these terminal commands

emacs
press enter
press escape
x
type in tetris, snake or pong (all lowercase letters) 
 

Reenact the original Star Wars in its entirety as ASCII art with one simple command:

telnet towel.blinkenlights.nl
Thomas Fraley
I am a tech enthusiast whose main focus is making technology easy again for everyone. Educated with degrees in network engineering and project management. I've worked in the entertainment industry for a decade as a director of information technology for global companies pioneering the way. A few years ago I decided to give back and have been helping young entrepreneur startups off on the right foot.
www.lifewithtech.net
Previous
Previous

Security: What is a BlackNurse Attack?

Next
Next

End-To-End encryption & Facebook