diff --git a/_episodes/02-unix-shell.md b/_episodes/02-unix-shell.md index 8aa3becf..00194109 100644 --- a/_episodes/02-unix-shell.md +++ b/_episodes/02-unix-shell.md @@ -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 Tab (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 Tab once you will -> > likely see nothing change, as there are more than one possible options. Hitting Tab -> > 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 Tab again, should complete the path. -> > -> > Now press Enter to execute the command. -> > -> > ``` -> > {{ site.remote.prompt }} cd {{ site.working_dir | last }}/ -> > ``` -> > -> > {: .language-bash} -> > -> > Check that we've moved to the right place by running `pwd`. -> > -> > ``` -> > {{ site.working_dir | join: '/' }}/ -> > ``` -> > -> > {: .output} -> {: .solution} -{: .challenge} - ## Creating directories @@ -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 @@ -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 .. @@ -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 Tab (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 Tab once you will +> > likely see nothing change, as there are more than one possible options. Hitting Tab +> > 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 Tab again, should complete the path. +> > +> > Now press Enter to execute the command. +> > +> > ``` +> > {{ site.remote.prompt }} cd {{ site.working_dir | last }}/ +> > ``` +> > +> > {: .language-bash} +> > +> > Check that we've moved to the right place by running `pwd`. +> > +> > ``` +> > {{ site.working_dir | join: '/' }}/ +> > ``` +> > +> > {: .output} +> {: .solution} +{: .challenge} + > ## Two More Shortcuts > > The shell interprets a tilde (`~`) character at the start of a path to