Skip to content

Latest commit

 

History

History
250 lines (166 loc) · 5.44 KB

File metadata and controls

250 lines (166 loc) · 5.44 KB

Lecture 3

The command line


Reading responses

They are great! Will talk through some of them at the end, if we have time.


CLI

Command line interface


Terminals


We'll be using the following in the VSCode integrated terminal:

  • Windows: Git BASH
  • macOS: Bash/zsh

Open it up.


Distributions


"It's a UNIX system!" clip from Jurassic Park

subtitles on


Examples

  • Darwin (macOS)
  • Debian
  • Ubuntu
  • Mint
  • Fedora
  • Red Hat Enterprise Linux (RHEL)

Paths

  • Separators:
    • Windows (outside of Git BASH): \
    • macOS/Linux: /
  • . - current directory
  • .. - parent directory
  • Absolute vs. relative

Navigation

  • pwd - path of working directory
  • ls - list files
    • ls -al - list all files (with dotfiles) with more details
  • cd - change directory
  • Mac:
    1. From Finder, right-click on folder
    2. Click Services
    3. Click New Terminal at Folder

Control-r allows you to search your command history


Working with files

  • Viewing
    • cat
    • less
  • mv
  • cp
  • mkdir
  • rmdir
  • find
  • Editing
    • nano
    • vim

If files have spaces or special characters, need to put quotes around them.

  • Best to avoid these when naming files, sticking to:
    • Letters
    • Numbers
    • Periods
    • Hyphens
    • Underscores
  • For Python files, snake case is most common.

Cases

  • snake_case
  • TitleCase
  • camelCase

Exiting/quitting

  • less: q
  • nano: control-x
  • vim: escape, then :q!
  • Other command line tools: control-c

Worst case, close your Terminal, and that will kill whatever process was running.


Other shell stuff

  • echo
    • echo abc | less
  • Exit codes
    • echo $?
  • Environment variables
  • which
    • which jupyter
    • which -a python3
  • $PATH
  • Pipes
    • ls | xargs cat
  • Redirecting output
  • grep
  • sudo
  • man

Example

Uses a "wildcard":

  1. find . -name 'lecture_*.md'
  2. find . -name 'lecture_*.md' | sed -E 's/([0-9]{2})/0\1/'

Shells

  • PowerShell
  • Bash
  • zsh
echo $SHELL

Getting fancy


Dependency/package management

Done through package managers


Python


Operating system



Reading response questions


Workflow & coordination

  • I am curious if there is a way to sync with the home database without doing it manually once in a while. It seems a bit annoying to have to deal with it regularly.
  • At what point does the proliferation of branches and pull requests begin to introduce coordination overhead, rather than reducing it?
  • If a team hits a WIP limit in a very specialized area, how can generalist team members realistically help clear that bottleneck if they lack the specific expertise?

Planning & merge conflicts

  • While the readings emphasize how safe branches are, I'm curious what are the best practices for the planning phase when multiple branches inevitably need to touch the same files? I'm interested in how teams avoid messy merge conflicts before they happen.

Terminology

  • What's the difference between command line interface, terminal, shell, and bash?

Note to self: Send terminal commands+output.