finished lesson 2, started 3

This commit is contained in:
ronny abraham 2025-02-19 04:38:34 +02:00
parent 8cb56d003f
commit 679d9a996a
4 changed files with 293 additions and 29 deletions

View file

@ -1,7 +1,7 @@
@use "sass:map" @use "sass:map"
@use "sass:color" @use "sass:color"
@use 'org-media-sass/default-org-mode' @use 'org-media-sass/org-base' as *
@use 'org-media-sass/themes/desert-oasis' as * @use 'org-media-sass/themes/desert-oasis' as *
@use 'org-media-sass/fonts' as fonts @use 'org-media-sass/fonts' as fonts

@ -1 +1 @@
Subproject commit c51abd0a595cc9c782198b43620acc29c411acd6 Subproject commit 9a1a53af49c8a887dd129e9ade15f7b49cae1a13

View file

@ -2,6 +2,7 @@
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" /> #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" />
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" /> #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" />
#+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script> #+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script>
#+OPTIONS: H:6
* Links * Links
#+attr_html: :class links #+attr_html: :class links
@ -31,8 +32,8 @@
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][28:27 - man command]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=1707s][28:27 - man command]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][31:26 - finding files]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2175s][31:26 - finding files]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][36:30 - grep]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2190s][36:30 - grep]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][42:53 - fuzzy finder]] *current* + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2573s][42:53 - fuzzy finder]]
+ [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][44:09 - history substring search]] + [[https://www.youtube.com/watch?v=kgII-YWo3Zw&t=2649s][44:09 - history substring search]] *current*
* Notes * Notes
@ -359,3 +360,273 @@ shellcheck some_bash_script.sh
- ag - ag
** fuzzy finder ** fuzzy finder
*** Overview of fzf
fzf is a fuzzy finder for the command line. It allows quick searching through lists (files, command history, processes, etc.) using an interactive interface. Unlike traditional search tools that require exact matches, fzf uses fuzzy matching, meaning you only need to type parts of what you're looking for, and it will find the closest match.
*** Why Use fzf?
- Fast and efficient, even for thousands of files or lines.
- Highly customizable, works with various CLI tools (find, grep, git, history, etc.).
- Interactive, allowing navigation with arrow keys or Ctrl-N / Ctrl-P.
- Minimal setup required, just install and start using it.
*** Test Commands to Try in fzf
**** Basic Usage
1. **Search files in the current directory**
#+begin_src sh
fzf
#+end_src
Opens an interactive search where you can start typing to filter through files.
2. **Search your command history**
#+begin_src sh
history | fzf
#+end_src
Lets you browse and select previously used commands.
3. **Find and open a file in Vim**
#+begin_src sh
vim $(fzf)
#+end_src
Searches for a file and opens it in Vim.
4. **Search running processes**
#+begin_src sh
ps aux | fzf
#+end_src
Lets you search for running processes.
5. **Find a Git-tracked file**
#+begin_src sh
git ls-files | fzf
#+end_src
Searches only files tracked by Git.
**** Advanced Usage
6. **Find and delete a file**
#+begin_src sh
rm -i $(fzf)
#+end_src
Select a file to delete (prompts before deletion).
7. **Search and kill a process**
#+begin_src sh
kill -9 $(ps aux | fzf | awk '{print $2}')
#+end_src
Finds a process and terminates it.
8. **Use fzf with ripgrep (fast file search)**
#+begin_src sh
rg --files | fzf
#+end_src
Searches only through files tracked by ripgrep.
9. **Preview file contents while searching**
#+begin_src sh
fzf --preview "bat --style=numbers --color=always {}"
#+end_src
Uses bat (a better cat) to preview file contents.
*** Customizing fzf
**** Set up a keybinding (Ctrl+T) to trigger fzf for file selection
#+begin_src sh
bind '"\C-t": "fzf\n"'
#+end_src
**** Change fzf options to improve display
#+begin_src sh
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
#+end_src
- --height 40%: Shows results in a smaller window.
- --layout=reverse: Shows matches from the bottom up.
- --border: Adds a visible border.
*** Final Thoughts
- fzf is a powerful tool for navigating files, commands, and processes.
- Once installed, just type fzf anywhere in the terminal and start filtering.
- Combine it with other commands for maximum efficiency.
** tree
*** Overview of tree
tree is a command-line utility that displays directory structures in a tree-like format. It recursively lists files and directories, making it useful for visualizing folder hierarchies.
*** Why Use tree?
- Provides a clear hierarchical view of files and directories.
- Supports filtering by file type, depth, and patterns.
- Can output results in various formats such as JSON and XML.
- Useful for quickly understanding directory structures.
*** Test Commands to Try in tree
**** Basic Usage
1. **Display the directory structure from the current location**
#+begin_src sh
tree
#+end_src
Lists all files and folders in a tree format.
2. **Limit the depth of displayed directories**
#+begin_src sh
tree -L 2
#+end_src
Shows only two levels of the directory structure.
3. **Show hidden files in the tree**
#+begin_src sh
tree -a
#+end_src
Displays all files, including hidden ones (those starting with a dot).
4. **Display file sizes and permissions**
#+begin_src sh
tree -h -p
#+end_src
Shows human-readable file sizes along with permission flags.
5. **List only directories**
#+begin_src sh
tree -d
#+end_src
Displays only directories, excluding files.
**** Advanced Usage
6. **Output the tree structure to a file**
#+begin_src sh
tree > structure.txt
#+end_src
Saves the tree output to a text file for later reference.
7. **Generate JSON output**
#+begin_src sh
tree -J
#+end_src
Outputs the directory structure in JSON format.
8. **Filter by file extension**
#+begin_src sh
tree -P "*.txt"
#+end_src
Lists only `.txt` files within the directory structure.
9. **Exclude certain files or directories**
#+begin_src sh
tree -I "node_modules"
#+end_src
Hides the `node_modules` directory from the output.
*** Customizing tree
**** Set an alias for a commonly used tree command
#+begin_src sh
alias t2="tree -L 2"
#+end_src
Creates an alias `t2` to quickly show two levels of the directory.
**** Change default colors in tree output
#+begin_src sh
export TREE_COLORS="di=1;34:ln=1;36:fi=0;37"
#+end_src
Customizes the colors used in the tree display for directories, links, and files.
*** Final Thoughts
- tree is a powerful tool for quickly understanding directory structures.
- It is useful for documentation, debugging, and navigating complex file systems.
- The command supports various output formats, filtering, and customization options.
** broot
*** Overview of broot
broot is a command-line tool for navigating and managing directory structures efficiently. It provides a tree-like view of files and directories while allowing fuzzy searching, filtering, and file operations within the terminal.
*** Why Use broot?
- Provides an interactive tree view of directories with better readability than `ls` or `tree`.
- Allows fuzzy searching and filtering of files and directories.
- Supports file operations (e.g., rename, delete, move) directly from the interface.
- Can replace `cd` by letting you navigate and enter directories quickly.
- Supports customizable keybindings and themes.
*** Test Commands to Try in broot
**** Basic Usage
1. **Launch broot**
#+begin_src sh
broot
#+end_src
Opens an interactive directory tree view.
2. **Navigate the file system with fuzzy search**
#+begin_src sh
broot
#+end_src
Start typing part of a file or directory name to filter results.
3. **Enter a directory from broot**
#+begin_src sh
br
#+end_src
If `br` is set up as a shell function, it allows `cd` replacement.
4. **Show hidden files**
#+begin_src sh
broot --hidden
#+end_src
Displays hidden files and directories.
5. **Only show directories**
#+begin_src sh
broot --only-folders
#+end_src
Filters out non-directory files from the view.
**** Advanced Usage
6. **Perform file operations within broot**
- Press `:rename` to rename a file.
- Press `:delete` to remove a file.
- Use `:move target_directory` to move a file.
7. **Find and open a file in an editor**
#+begin_src sh
broot --cmd "edit file_name"
#+end_src
Searches and opens a file using the default editor.
8. **Integrate broot with `cd` command**
#+begin_src sh
broot --install
#+end_src
Enables `br` to work as a replacement for `cd`.
9. **Customize broot settings**
#+begin_src sh
broot --edit-conf
#+end_src
Opens the broot configuration file for customization.
*** Customizing broot
**** Change default display options
#+begin_src sh
broot --set-default-flags "gh"
#+end_src
Sets the default view to show hidden files and a grid layout.
**** Define a shortcut for frequently used commands
#+begin_src sh
alias bcd='broot --cmd "cd"'
#+end_src
Creates an alias to quickly navigate directories.
*** Final Thoughts
- broot is a powerful alternative to `ls`, `tree`, and `cd`, offering an interactive way to browse and manage files.
- With fuzzy search and built-in file operations, it enhances productivity for command-line users.
- Customization options allow tailored keybindings and themes for better usability.

View file

@ -1,38 +1,31 @@
#+title: Lesson 02 | shell tools and scripting #+title: Lesson 03 | text editors (vim)
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" /> #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/missing-semester.css" />
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" /> #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../_share/media/css/org-media-sass/collapsible.css" />
#+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script> #+HTML_HEAD: <script src="../_share/media/js/collapsible.js"></script>
#+OPTIONS: H:6
* Links * Links
#+attr_html: :class links #+attr_html: :class links
- [[../toc.org][TOC | Missing Semester]] - [[../toc.org][TOC | Missing Semester]]
- [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]] - [[https://www.youtube.com/playlist?list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J][Playlist: Missing Semester]]
- [[https://missing.csail.mit.edu/2020/editors/][class notes]]
* Notes - Curr: https://www.youtube.com/watch?v=a6Q8Na575qc
*** Playlist *** timestamps
:PROPERTIES:
:CUSTOM_ID: timestamp
:END:
#+attr_html: :class playlist #+attr_html: :class playlist
1. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=20s][why we're doing this class]] + [[https://www.youtube.com/watch?v=a6Q8Na575qc][00:00 - introduction]]
2. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=251s][the shell]] + [[https://youtu.be/a6Q8Na575qc?si=qzD5HiycrEhplKeQ&t=285][04:45 - modal editor]]
3. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=338s][install a terminal and a shell]] + [[https://youtu.be/a6Q8Na575qc?si=ra-MbPQpbKzAcJnP&t=571][09:30 - opening vim]]
4. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=411s][shell prompt]] + [[https://youtu.be/a6Q8Na575qc?si=OyhOfX2ft9w7O9kM&t=1020][17:00 - buffers vs windows]]
5. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=522s][how does the shell know what these programs are]] + [[https://youtu.be/a6Q8Na575qc?si=gaek6N0DJo57AwKn&t=1407][23:25 - movement keys]]
6. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=672s][paths]] + [[https://youtu.be/a6Q8Na575qc?si=_gbAQlOZ_irCdHt6&t=1797][29:54 - questions]]
7. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=738s][absolute path]] + [[https://youtu.be/a6Q8Na575qc?si=4VwNEC040Jna5znz&t=2254][37:33 - demo]]
8. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=759s][relative paths]] + [[https://youtu.be/a6Q8Na575qc?si=0qDOcyT0WX1U4RXB&t=2682][44:42 - vim configuration]]
9. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1034s][tilde character]]
10. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1336s][directories]] * notes
11. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1376s][execute on directories]]
12. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1514s][cp command]]
13. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1547s][rm]]
14. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1590s][create a new directory]]
15. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=1912s][pipe character]]
16. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2044s][grep]]
17. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2145s][the root user]]
18. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2239s][kernel paramters]]
19. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2612s][scroll lock led]]
20. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2706s][open a file]]
21. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2829s][lecture notes]]
22. [[https://www.youtube.com/watch?v=Z56Jmr9Z34Q&list=PLyzOVJj3bHQuloKGG59rS43e29ro7I57J&t=2875s][office hours]]