How To Use GitHub Copilot On Your Mac for Faster Programming

GitHub Copilot mac

Software development can be an extremely long process. After you’ve worked out the algorithms for what you want your app to do, you have to write the code. Painstakingly, you’ll find yourself building function after function, perhaps wishing there was a faster way. Thanks to advances in artificial intelligence (AI), there now is. Let’s explore the power of GitHub Copilot on your Mac to speed up your app development.

What Is GitHub Copilot and What Can It Do?

GitHub Copilot is an artificial intelligence (AI) tool that can write code snippets for you as you work. The developers refer to it as an AI pair programmer. The tool uses OpenAI’s GPT-3 technology to analyze code and generate suggestions for completing it. This tool can save you countless hours of time and effort, allowing you to focus on other aspects of your work.

Using GitHub Copilot on your Mac, you can write code faster in two ways. First, as you are typing your code, the extension offers autocomplete suggestions to quickly and easily build the functions and other bits of code you need. That’s just the tip of the iceberg, though.

Going a step further, you can type natural language comments in your source code. GitHub Copilot will then suggest the entire functions to you, allowing you to rapidly develop your app without nearly as much time, effort, or typing.

Let’s start by learning how to install Github Copilot on macOS, step-by-step.

Getting the GitHub Copilot Extension Into Your Development Software On Your Mac

The AI extension is available for a number of different Integrated Development Environments (IDEs). While not currently available for Xcode, GitHub Copilot is available for a wide variety of other IDEs on macOS. These include JetBrains IDEs, Neovim and Visual Studio Code (VSC).

For the sake of this tutorial, I’ll explore using the plugin within VSC. Let’s look at how to install it.

Time needed: 2 minutes

Once you have Visual Studio Code installed, you can follow these steps to get the GitHub Copilot extension up and running.

  1. Within VSC, click the Extensions button in the left sidebar. Search for GitHub Copilot and click the blue Install button.

    Extensions Tab in VSC

  2. Quit VSC and relaunch it to completely reload the environment.

  3. Finally, you should sign into your GitHub account within VSC. To do so, click on the profile icon near the bottom left of the app window, then click Sign in with GitHub to use GitHub Copilot. Follow the instructions in your browser window to grant the plugin access.

    Sign Into GitHub in VSC

With that out of the way, you’re ready to get to work, allowing your new AI pair programmer help you write code more quickly and efficiently.

Seeing Your First Code Suggestions

In VSC, open a new source code file. The GitHub Copilot extension can help you write for a number of programming languages and frameworks, but it does have its preferences. As of this writing, the tool works especially well for Python, JavaScript, TypeScript, Ruby, Go, C# and C++.

Let’s look at a couple of ways GitHub Copilot can help us generate random numbers using JavaScript. First, let’s say you’re beginning to build a function and want the AI pair programmer to suggest ways to do it.

  1. In VSC, create a new JavaScript (*.js) file.
  2. Within your new file, type the following function header: function generateRandomNumberBetween1And10()
  3. GitHub Copilot will suggest the “meat” of your function, which you see in the dark gray text outlined above.
  4. Don’t like the suggested code? You can cycle through any other alternatives by pressing Option + ] or Option + [.
  5. Once you’ve found a code suggestion you like, press the Tab key to accept it.

There’s another way GitHub Copilot can help streamline your programming. You can also type a natural language comment in your source code file describing what you want the code to do. GitHub Copilot will offer suggestions to accomplish that.

In this case, I want to create a Python program that will generate a random number between 1 and 6, then display the number and a series of dots corresponding to that number.

Here’s how GitHub Copilot can help with that.

  1. To begin, I’ll type a comment describing what I want to do.
    # Generate a random number between 1 and 12, then print
    # the number using dots corresponding to the number.
  2. GitHub Copilot starts by suggesting the function needed. I press Tab to accept it, then continue to press Tab as the extension builds my code. You can see the results of one suggested option below.
    GitHub Copilot Code in VSC

Once you’re happy with what you’ve generated with the help of your AI pair programmer, it’s time to test.

Test and Debug Your Code

How you go about this, of course, will vary based on what type of code you’re writing. JavaScript, for example, you’ll usually upload to your web server and test through a web page. For a Python script, on the other hand, you can just run it from the Terminal.

For the Python example above, I launch the Terminal app from Applications > Utilities > Terminal. Then, I run my program in Python to see how it does.

  1. First, I change directories to where I saved my file.
  2. Next, type python [the file name of my source code].
    So, in my case, I type python github.py.
  3. And just like that, I see that my little program functions pretty much as I expected.
    Running Python Script

GitHub Copilot Can Streamline Your Work as a Coder

This is definitely an exciting tool for developers. It allows you to work faster and more efficiently, offering code suggestions as you develop your app. You can get it set up in just a few quick steps, and start using it on your Mac within minutes.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WIN an iPhone 16 Pro Max!