Skip to content

Commit

Permalink
Update 02-unix-shell.md
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyDShaw authored Oct 6, 2024
1 parent 8528b22 commit 796d317
Showing 1 changed file with 58 additions and 58 deletions.
116 changes: 58 additions & 58 deletions _episodes/02-unix-shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,62 +187,6 @@ We can check we are in the right place by running `pwd`.

{: .output}

> ## Tab completion
>
> Sometimes file paths and file names can be very long, making typing out the path tedious.
> One trick you can use to save yourself time is to use something called **tab completion**.
> If you start typing the path in a command and their is only one possible match,
> if you hit tab the path will autocomplete (until there are more than one possible matches).
>
> > ## Solution
> >
> >For example, if you type:
> >
> > ```
> > {{ site.remote.prompt }} cd {{ site.working_dir | last | slice: 0,3 }}
> > ```
> >
> > {: .language-bash}
> >
> > and then press <kbd>Tab</kbd> (the tab key on your keyboard),
> > the shell automatically completes the directory name for you (since there is only one possible match):
> >
> > ```
> > {{ site.remote.prompt }} cd {{ site.working_dir | last }}/
> > ```
> >
> > {: .language-bash}
> >
> > However, you want to move to your personal working directory. If you hit <kbd>Tab</kbd> once you will
> > likely see nothing change, as there are more than one possible options. Hitting <kbd>Tab</kbd>
> > a second time will print all possible autocomplete options.
> >
> > ```
> > cwal219/ riom/ harrellw/
> > ```
> >
> > {: .output}
> >
> >Now entering in the first few characters of the path (just enough that the possible options are no longer ambiguous) and pressing <kbd>Tab</kbd> again, should complete the path.
> >
> > Now press <kbd>Enter</kbd> to execute the command.
> >
> > ```
> > {{ site.remote.prompt }} cd {{ site.working_dir | last }}/<username>
> > ```
> >
> > {: .language-bash}
> >
> > Check that we've moved to the right place by running `pwd`.
> >
> > ```
> > {{ site.working_dir | join: '/' }}/<username>
> > ```
> >
> > {: .output}
> {: .solution}
{: .challenge}

## Creating directories

<!-- NOTE: This bit uses relative paths even though the convept hasn't been introduced yet. -->
Expand Down Expand Up @@ -339,7 +283,7 @@ These two specific hidden directories are special as they will exist hidden insi

You may have noticed in the last command we did not specify an argument for the directory path.
Until now, when specifying directory names, or even a directory path (as above),
we have been using what are know **absolute paths**, which work no matter where you are currently located on the machine
we have been using what are known as **absolute paths**, which work no matter where you are currently located on the machine
since it specifies the full path from the top level root directory.

An **absolute path** always starts at the root directory, which is indicated by a
Expand All @@ -356,7 +300,7 @@ rather than from the root of the file system.
In the previous command, since we did not specify an **absolute path** it ran the command on the relative path from our current directory
(implicitly using the `.` hidden directory), and so listed the contents of our current directory.

We will now navigate to the parent directory, the simplest way do do this is to use the relative path `..`.
We will now navigate to the parent directory, the simplest way do this is to use the relative path `..`.

```
{{ site.remote.prompt }} cd ..
Expand All @@ -378,6 +322,62 @@ We should now be back in `{{ site.working_dir[0] }}`.

{: .output}

> ## Tab completion
>
> Sometimes file paths and file names can be very long, making typing out the path tedious.
> One trick you can use to save yourself time is to use something called **tab completion**.
> If you start typing the path in a command and there is only one possible match,
> if you hit tab the path will autocomplete (until there are more than one possible matches).
>
> > ## Solution
> >
> >For example, if you type:
> >
> > ```
> > {{ site.remote.prompt }} cd {{ site.working_dir | last | slice: 0,3 }}
> > ```
> >
> > {: .language-bash}
> >
> > and then press <kbd>Tab</kbd> (the tab key on your keyboard),
> > the shell automatically completes the directory name for you (since there is only one possible match):
> >
> > ```
> > {{ site.remote.prompt }} cd {{ site.working_dir | last }}/
> > ```
> >
> > {: .language-bash}
> >
> > However, you want to move to your personal working directory. If you hit <kbd>Tab</kbd> once you will
> > likely see nothing change, as there are more than one possible options. Hitting <kbd>Tab</kbd>
> > a second time will print all possible autocomplete options.
> >
> > ```
> > cwal219/ riom/ harrellw/
> > ```
> >
> > {: .output}
> >
> >Now entering in the first few characters of the path (just enough that the possible options are no longer ambiguous) and pressing <kbd>Tab</kbd> again, should complete the path.
> >
> > Now press <kbd>Enter</kbd> to execute the command.
> >
> > ```
> > {{ site.remote.prompt }} cd {{ site.working_dir | last }}/<username>
> > ```
> >
> > {: .language-bash}
> >
> > Check that we've moved to the right place by running `pwd`.
> >
> > ```
> > {{ site.working_dir | join: '/' }}/<username>
> > ```
> >
> > {: .output}
> {: .solution}
{: .challenge}

> ## Two More Shortcuts
>
> The shell interprets a tilde (`~`) character at the start of a path to
Expand Down

0 comments on commit 796d317

Please sign in to comment.