Code-to-Gist 🤖
The code-to-gist extension allows you to conveniently create and share GitHub Gists from your code files directly within the editor. Gists are a way to share snippets or larger portions of code with others, either as a public or secret gist, making it easy to collaborate or showcase your work.
Table of Contents
Features 📙
- Create GitHub Gists: Create Gists by posting code files from your local VS Code environment to GitHub's Gist service.
- Update GitHub Gists: Automatically update Gists when changes are made to the associated files in the editor.
- View All Gists: View all your Gists and open them directly in the editor.
- View Gist in Editor: Open a specific Gist in the editor by providing the Gist URL.
- Edit GitHub Gists in Editor: One of the standout features of this extension is the ability to edit your Gists directly within the VS Code editor, and the changes will be automatically reflected in the live URL of the Gist. This seamless integration allows for real-time collaboration and sharing, as any modifications made to the Gist in the editor are instantly updated on the GitHub Gist platform. Whether you're making a quick fix or adding substantial content, your Gists are always up to date.
- File Selection: Choose specific code files to include in the Gist by selecting them through the file picker within the VS Code interface.
- Public or Private Gists: You can decide whether your Gist should be public or private, allowing you to control who can access and view your code snippets for safer collaboration.
- Language Detection: Automatically detects the language of the file based on the file extension.
- Extension Update Notification: Notifies you if there's a new version of the extension available in the marketplace.
- Status Bar Integration: Quickly create a Gist from the status bar below the file explorer.
Installation 📝
- Launch Visual Studio Code.
- Go to the Extensions view by clicking on the square icon on the left sidebar or by using the shortcut
Ctrl+Shift+X .
- Search for "Code-to-Gist" in the Extensions marketplace.
- Click the "Install" button next to the "Code-to-Gist" extension.
- Once installed, you can find the extension using
Cmd+Shift+P or at the bottom left of your VSCode as Create Gist
Usage 🛠️
Creating a Public/Secret Gist
Open Visual Studio Code and open a workspace/project folder.
Choose a method to create a Gist: There are multiple ways to create a Gist using the code-to-gist extension:
Create Gist from Active Editor: This method allows you to create a Gist from the currently active file in your editor. To use this method, ensure the file you want to share is open and active. Then, use the Cmd+Shift+P shortcut, search for "Code-To-Gist: Create GitHub Gist from Active Editor" , and select it.
Create Gist from Explorer: This method allows you to create a Gist from a file selected in the Explorer view. To use this method, navigate to the file you want to share in the Explorer view, right-click on it, and select "Code-To-Gist: Create GitHub Gist from Explorer" .
Create Gist using File Picker: This method allows you to create a Gist using a file picker dialog. To use this method, use the Cmd+Shift+P shortcut, search for "Code-To-Gist: Create GitHub Gist using File Picker" , and select it. A file picker popup will appear, allowing you to navigate to and select the file or files you want to share as a Gist.
Create Gist from Selection: This method allows you to create a Gist from a selected portion of code in your editor. To use this method, highlight the portion of code you want to share in your editor, then use the Cmd+Shift+P shortcut, search for "Code-To-Gist: Create GitHub Gist from Selection" , and select it.
Follow the on-screen prompts to authenticate, select files, and set the visibility of your Gist.
The extension will handle the creation of the Gist and display a success message with the URL of the created Gist at the bottom right corner of your code editor.
If you choose to go to the Gist, it will open up in your default browser.
In case of any errors or issues, appropriate error messages will be displayed, indicating the problem encountered. Refer to the #Troubleshooting section of this docs and try to fix the issue based on the error message. If the error persists, please reach out to me via Twitter DM (@developerayo).
Viewing and Editing Gists
- Show All Gists: Use the
Cmd+Shift+P shortcut, search for "Code-To-Gist: Show All Gists" , and select a Gist to open in the editor.
- View Gist in Editor: Use the
Cmd+Shift+P shortcut, search for "Code-To-Gist: View Gist in Editor" , and provide the Gist URL, either gists owned by you or others.
- Edit Gist in Editor: Open a Gist in the editor using the
"Code-To-Gist: Show All Gists" commands, clicking on it displays a quick pick menu, you can then select any Gist to open its content in a new editor tab. Once opened you can make edits, and all changes made are updated automatically to the live Gist on GitHub via our automatic Gist update feature.
Extension Deactivation 😔
The extension is deactivated automatically when you close Visual Studio Code or manually disable the extension in the Extensions view.
Troubleshooting 🐛
- Error: "GitHub authentication failed": Ensure that you are successfully authenticated with your GitHub account in your VSCode session. If not, the Code-To-Gist extension cannot authenticate and create Gists.
- Error: "Please select a file": Make sure you select at least one code file to include in the Gist when the file picker opens. You can select multiple files by using
Cmd + Click .
- Error: "Rate limit exceeded. Please try again later.": GitHub imposes rate limits on API requests. If you encounter this error, you'll have to wait for some time before trying to create a new Gist again.
- Error: "Invalid GitHub PAT. Please check your token.": This error should not appear unless there is a change in the GitHub authentication method provided by VSCode. If you do encounter it, verify that you're properly authenticated on your VSCode session.
- Error: "Please select a gist visibility": Make sure to select either 'public' or 'secret' when asked for the visibility of the Gist.
- Error: "Failed to create a gist: [Error Message]" or "An unexpected error occurred while creating a gist": These are general error messages. Look at the provided error details for hints on what went wrong. If the error persists, reach out for help via Twitter DM (@developerayo).
Feedback and Contributions 👂
If you have any feedback, suggestions, or bug reports, please reach out to me on Twitter (@developerayo)
Enjoy! 🧡
| |