These are some tips to make using your relationship with your terminal more beautiful. I advise you to try each step of the way the new tips and tricks that you can become more comfortable with it!
Use the computer in your friend as much as you can! Autocomplete will save you time and also avoid typos. One easy tip that we have already mentioned is using the <TAB>
key in your keyboard.
The <TAB>
key, usually in the left side of your keyboard can be used to auto-complete the name of a directory, file or tool in your terminal. It works if you give enough characters so the name can be uniquely identified.
For example, to complete the path to go from “Documents” to “Recipies”, in the below directory schema, what you can do is:
cd R
+ tab
= cd Recipies/
But if you want to go from “Recipies” to “Soups” you need more than just one letter.
cd S
will not complete because it is not a unique prefix, instead should print in your terminal all the possible options. For this case you need to give some more information that makes it unique.
cd So
+ tab
= cd Soups/
while
cd Sa
+ tab
= cd Salads/
Suggested activity: Open replit and, starting inside theDocuments
folder, use tab autocomplete to list the path to the Aus(tralia) trip photo.
Another interesting and very useful resource is that your terminal has a “memory“, it keeps a history of the commands that you have used in the past. If it is the 1st time you are using this, you can access the commands you’ve used up until now. You should not rely on this behaviour.
So you are probably asking yourself how can I access this history of commands?
You can easily access the most recent commands you have used without typing them all over and over and over again with the UP and DOWN arrows on your keyboard. In fact you can go quiet far into the past using the UP arrow, and go back to last used line with the DOWN arrow.
So imagine you have used the following commands lately:
PC $ cd Documents/Recipies/Desserts
PC $ ls -la
PC $ cd Chocolate_Desserts/Chocolate_mousse
PC $ ls -la
PC $ mv strawberry_mousse ../
PC $ mv vanilla_cream ../
If you press 3x the UP arrow you get ls -la
, and if you press DOWN arrow 1x immediately after you get mv strawberry_mousse ../
It might be a good moment to test this! Just use the UP and Down arrows in replit and check if you can see the commands you’ve used before showing in your prompt. If you desire to run a command that you find again you just need to press <ENTER>
once you choose one of them.
The previous example is very simple, and might not showcase well how useful this is. But imagine you are running a program and you have the following line:
PC $ blastp -query mm-first.faa -db zebrafish.1.protein.faa -out mm-first.x.zebrafish.txt
In this case instead of typing it all again, if you want to repeat the analysis you just the UP arrow, or if it is a command you might use many times, you might want to use this shortcut in your keyboard.
What if instead of looking one by one you want to get a list of commands you have used?
An alternative way to check your commands history in list format is directly asking for the history
into your terminal.
PC $ history
cd Doc/
ls Fotos/
ls Recipies/
rm copy_to_delete
cd ..
mv note.txt copy_of_note.txt
history
if you just type history
you should get a list similar to the one you see above. Showing from the bottom to top the most recent to the oldest respectively. There are ways to filter this list that eventually will get much longer than a feel lines. But this I’ll teach you later!
Just try now, go to your replit terminal and ask for history
and see the list of commands you have learned and practiced so far! With time the list might get very big and you have to scroll down to see it all. There some tricks to filter this list but we are not talking about it just yet!