Command Line Introduction
What is the Command Line?
The Command Line Interface (CLI) is a means of interacting with a computer via text commands. While it seems that the CLI is archaic compared to GUIs (Graphical User Interfaces) it’s actually a very powerful tool for interacting with files and programs, and many of the tasks we need to complete as programmers will happen via command line.
To get your command line program running on your computer, jump to the appropriate instructions:
Once command is running, continue to the Command Line Primer.
Mac - Terminal
Mac comes with a command line program called Terminal. You can locate it via Spotlight (command + space
) by searching for Terminal.
Once Terminal is open, right click it in your dock and choose Options > Keep in Dock so it’s always accessible.
If when you first open Terminal you see the following message:
The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`
...follow the instructions and run the command chsh -s /bin/zsh
to update your default shell. A shell is basically the system that is working “under the hood” in Terminal, and for consistency we all want to be using zsh.
Under Terminal Settings > Profiles, you can choose a default color profile for your Terminal window:
To improve your prompt so it includes your current working directory, run one of the following commands...
If you are using the dark theme, use this command, which sets your default text color to white:
echo "PROMPT='%F{magenta}%/ %F{white}%f %F{white}$ '" >> ~/.zshrc
If you are using the light theme, use this command which sets your default text to black:
echo "PROMPT='%F{magenta}%/ %F{black}%f %F{black}$ '" >> ~/.zshrc
After running one of the above commands, close and re-open Terminal to see the changes take effect.
Windows - Git Bash
Windows comes with a couple built-in command line programs (Command Prompt, PowerShell), but they don’t have the functionality we’ll need.
Instead, you should download Git for Windows, which includes Git Bash, a command line program that will fit our needs for this course.
Download here:
→ https://git-scm.com/downloads
Once Git is installed, you can open Git Bash by searching for it. Once Git Bash is open, right click its icon in your taskbar and choose Pin to taskbar so it’s always accessible.