This Zsh/Oh My Zsh plugin enhances the git clone
command by autocompleting GitHub repository URLs using SSH. It supports public repositories and can be configured with a GitHub token to avoid API rate limits.
-
Clone the Plugin: Clone this repository into your Oh My Zsh custom plugins directory:
git clone https://github.com/dcorral/gitclone-autocomplete-omzsh-plugin ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/gitclone-autocomplete
-
Update
.zshrc
: Addgitclone-autocomplete
to the plugins list in your.zshrc
:plugins=(... gitclone-autocomplete)
-
Reload Zsh: Apply the changes by either restarting your terminal or sourcing your
.zshrc
:source ~/.zshrc
To prevent hitting GitHub API rate limits, configure a personal access token:
-
Generate Token: Visit GitHub's Tokens page and generate a new token with minimal scopes.
-
Setup Environment Variables:
- Copy the
.zshprivate.template
from this repository to your home directory and rename it to.zshprivate
. - Replace placeholder values in
.zshprivate
with your GitHub token and username.
cp path_to_cloned_repository/.zshprivate.template ~/.zshprivate nano ~/.zshprivate # Edit and save your changes
- Copy the
-
Source
.zshprivate
: Ensure.zshprivate
is sourced in your.zshrc
. Add the following line if it's not already there:[[ -f ~/.zshprivate ]] && source ~/.zshprivate
# GitHub Personal Access Token
export GITHUB_TOKEN="your_github_personal_access_token_here"
# Default GitHub username
export GITCLONE_AUTOCOMPLETE_USER="your_github_username_here"
With the plugin and configuration in place, begin typing git clone
followed by the start of a GitHub username. Autocompletion suggestions for repository URLs will appear as you type. Press Tab
to cycle through the suggestions.