Navigating your environment
I barely ever use Finder on my Mac anymore as navigating your directory structure on your machine is super easy with the command line (even easier with shortcuts - more on that later).
Change directory to your machine's root, for example:
Back up one directory:
List contents in a directory:
List contents in a directory, with full detail:
Creating files and directories is easy too - I often create a bunch via the command line before starting a project.
Create a directory (and head into it):
Note: Performing commands one after another with && makes things a little quicker too.
mkdir yourProject && cd yourProject
Create a file:
Write to a file (also creates files if it doesn't exist):
echo "Hello, World!" > index.html
Open a file:
Open the directory you’re in:
Searching your previous commands can be useful if your workflow involves a lot of repetition.
If you want to repeat a command you know you did a little while ago:
List a specific number of commands:
To search your history:
history | grep git
Where git is your search term.
When your command history comes back they'll all have indexes beside them, so to run one of the commands in the list use:
To run number 12 in the list for example.
You may know
sudo for overriding privileges, running as an admin when you execute commands, but this pretty handy tip is to hit:
When you've tried to do something that fails without the correct privileges.
This simply repeats the previous command with superuser privileges.
- Don't use Finder for a day
- Create some shortcuts in your .bash_profile for your most frequently used navigational commands
- See how much quicker it is!
- Then comment below and let me know how you got on!