You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: notes/2023-10-24.md
+84-30Lines changed: 84 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -500,6 +500,7 @@ important_classes.py
500
500
setup.py
501
501
```
502
502
503
+
And this is as `ls` except without the folders:
503
504
504
505
```{code-cell} bash
505
506
:tags: ["skip-execution"]
@@ -513,24 +514,19 @@ LICENSE.md docs setup.py
513
514
README.md filecheck.sh tests
514
515
```
515
516
517
+
```{important}
518
+
We also looked at the structure and some examples of the action files in the KWL repo and course website.
516
519
517
-
```{code-cell} bash
518
-
:tags: ["skip-execution"]
519
-
cd ../fall2023/
520
-
```
521
-
522
-
```{code-block} console
520
+
I recommend the docs, starting from the [quickstart](https://docs.github.com/en/actions/quickstart) and the [understand section](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions)
523
521
```
524
522
523
+
## Using GH
525
524
526
525
```{code-cell} bash
527
526
:tags: ["skip-execution"]
528
-
gh repo view --web
527
+
cd ../fall2023/
529
528
```
530
529
531
-
```{code-block} console
532
-
Opening github.com/introcompsys/fall2023 in your browser.
533
-
```
534
530
535
531
536
532
```{code-cell} bash
@@ -549,6 +545,7 @@ Showing 5 of 5 open pull requests in introcompsys/fall2023
549
545
#5 Added question to 9 26 n... NoahV17:added-question-t... about 23 days ago
550
546
```
551
547
548
+
Grep can search content, so with a pipe we can use it to filter results.
552
549
553
550
```{code-cell} bash
554
551
:tags: ["skip-execution"]
@@ -559,13 +556,27 @@ gh pr list | grep sample
559
556
12 sample proposals for 212 docs build 212build OPEN 2023-10-14 17:02:14 +0000 UTC
560
557
```
561
558
559
+
## Terminal coloring and customizing your prompt.
560
+
561
+
Your path settings, aliases, and the your prompt can be set with a file.
562
+
563
+
On MacOS the file is called `.bash_profile` and is stored at your `~` home directory. If you use `zsh` instead of bash there is a different file, but it is similar.
564
+
565
+
On linux it is `.bashrc` it should be the same in WSL on Windows.
566
+
567
+
```{admonition} Community Badge opportunity
568
+
If you use windows, can you PR to update these notes with what file is used and which terminal/shell you are using (bash via GitBash, powershell, bash in WSL, etc. )
569
+
```
562
570
563
571
```{code-cell} bash
564
572
:tags: ["skip-execution"]
565
573
cat ~/.bash_profile
566
574
```
567
575
568
-
## Terminal coloring and customizing your prompt.
576
+
577
+
I have some aliases set, this way when I use Python, I can use the `python` command instead of `python3`.
578
+
579
+
the `PS1` variable describes the main default prompt, according to [the spec](https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html). [this tool can help you customize your prompt](https://bash-prompt-generator.org/)
### How often will we be writing scripts for this class?
618
630
619
-
```{include} ../_review/2023-10-24.md
620
-
```
631
+
Just a few times to get practice and exposure, but they will come back in 412 and are handy in general.
621
632
633
+
### Are bash scripts commonly used today in real world applications or is it something that was used more in the 70s?
622
634
635
+
They are still super common. GitHub actions can be written using bash scripting as a strategy. Lots of systems have build scripts.
623
636
624
-
## More Practice
637
+
The thing we would not do that often that we did today was write it from nano instead of a full IDE.
625
638
626
-
```{include} ../_practice/2023-10-24.md
627
-
```
639
+
### What is the scope of loop variables?
628
640
641
+
In bash the loop variable has the same scope as any other variable. It is the same in Python. This is one of the many features that can very from language to language.
629
642
643
+
### When would I use bash instead of a different programming language?
630
644
631
-
## Experience Report Evidence
645
+
When you need to do things that are file operations or other os level actions, it can be faster to run if it is in bash.
646
+
647
+
### What specific tasks do developers like to use bash to automate?
648
+
649
+
build processes, file manipulations, git operations. Anything even just a few steps that would be repetitive and you would have to do often.
650
+
651
+
### do people write full programs in bash using things like nano or directly into the terminal?
652
+
653
+
Yes! Some people especialy people who started programming a long time ago still do.
654
+
655
+
More often, using a terminal text editor is a handy tool to use on occasion, but not for every day work. We will work on a remote server, which is an occasion you would use that, on Thursday.
656
+
657
+
### Is there a way to save files that you create in the shell?
658
+
659
+
yes, today we saved the filecheck.sh file.
660
+
661
+
### what else can we do with bash?
662
+
663
+
Its mostly for automating things and processing files or outputs.
664
+
665
+
It *can* do anything though.
666
+
667
+
### Does running a bash script with `bash <filename>`` remove the need to add #!/bin/bash to the top of it and then make it executable prior to running?
668
+
669
+
Yes. by running it like `bash <filename` it works just like passing those lines in the file to bash.
670
+
671
+
Alternatively you can put the shebang `#!/bin/bash` at the top to tell the computer what shell to use to run it and then treat it as an executable.
672
+
673
+
We will learn about making it executable permissions wise on Thursday.
674
+
675
+
676
+
### Is it possible to create functions in bash scripts?
677
+
678
+
Yes! [see the GNU bash docs on functions](https://www.gnu.org/software/bash/manual/html_node/Shell-Functions.html)
679
+
680
+
681
+
### Where would we see bash the most as a developer? Would we use this language more for an embedded swe role or is it something that's present in every type of programming job.
682
+
683
+
I think it's present in just about any programming job. You will always need to work with files at times, you will alwasy have repetitive things that you do not want to do manually. You may write more or less, but it's alwasy a handy tool to have.
684
+
685
+
### Where could I learn more about writing something similar to the workflows we saw?
632
686
633
-
## Questions After Today's Class
687
+
The [github actions documentation](https://docs.github.com/en/actions) has instructions with how tos, API like documentation, and examples.
0 commit comments