Configure Autocomplete Commands and Git SSH Key on Mac OS

JasonHsieh 謝帛軒
3 min readMar 28, 2023

--

It has been a while for me using Git to develop application or in some development teams. Sometime it is too old school or lazy for me to type some git commands in the terminal, (Well, I’m not a SourceTree lover lol), so having a Autocomplete commands library is pretty good for me when typing commands.

It is happened that I need to deliver some git documents for our development team (on MacOs), so the following are the steps to do those configurations.

Btw, I want to keep practicing english writing for my master in US…please feel free to give me some checks and advices about my poor grammar.

Autocomplete Git Commands:

Step 1

Open the terminal and paste the curl command to download the package

curl <https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash> > ~/git-auto-complete.bash

Step 2

Type the command to open the .bash_profile file for setting the environment variable:

vi ~/.bash_profile

Click “i” on the keyboard as an insert command, and paste the two commands into .bash_profile:

source ~/git-auto-complete.bash
autoload -Uz compinit && compinit

Click “esc” and type “:wq!” to save the configuration and quit vim

Step 3

Restart the terminal, and test the configuration with “$ git + click tab button”

Git Config SSH Keys:

In order to access GitHub more easily, an avoid keep typing the same username and password everyday, you can connect to GitHub Enterprise Server using the Secure Shell Protocol (SSH), which provides a secure channel over an unsecured network.

Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub Enterprise Server without supplying your username and personal access token at each visit.

You can access and write data in repositories on your GitHub Enterprise Server instance using SSH (Secure Shell Protocol). When you connect via SSH, you authenticate using a private key file on your local machine.

Step 1

Open the terminal and paste the command to generate SSH Key

$ ssh-keygen -t ed25519 -C "your_email@example.com"

If succeed, it would response:

Generating public/private ed25519 key pair.

Step 2

Type the path to save the SSH Key

Enter file in which to save the key (/Users/jasonhsieh/.ssh/id_ed25519):

Step 3

Input secure passphrase

About passphrases for SSH keys

With SSH keys, if someone gains access to your computer, the attacker can gain access to every system that uses that key. To add an extra layer of security, you can add a passphrase to your SSH key. To avoid entering the passphrase every time you connect, you can securely save your passphrase in the SSH agent.

> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]

Step 4

Access GitHub Enterprise -> Click Profile -> Settings → SSH and GPG Keys → New SSH Key

Step 5

Open the terminal, input the following command to acquire the content of SSH key

$ pbcopy < ~/.ssh/id_ed25519.pub
# Copies the contents of the id_ed25519.pub file to your clipboard

Step 6

Paste the key into the textbox, and click “Add SSH Key”

SSH key added

--

--

JasonHsieh 謝帛軒

LinkedIn: Jason Hsieh | Insta: jason__roy7dct | DCT on the journeys. UC Irvine right now outdooring