My 6 most helpful commands to only use macOS Terminal in future

Learning to work with your Terminal on your mac can save a lot of tedious tasks and time and even automate whole routines to get you focused on the essential things.

Useful Bash Commands to Manage Directories and Files

Print Current Working Directory (pwd)

Your current working directory is the Directory where your commands are being executed. It is typically printed as the full path to the Directory (meaning that you can see the parent directory).

To print the name of the current working directory, use the command pwd

$ pwd 

Create a New Directory (mkdir)

Usually, the first step in creating a new directory is to navigate to the Directory that you would like to be the parent directory to this new Directory using cd

But when you set up a smart folder and directory structure, you can navigate real quick or create new folders and files in your desired Directory without switching your current folder. So, let’s say we have the following folder structure:


Playground: Just used to quickly set up a local test environment like creating a react-app to test a new feature or creating and testing a new shell script

Work: Here is your production code, directories, and repositories

Pictures: You don’t have to explain that folder, huh?

Documents: I think you now get it?!

You can now navigate within your Terminal with the following command in every folder by just typing:

# The long version
cd /users/yourUsername/Playground
# Better Option
cd ~/Playground or cd $HOME/Playground

If you aliasing your $HOME variable and setting it to something like

alias home=’$HOME’

You just type the following command in your Terminal to navigate to every Directory you want:

home/Playground --> to navigate to the Playground directory

You can use this command structure to clone maybe a repository you want to test locally:

git clone home/Playground/react-cheatsheet

If you are aliasing git clone or just using the GitHub CLI you just have to enter:

# alias ghc='gh repo clone'
# alias Playground='home/Playground'
ghc typescript-cheatsheets/react Playground/react-cheatsheet

Get local weather information

alias weather='curl -H "Accept-Language: en"'# You can set the output to your prefered language
# You can pass coordinates instead of the yourCity to getting better # results

Updating your software by one typing one word

Do you ever think about getting all your tools, programs, and software up to date?

# I using homebrew to install all tools I need, so I only have one 
# script to update everything. You can setup auto-update for brew if # you want. Just take a look at brew manpage or documentation
alias update-mac='brew update && brew cleanup && softwareupdate -l'# Some information for softwareupdate:
# -l | --list List all appropriate update labels (options: --no-scan, --product-types)
# -d | --download Download Only
# -i | --install Install
# -a | --all All appropriate updates
# -R | --restart Automatically restart (or shut
# down) if required to complete installation.
# Full automation
alias auto-update='brew update && brew cleanup && softwareupdate --download --install --all --restart'

You can use brew autoupdate to automate even more or use the build-in brew auto-update function by enabling them like:

# You have to set time between updates in seconds
# 24 hours == 86400 seconds
export HOMEBREW_AUTO_UPDATE_SECS="86400"# or if you wish to disable auto-update mechanism entirelyexport HOMEBREW_NO_AUTO_UPDATE="1"

Annoyed by typos or misspellings

I am using this handy tool for it. When I just type too fast or forget one Letter, I do not have to rewrite the whole command in my shell or navigate to the place to paste the missing Letter. Instead, just type ‘fuck’ in the future in your Terminal. Sure, you can choose an alias for it you want, but believe me, when you share your desktop at your next Live Coding Session and just type ‘fuck’ after making a mistake in your last command, you definitely get some attention!

➜ git brnch
git: 'brnch' is not a git command. See 'git --help'.

Did you mean this?

git branch [enter/↑/↓/ctrl+c]
* master

Downloading The Fuck or getting more information

Annoyed of retyping long commands!?

You type a long command into your Terminal to start up your program. Now you want to do it again. The easiest option is to retype the entire command. Your typing speed might improve. Or, you will get tired of programming 😪reverse-i-search, a better way of searching

You ran an AWS command in your Terminal 5 days ago. Unluckily for you, you don’t remember the obscure StackOverflow question that contained it. Of course, you also forgot to document this command. You can use the arrow keys, but this will go through all the commands you executed in your Terminal since last week.

Instead, we can use reverse-i-search

reverse-i-search: Search backward starting at the current line and moving ‘up’ through the history as necessary. This is an incremental search. (source)

Press the ctrl key and the r key simultaneously. A prompt will appear. Start typing what you remember of your command. You will see the latest command from your history that matches your search term.

Press ctrl + r again to navigate through earlier entries in your history that match your search term.

I hope you now have some valuable tips and commands to get started to work with your Terminal instead of losing time by navigating through the UI 🤭

Bonus Hint:

# searching on homebrew for a program you want to install?brew search visual-studio-code==> Casks
visual-studio visual-studio-code
# need more info? open the homepage from the cask, formula directly # in a new browser tabbrew browser visual-studio-code



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store