I'm not here to teach you how to use copy and paste, however what I'm here for is to show you
how to use Terminal the right way. I'm here to show you how to do this and show you how you
can become a Terminal Pro, so that you can boast to your friends that you can navigate the matrix.
SUBSCRIBE and let's dive in. Today you will master Terminal. Before we do that let me remind you about
DEV_FACTORY. It is at rebeloper.com/mentoring if you want to meet me on a one-on-one Zoom call,
you have a SwiftUI question or you want to learn how to build out iOS apps, go ahead and check out
it's at rebeloper.com/mentoring, a one-on-one Zoom call with me. Now where is Terminal? Well you
can just hit Command + Space and just go and search for Terminal, there we go. You've just searched for
Terminal right over there. You will see it's kind of this icon right over here. I have already
opened it up and it's right over here. Really, really big and the first tip that
I would like to give you is to know where you are at currently in Terminal. So that is our PWD.
So we are on the users slash rebeloper. That is tip number one. PWD. Now next up we want to know
what other files or folders are in that folder, file or folder basically, where we are at. And that
is LS. So we want to list that out. As you can see we are in application, documents, library
music and so forth. I also open up finder right over here so as you can see, yes that is
my root folder right over here. So let's just go into the documents folder because now you see
that we have our document and that is CD so change directory, CD and doc and I just start typing
doc and hit TAB you will see that it's auto completing. Now as you can see we also have
documents and downloads. So if I hit the TAB with the "DO" it will not auto complete. It will
give us the two options that we have for the autocomplete. So I would just go with C
and another TAB and then hit RETURN and now as you can see we are inside our documents folder.
Let's call LS here so we can see that we are actually right inside our documents folder. As you can
see in the finder in the GUI we also see the same structure. Really nice. Now how can we go back from
a folder? Well it couldn't be easier. We just go CD .. and let's just list out again we are
out of there. But what if I want to switch between those two previous movements. I just go with the CD -.
There we go now we are inside the documents and it's already printing this out that
we are going into the documents. Let's just do the CD - again and here's another cool trick.
If you just hit the arrow keys in our case up and we just go through all of the previous history
of our commands. If you just go one up you will select CD - and then you are going to go
back to the root. I'm just going to go CD - again because I want to now create
a new file and that is with the help of TOUCH. We just go TOUCH and add the file name and extension.
I'm going to go with test underscore file dot txt and there we go we have created it, but how do we
know we actually created it? Well let's just go back into Finder and as you can see here is our
text file. And it's empty currently. So let's just open it. So what we would just do is just go test
and TAB. There are many, so let's just go TEST_FILE and then TAB file dot
txt and then open.
Oh, we're just going to go open and yeah there we go. We have our open, so I have done a little bit
of experiments right over here and there's quite a lot going on. So how do we clear this? Well we just
use clear and there we go. Everything has been cleared. Now what it actually happened is just
going to move everything down, well actually up till this point. Now if you want to remove
everything you just go with Command + K and this time around we cannot scroll to the top. Now next
up is the open. So let's CD into our documents, maybe. So documents and then open old because
I do know that there is actually a folder called old. And there we go we have that, okay. Now it's time to
open up a file. The test file that we have just created and that is nano and let's just go test
underscore hit TAB for auto completion and this will open up nano. Now we can just add in here some
hello there and also we can read the file, go to the previous, page all of these
and this upward carrot is actually the control on your keyboard. Now what I want to do is save
and that is right out. So just go CTRL + O, okay hit RETURN right over there. As you can see wrote one
line and then I want to exit and that is CTRL + X. Now if we take a look at that file under the
finder you will see now that it has hello, how awesome is that. You can edit your text files
inside terminal. Now the next one is removing files and that is RM and again I'm going to
use test underscore TAB for auto completion hit RETURN there and the file has been removed.
Now pay attention here because it's not going to move it into trash it will permanently delete it.
So make sure that you are removing only those files that you no longer will miss, okay.
Next up on the list is making a new directory. So that is MKDIR and let's just call this test
underscore dir. Hit RETURN, let's just take a look at that, here we have our new directory created.
Now what if we want to create a file inside a directory but we could just go CD into our
test underscore directory and then create our file with touch but I'm going to do this,
I'm going to go back and I'm going to do this from the documents folder actually and
there are two ways of, actually let's just do this with only terminal. So I will just go
TOUCH and then test underscore hit TAB so you know that's our directory and then just type out test
file dot txt and there we go, we should see this so let's CD into our test underscore directory
and then list out all of our files. As you can see it's the test file right over there and we
can also double check right over here in Finder to make sure that everything works as expected.
So that is how you can touch a new file inside a nested directory, okay. Also we can just list out
the whole directory. So let's just go back, so CD .., we are in the document so we just
go LS and then test underscore directory and it will give us a list of all the components of that
directory, okay. Finally let's get rid of that directory and we want to actually get rid of
all the files inside the directory so that would be recursive. We are going to use RM - R.
That is for recursive and then test underscore and directory and that will remove that. As you can
see no traces left of our test directory, okay. So that is all about navigation, creation, deletion
inside Terminal. Now here come the last three code snippets, like a command snippets that
I highly recommend. The first one is creating a Zip file. So let's create a new file again.
So TOUCH test underscore file dot txt, okay. And let's list out our files, okay, there we go.
We have our test file right over here. Now we want to zip this. So what we need to do is a ZIP - E
and then the new file name so that would be maybe the same like test underscore file dot
zip and then the file path. So the file path the easiest way of doing this and this is again a new
trick that you can learn right over here is just drag and drop it into your Terminal. So that
is actually our file path and then what we want to do is, oh I just gone forward, okay. So what we want
to do is hit RETURN again enter a password because we entered encrypted. So - E e is encrypted,
now you know and now we just add in here 1,2,3 and hit RETURN, verify password 1,2,3 hit
RETURN, okay. So now let's just go ahead and open up that Zip file. Here is our Zip file, open it up
Oh, let's see users rebeloper documents and there we go. We want to see that and there we go.
So what if I want to capture this window? So screen capturing in macOS is with SHIFT + CMD + 4,
then you have this nice cursor right over here but you also if you hit SPACE, it will
turn into this camera. So you can select the window that you want to screen capture of. So if we hit
there you will see that I will just open this up, we see this screen capture. Let me just resize this
really nice, but it has this shadow like before, well actually after our
window that we have captured. We have this really nice shadow which we actually don't want. So that
is our next trick right over here. Let's just remove this and I will copy this out, it's actually
going to override defaults. So there we go, now if you do want to have a list of these commands go
ahead and check out the link in the description where you can find the resources for all my
tutorials and just search for this video and you will be able to download all of these commands.
So it's this one. So now that we have added that, of course we can also revert that. Go ahead
and check out the list of the commands. Now let's take a look at SHIFT + CMD + 4 and then hit space
and take a new screenshot. So let me just move that right in. Now as you can see we don't have
that actual shadow and in many, many cases this is much more and nicer and yeah of course you can
revert it back if you want to. Now the final trick that I want to show you is actually two commands.
So let's take a look at our dock and I have moved my dock to my trailing part right over here, to the
right and you can see if I just hover right over there with my mouse it's taking a lot of time
to activate and it's animating it. Now if you are familiar with my setup then you will know that
this if I just hover right over here it just pops instantly. So let's do that. First of all I want to
set the delay to be a zero. So it's this line of code and then I want to remove the animation
all together. So next up is this line of code and now there we go. It's just snaps and I prefer this
very, very much. Now if you do like these lists of Terminal commands you will definitely want to know
why you should avoid nesting if else statements. Go ahead and check out the video right over here.