Skip to content

Commit

Permalink
docs: typo cleanup on chapter 24/25
Browse files Browse the repository at this point in the history
  • Loading branch information
dwmkerr committed Apr 28, 2022
1 parent dd40c64 commit 674e408
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ You can list the options available to set by running `shopt -p`, or searching th
| `checkjobs` | Show the status of stopped and running jobs before exiting the shell. |
| `cmdhist` | Save multi-line commands in the shell history as single entries, rather than an entry per line. |
| `dirspell` | Try to correct typos when auto-completing directory names. |
| `globstar` | Support recurive globbing such as `**/*.py` to find files in subdirectories. |
| `globstar` | Support recursive globbing such as `**/*.py` to find files in subdirectories. |
| `histappend` | Append to the history file when the shell exists, rather than overwriting it. |

As well as the options that can be set using the `shopt` command, there are also many variables that are used to configure the shell. We've seen some of these variables already, such as the `EDITOR` variable that defines what text editor to use and the `PAGER` variable that defines what pager program to use.
Expand Down Expand Up @@ -241,7 +241,7 @@ You may have seen references to files such as _/etc/profile_, _~/.bash_profile_,

## Different Types of Shells

For us to be able to understand how shells are configured, we need to understand the different types of shells that can run. This does not mean different shell programs, such as `bash`, `zsh` or `dash`, but instead the differences between _interactive_ and _non-interactive_ shells, as well a _login_ shells.
For us to be able to understand how shells are configured, we need to understand the different types of shells that can run. This does not mean different shell programs, such as `bash`, `zsh` or `dash`, but instead the differences between _interactive_ and _non-interactive_ shells, as well as _login_ shells.

A lot of people get confused by how the shell is configured because they don't fully understand what these different types of shells are. So let's introduce each one, what it is and how it is used.

Expand Down Expand Up @@ -372,7 +372,7 @@ The shell will then attempt to read each of the following files. If the shell fi
- _~/.bash_login_<!--index-->
- _~/.profile_<!--index-->

There are very few circumstances in which you should change any of theses files. It is based to think of the profile files as essential operating system specific configuration that is needed to have a functional login shell.
There are very few circumstances in which you should change any of these files. It is based to think of the profile files as essential operating system specific configuration that is needed to have a functional login shell.

When a login shell closes, it will run any commands in the _~/.bash_logout_ file. However, users might terminate the shell process forcibly, which means that you cannot be sure this file will always be sourced as the shell exits.

Expand Down Expand Up @@ -470,7 +470,7 @@ exit
chsh -s "/bin/zsh" $USER
```

Be careful when changing your shell - if you get this wrong then you may inadvertently lock yourself out of your account, if logging in trys to start a shell that is not properly configured. Always test that the new shell works before you set it!
Be careful when changing your shell - if you get this wrong then you may inadvertently lock yourself out of your account, if logging in tries to start a shell that is not properly configured. Always test that the new shell works before you set it!

## Summary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The special characters that the shell uses are listed below:
| `\nnn` | The character corresponding to the octal number `nnn`, used to show special characters. |
| `\\` | A `\` backslash character. |
| `\[` | The 'start of non-printing characters' sequence. |
| `\[` | The 'end of non-printing characters' sequence. |
| `\]` | The 'end of non-printing characters' sequence. |

Some of these sequences are reasonably self-explanatory, some are a little more complex. Let's use some of them now to see how we can customise the prompt.

Expand Down Expand Up @@ -213,7 +213,7 @@ BLACK ON GREEN

However, the colour of the foreground and background should change on each line. The exact formatting will change depending on the terminal emulator you use. Some terminal emulators use bold text for the 'bright' colours.

With our new knowledge of how to use ANSI Escape Sequences to set the format of text, we can update our `PS1` variable to show a prompt in colour. As an example, the code below sets the prompt to show the username in blue and the name of the current working directory in green, followed by a white `$` prompt symbol, followed by the 'reset' sequence so that the text we type afterwords does not have its colour changed:
With our new knowledge of how to use ANSI Escape Sequences to set the format of text, we can update our `PS1` variable to show a prompt in colour. As an example, the code below sets the prompt to show the username in blue and the name of the current working directory in green, followed by a white `$` prompt symbol, followed by the 'reset' sequence so that the text we type afterwards does not have its colour changed:

```
dwmkerr@effective-shell-ubuntu-20:~/effective-shell$ PS1='\033[34m\u \033[32m\W \033[37m\$ '
Expand Down Expand Up @@ -241,7 +241,7 @@ dwmkerr@effective-shell-ubuntu-20:~$ PS1='-Ready?---> '
-Ready?--->
```

We don't need to limit ourselves to the special sequences we've seen so far in this chapter - we can run any commands we like to build a command prompt. For example, we could use the use the `ls` (_list directory contents_) and `wc` (_count lines and works_) commands to count the number of files and folders in the current directory and show that in the prompt:
We don't need to limit ourselves to the special sequences we've seen so far in this chapter - we can run any commands we like to build a command prompt. For example, we could use the use the `ls` (_list directory contents_) and `wc` (_count lines and words_) commands to count the number of files and folders in the current directory and show that in the prompt:

```bash
PS1="$(ls -al | wc -l | tr -d '[:space:]') \\$ "
Expand Down Expand Up @@ -569,7 +569,7 @@ For Z-Shell users, you might also consider the very popular "Oh-My-Zsh" project.
However, just like with most things in computing, I would strongly recommend that you learn how the fundamentals work as they are described in this chapter before using "Oh-My-Zsh" themes. This will help you understand how things like "Oh-My-Zsh" actually work under the hood.
You might also realise that you don't need to install an additional package to get the styling you want. For example, my own shell prompt includes information on Git, the working directory (trimmed to only show up to three entries), but only requires a few lines of of setup and works consistently in Bash-like shells _and_ Z-Shell.
You might also realise that you don't need to install an additional package to get the styling you want. For example, my own shell prompt includes information on Git, the working directory (trimmed to only show up to three entries), but only requires a few lines of setup and works consistently in Bash-like shells _and_ Z-Shell.
Enjoy playing around with the prompt customisation! It can be a lot of fun and the options are almost limitless!
Expand Down

0 comments on commit 674e408

Please sign in to comment.