Mac tips: Terminal

Wait, don’t be afraid of the mysterious and unknown… just kidding. Terminal can be amazing. Let me show you some super-easy basic features which can save you time. Oh almost forgot, terminal can be fun too.

The dock spacer

This one is my favourite. You can add a blank “Icon” in your dock and move it wherever you want. As result, you can organise apps in a pretty way.

The command:

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

Now restart the UI:

killall Dock

Never sleep again

We all love how efficient macOS is. Battery life is stellar but everything comes with a price. MacOS will put your computer to sleep as much as it can. Sometimes we just need it to stay awake. There are plenty of apps for it, but there is a built-in feature which you can access from terminal.

Just type caffeinate and you are ready to go. Want more options? Check this out:

caffeinate -s keep your whole system awake

caffeinate -i disable your mac from going to idle state

caffeinate -d will keep your display up

This command will prevent your mac from sleep until your terminal windows is open. You can stop this command (and any command) by pressing control+C.

Talk to me

Simple, fun. Useful? Maybe. Your mac can turn text to speech with say command.

The command:

say write here wahetever you want and your mac will say it.

The useful basics

Want to be the terminal ninja? You’re in the wrong place my friend, but here are some basics.

The commands:

cd = change directory. You can go in and out through your folders with this command.

cd Downloads will enter the Downloads folder

cd .. is one level back in your folder structure

cd SPACE yes just hit spacebar do not type SPACE there. will get you home

ls = list. Will sow you the content of th current folder

df -h will show you the used disk space

uptime = will show your uptime

Download without a browser:

curl -O [URL of file you want to download]

Shutdown or restart you mac:

sudo shutdown -h now

sudo shutdown -r now

View your total download history:

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'

Delete your download history:

sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'

Copy the content of one folder to another:

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

Speed up Time Machine backups:

sudo sysctl debug.lowpri_throttle_enabled=1

Flush your DNS Cache:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Add static route (IP address and netmask is an example, change it to yours):

sudo route -n add -net 10.0.0.0/8 192.168.0.254


BREW – here comes the fun part!

Brew is everything you miss from your mac / linux terminal. Want to use Midnight Commander? Need to launch a web development environment? You are covered with brew.

How to install?

Check the official HomeBrew website first. The short answer is:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Now you can install brew packages.

Let’s say, you want to use your beloved file manager Midnight Commander (MC).

The command:

brew install midnight-commander

After the installation launch it with a simple command: mc

FUN and relaxation

Sometimes you just need to think and wash your brain.

Try this out.

brew install cmatrix

Launch with: cmatrix

Boom, you are in the MATRIX my firend. (Turn out with control+c)

Not enough right?

brew install asciiquarium

What? Really? Yes! Check this out. You have an aquarium to watch in ASCII.

Okay so you need something more interactive? How about TETRIS?

brew install samtay/tui/tetris (You need to install or update xcode for this)

Launch with this command: tetris

Have fun exploring thousands of packages, commands, options in the most amazing tool ever made.