mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
379 words
2 minutes
5 Terminal Tips to Boost macOS Efficiency

As a macOS user, the Terminal is one of our most powerful tools. Whether you are a developer or just an advanced user, mastering some Shell tricks can multiply your work efficiency.

This article shares 5 Zsh/Bash tips I use every day. They require no complex plugin installations and work right out of the box.

1. Quickly Return to the Previous Directory (cd -)#

This is perhaps the simplest yet most practical command. When you are frequently switching between a deep directory like /Users/levi/project/src/components/ and a system directory like /etc/nginx/, you don’t need to type the full path every time.

Simply type:

cd -

The system will automatically take you back to “the directory you were in last.”

2. Command Too Long? Use Ctrl + A and Ctrl + E#

When you’ve typed a massive command in the terminal and realize you forgot to add sudo at the very beginning, or misspelled a word:

  • Do NOT frantically spam the left arrow key.
  • Press Ctrl + A: The cursor instantly jumps to the beginning of the line.
  • Press Ctrl + E: The cursor instantly jumps to the end of the line.

These two shortcuts are standard Readline bindings and work universally across most Shell environments.

3. Search Command History (Ctrl + R)#

This is an operation that makes you look very “geeky.” What if you want to execute a complex docker run command you ran a few days ago, but can’t remember the exact parameters?

  1. Press Ctrl + R.
  2. Type a keyword (e.g., docker).
  3. The terminal will automatically show the most recent matching history record.
  4. If you want to find an even older one, just keep pressing Ctrl + R.

4. Free Your Hands with Aliases#

If you find yourself frequently typing long commands, like git commit -m "update", you must set up aliases.

Edit your ~/.zshrc file:

# Quick commit
alias gcm="git commit -m"
# Quick status check
alias gs="git status"
# Show hidden files with human-readable sizes
alias ll="ls -lah"
# Quick flush DNS cache
alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"

After saving, run source ~/.zshrc. From now on, you only need to type gcm "message".

5. open . - Open the Current Folder Graphically#

Sometimes manipulating files in the terminal gets tiring, and you just want to use Finder to drag and drop files. Just type:

open .

macOS will immediately pop up a Finder window displaying the exact directory your terminal is currently in. This trick is especially handy when managing blog image assets.


Summary#

The purpose of tools is to serve people. While these terminal tips may seem minor, the few seconds saved every day accumulate into a massive efficiency boost.

Share

If this article helped you, please share it with others!

5 Terminal Tips to Boost macOS Efficiency
https://blog.levifree.com/posts/macos-terminal-tips/
Author
LeviFREE
Published at
2025-04-12
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents