Skip to content

Commit

Permalink
bash chapters are updated
Browse files Browse the repository at this point in the history
  • Loading branch information
critmcdonald committed Jul 12, 2023
1 parent 537abc6 commit bb1dd28
Show file tree
Hide file tree
Showing 44 changed files with 1,330 additions and 431 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ $RECYCLE.BIN/

# End of https://www.gitignore.io/api/macos,windows
/.quarto/
.Rproj.user
2 changes: 2 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ book:
format:
html:
theme: cosmo
code-overflow: wrap

2 changes: 1 addition & 1 deletion bash-00-intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This lesson is a beginner's guide to using **command-line interface** tools for

I use a Mac, and there are some differences for Windows users. The first major difference is Windows users have to install Git (and Git Bash, which comes with it) before we can go much further.

::: {.callout-caution collapse="true"}
::: {.callout-caution}
## Windows uses must install Git first

Windows users have to install Git and Git Bash before doing moving forward with this lesson. These next few steps do that.
Expand Down
94 changes: 94 additions & 0 deletions bash-01-terminal.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bash\n",
"\n",
"## Terminal vs shell\n",
"\n",
"Terminal (Mac) and Git Bash (Windows) are programs that can run a **shell**, which is a text-based user interface where you type commands that your computer understands.\n",
"\n",
"::: callout\n",
"People (including myself) will use the term **shell** and **terminal** interchangeably. This means when I say \"type into your shell\" or \"in your terminal\", I mean type at the prompt in your Terminal or Git Bash program. (Just to add confusion, I use a different Mac terminal program called iTerm, but Terminal is fine.)\n",
":::\n",
"\n",
"Developers use a shell to issue commands to their computer to do things, like install programs, change what folder their are in, etc. Using a terminal program to use your computer can be confusing at first, but it will become second-nature as you progress through this class.\n",
"\n",
"The shell programming language we will use for these text-based interactions is called **Bash**.\n",
"\n",
"**Windows** doesn't understand Bash at all without the help of another program. This is why we installed **Git Bash** so we can all speak the same language. (If you are a Windows user and haven't yet installed Git, [do it now](bash-00-intro.qmd).)\n",
"\n",
"For what its worth, Bash is a Unix-based program. Most of the Internet runs on Unix (or Linux) computers.\n",
"\n",
"**Macs** understand Bash natively, but some day they will change to a similar language called zsh. When you launch a shell on newer Macs you might get a message _The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`._ **DON'T DO THIS! JUST IGNORE IT.** We will continue to use **Bash**. Later we will add a command to disable this message. If somehow your terminal gets set to use zsh, you can [check and/or change it to Bash](a-macos-shell.qmd).\n",
"\n",
"## Launch your terminal\n",
"\n",
"::: {.panel-tabset}\n",
"\n",
"## macOS\n",
"\n",
"1. For **Macs** you can use your Launchpad and type in _Terminal_ and launch it. Or you can use the Spotlight search to find it.\n",
"\n",
"It will look like this:\n",
"\n",
"![Mac Terminal](images/terminal-startup.png)\n",
"\n",
"Though it may have a white screen.\n",
"\n",
"\n",
"## Windows\n",
"\n",
"1. For **Windows** you can go to your Start menu and type in _Git Bash_ and launch it.\n",
"\n",
"It will look like this:\n",
"\n",
"![Windows Git Bash](images/gitbash-startup.png)\n",
"\n",
":::\n",
"\n",
"\n",
"## The terminal prompt\n",
"\n",
"When I launch my terminal, the commands inside it look like this:\n",
"\n",
"\n",
"```{bash}\n",
"COMMA21617:~ ccm346$\n",
"```\n",
"\n",
"\n",
"- The first part before the `~` is my computer name\n",
"- The part after the `~` is is my username.\n",
"- Lastly we have the `$`. This is the \"prompt\" where you type commands. You type your commands AFTER the $ and then hit **Return** to execute them.\n",
"\n",
"If you see a direction for a command that includes an output, you might see the `$` before the command. DON'T TYPE IN THE $. For instance:\n",
"\n",
"\n",
"```{bash}\n",
"$ pwd\n",
"/Users/ccm346/Documents/icj/myproject\n",
"```\n",
"\n",
"\n",
"Means you type in just \"pwd\" and then hit return.\n",
"\n",
"## Typing vs copy/paste\n",
"\n",
"I encourage you to type commands into your terminal instead of copy and pasting them from the lessons. Build muscle _and_ mind memory. Typing a command wrong and then having to figure out why it broke will help you learn it and remember it. If you just copy and paste blindly, then you won't learn anything other than **command-c** and **command-v**."
],
"id": "29931060"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
41 changes: 28 additions & 13 deletions bash-01-terminal.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,67 @@

