Your tools
The Mac, the Terminal and Visual Studio Code: the basics for the workshop
New to the Mac, the Terminal or Visual Studio Code? This page has what you need for the workshop, and nothing more. Watch the two-minute video (Figure 1), then keep the page open in a browser tab.
The Mac
The keys
⌘ Command ⌃ Control ⌥ Option ⇧ Shift
On a Mac, ⌘ Command does what Ctrl does on Windows and Linux:
| Press | To |
|---|---|
| ⌘ C | copy |
| ⌘ V | paste |
| ⌘ S | save |
| ⌘ Z | undo |
| ⌘ W | close the window or tab |
| ⌘ Q | quit the app (closing its window does not quit it) |
| ⌘ Tab | switch to another app |
| ⌘ Space | search for an app or a file (Spotlight) |
To stop a running program, such as the simulator, press ⌃ Control C, not ⌘ C: in the Terminal, ⌘ C only copies.
The trackpad
- Click: press down anywhere on the trackpad (or tap it, if tap to click is on).
- Right-click: click with two fingers, or hold ⌃ Control and click.
- Scroll: slide two fingers up or down.
- Switch between full-screen apps: swipe left or right with three or four fingers.
- See all open windows (Mission Control): swipe up with three or four fingers, or press ⌃ Control ↑. Click a window to bring it to the front.
Open an app
- Press ⌘ Space: a search bar appears (Spotlight).
- Type
Terminal, orVisual Studio Code. - Press ↩︎ Return.
An open app has a small dot under its icon in the Dock, the row of icons at the bottom of the screen.
Where your files are
Everything for the workshop is in one folder, dotbot-academy, in your home folder: the folder named after your user, which the Terminal writes ~. Your scripts go there, next to academy.py (Figure 2).
~/dotbot-academy. Finder hides .venv, as it hides every name that starts with a dot.
To open it in Finder:
- Open Finder (the blue face in the Dock), press ⌘ ⇧ Shift H to go to your home folder, then double-click
dotbot-academy. - Or, in a Terminal already in the folder, type
open .and press ↩︎ Return.
The Terminal
The Terminal is a window where you type commands instead of clicking: type a command, press ↩︎ Return, and it runs in the folder you are in.
| Type | To |
|---|---|
cd ~/dotbot-academy |
go into the workshop folder |
pwd |
show which folder you are in |
ls |
list the files in this folder |
open . |
open this folder in Finder |
python hello.py |
run your script |
| Press | To |
|---|---|
| Tab | complete a file or folder name: type hel, then Tab |
| ↑ | bring back the last command; press again for earlier ones |
| ⌃ Control C | stop the running program |
| ⌘ N | open a new Terminal window |
| ⌘ T | open a new tab in this window |
To run a command from this site, copy it with the button at the top right of its block, paste it in the Terminal with ⌘ V, and press ↩︎ Return.
Two Terminal windows
During the workshop you always have two Terminal windows open, side by side (Figure 3): one runs the simulator, the other runs your scripts.
Leave it running. ⌃ Control C stops it.
Run every script here.
(.venv) at the start of the prompt.
In each window, first go to the folder and turn on the Python environment:
cd ~/dotbot-academy
source .venv/bin/activateThen, in window 1, start the simulator and leave it running; in window 2, run your scripts.
Is the environment on?
Look at the start of the prompt, the line where you type: when the environment is on, it starts with (.venv). A new window or tab starts without it, so run the two lines above in every new one.
You ran it in a window where the environment is not on: no (.venv) at the start of the prompt. Run the two lines above in that window, then your command again.
Visual Studio Code
You write your scripts in Visual Studio Code (VS Code) and run them in the Terminal, in window 2.
Open the workshop folder
- Open VS Code: ⌘ Space, type
Visual Studio Code, ↩︎ Return. - Choose File > Open Folder…, select
dotbot-academyin your home folder, and click Open. - If VS Code asks whether you trust the authors of the files, click Yes, I trust the authors.
The folder’s files are now in the Explorer, on the left (Figure 4). Two other ways to open it: drag the dotbot-academy folder from Finder onto the VS Code icon in the Dock, or type code . in a Terminal in the folder. code works only once it is installed: in VS Code, press ⌘ ⇧ Shift P, type Shell Command: Install 'code' command in PATH, and press ↩︎ Return.
Opening the folder is all the workshop needs. File > Add Folder to Workspace… adds a second folder next to it, should you ever want one.
dotbot-academy open: the Explorer on the left, hello.py in the editor. The dot on its tab means it has unsaved changes.
Open, create and save files
- Open a file: double-click it in the Explorer. A single click opens a preview, its name in italics on the tab, which the next file you click replaces.
- Create a file: right-click an empty spot in the Explorer, choose New File…, type its name (
hello.py) and press ↩︎ Return. - Save: ⌘ S. A dot on the tab, instead of the ×, means unsaved changes: the Terminal runs the last saved version, so save before you run.
- No Explorer on the left? Press ⌘ ⇧ Shift E.
Run your scripts from the Terminal with python hello.py, not with VS Code’s ▷ Run button, which may use another Python, without DotBot. You can ignore VS Code’s pop-ups suggesting extensions.
Optional: the terminal inside VS Code
VS Code has its own terminal: View > Terminal, or ⌃ Control `. It works like the Terminal app, two lines first included: cd ~/dotbot-academy, then source .venv/bin/activate. This site uses the Terminal app.
Back to the workshop
The hands-on part starts at step 3, with the two windows. All the steps are in the sidebar, from step 1.