Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this movie we're going to learn to take screen captures from the command line. Do you already know how to do screen captures in the Mac? It's simple. You just hold down the Command key, the Shift key and hit the number 3 key and it will take a screenshot of your screen and put it on your Desktop. There is another version of that. If you hold down Command+Shift+4 you'll get an interactive screen capture which means that you get crosshairs. You select exactly the portion of the screen that you wanted to capture and when you let go just that portion of the screen gets turned into a capture as a file on your Desktop. We can do the exact same thing from the command line plus there are a few extra options that we don't normally have available to us.
Let's see at its most basic first. From the command line you just simply type screencapture. It's that easy. Followed by the name of the file where you want it to go. So screencapture and let's put it on our Desktop and then I'm going to call it screen_capture.png. By default the screen captures are going to be PNG files. Now already this is a slight improvement over the regular Mac version, because we get to specify our own location and our own filename. Whereas we can do the other way the Mac gives it a filename based on the time that the picture was taken and puts it on your desktop.
So let's hit Return and it takes the screenshot and puts it on the Desktop. Now in addition we have a number of options that we can specify. There is the lowercase -i option and that's put us in that interactive capture mode exactly, the same as if we done Command+Shift+4. Once you have those crosshairs and you decide you don't want to take the screen picture you can just hit Escape key to cancel out of it. There is a lowercase -m option if you wanted to capture your main monitor only. That's of course only if you have multiple monitors. By default the Mac will capture all monitors. Then there is a capital -C for showing the cursor.
By default the cursor is not shown in the screen capture. If you did want the cursor for some reason, you couldn't do that from the Mac, but you can do it from the command line. You can use the -t option followed by a Format if you wanted it in a different format than png. You can use pdf, jpg, tiff. There are number of others as well, but these are the main ones. The capital -T allows you to specify a Delay. So you put the -T option followed by a number of seconds that you wanted it to wait before snapping the picture. Once it finishes snapping the picture you can use the -P Option to open that file with Preview or the -M option to send it directly to Mac Mail and put it in a mail message. Or if you don't want to even have a file you can use the lowercase -c option and capture it directly to the clipboard.
Let's try a few to these out. So this time instead of the simple version I'll do screencapture, but I'll specify some options. Let's say I'm going to use lowercase -m to get my main monitor, capital C to include the cursor. We're going to open in preview when we're done with the capital P, and then let's put a delay on it capital -T 3 and wait 3 seconds. Then let's also change the format using lowercase -t, make it a jpg file, and this time I'm going to save it in my current directory which is the Unix files directory inside my user directory.
So I'll just save it there and I'll call it screen_capture.jpg since the JPEG file this time. So there we go. I hit Return. It waits 3 seconds and then it snaps the picture and it opens it up in Preview for us. So here is the actual screen capture. So again all of the special configuration options are available in the man pages if you need to look them up. Now if is the kind of thing you find yourself doing often, then create an alias for it. That has all the configurations that you want. Put that in your bashrc file and then you can just type something simple like screencap and voila! You'll get your screen capture configured exactly the way you wanted.
So again this is the exact same screen capture you can normally do on the Mac, but we just have these extra enhancements available to us through the power of Unix.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.