Terminal (Mac) and Git Bash (Windows) are programs that can run a **shell**, which is a text-based user interface where you type commands that your computer understands.

> People (including myself) will use the term **shell** and **terminal** interchangeably. This means when I say "type into your shell" or "in your terminal", I mean type at the prompt in your Terminal or Git Bash program. (Just to add confusion, I use a different Mac terminal program called iTerm, but Terminal is fine.)
::: callout
People (including myself) will use the term **shell** and **terminal** interchangeably. This means when I say "type into your shell" or "in your terminal", I mean type at the prompt in your Terminal or Git Bash program. (Just to add confusion, I use a different Mac terminal program called iTerm, but Terminal is fine.)
:::

Developers use a shell to issue commands to their computer to do things, like install programs, change what folder their are in, etc. Using a terminal program to use your computer can be confusing at first, but it will become second-nature as you progress through this class.

The shell programming language we will use for these text-based interactions is called **Bash**.

**Windows** doesn't understand Bash at all without the help of another program. This is why we installed **Git Bash** so we can all speak the same language. (If you are a Windows user and haven't yet installed Git, [do it now](https://github.com/utdata/icj-setting-up/blob/master/windows-01.md#install-git).)
**Windows** doesn't understand Bash at all without the help of another program. This is why we installed **Git Bash** so we can all speak the same language. (If you are a Windows user and haven't yet installed Git, [do it now](bash-00-intro.qmd).)

For what its worth, Bash is a Unix-based program. Most of the Internet runs on Unix (or Linux) computers.

**Macs** understand Bash natively, but some day they will change to a similar language called zsh. When you launch a shell on newer Macs you might get a message _The default interactive shell is now zsh. To update your account to use zsh, please run `chsh -s /bin/zsh`._ **DON'T DO THIS! JUST IGNORE IT.** We will continue to use **Bash**. Later we will add a command to disable this message. If somehow your terminal gets set to use zsh, you can [check and/or change it to Bash](a-macos-shell.qmd).

## Launch your terminal

::: {.panel-tabset}

## macOS

1. For **Macs** you can use your Launchpad and type in _Terminal_ and launch it. Or you can use the Spotlight search to find it.

It will look like this:

![Mac Terminal](../../images/terminal-startup.png)
![Mac Terminal](images/terminal-startup.png)

Though it may have a white screen.


## Windows

1. For **Windows** you can go to your Start menu and type in _Git Bash_ and launch it.

It will look like this:

![Windows Git Bash](../../images/gitbash-startup.png)
![Windows Git Bash](images/gitbash-startup.png)

:::


## The terminal prompt

When I launch my terminal, the commands inside it look like this:

```bash
```
COMMA21617:~ ccm346$
```

The first part before the `~` is my computer name, and the part after is my username.

> I actually shorten my prompt name to `crit:~$` so you'll see that in my examples. We'll shorten yours later, too.
- The first part before the `~` is my computer name
- The part after the `~` is is my username.
- Lastly we have the `$`. This is the "prompt" where you type commands. You type your commands AFTER the $ and then hit **Return** to execute them.

Lastly we have the `$`. This is the "prompt" where you type commands. You type your commands AFTER the $ and then hit **Return** to execute them.
If you see a direction for a command that includes an output, you might see the `$` before the command. DON'T TYPE IN THE $. For instance:

When I give command instructions for you to type, I sometimes (but not always) include the `$` at the beginning to indicate this should go at the prompt in your terminal. DON'T TYPE IN THE $. For instance:

`$ pwd`
```
$ pwd
/Users/ccm346/Documents/icj/myproject
```

Means you type in just "pwd" and then hit return.

## Typing vs copy/paste

I encourage you to type commands into your terminal instead of copy and pasting them from the lessons. Build muscle _and_ mind memory. Typing a command wrong and then having to figure out why it broke will help you learn it and remember it. If you just copy and paste blindly, then you won't learn anything other than command-c and command-v.
I encourage you to type commands into your terminal instead of copy and pasting them from the lessons. Build muscle _and_ mind memory. Typing a command wrong and then having to figure out why it broke will help you learn it and remember it. If you just copy and paste blindly, then you won't learn anything other than **command-c** and **command-v**.
Loading

0 comments on commit bb1dd28

Please sign in to comment.