Skip to content

Commit 9bcea90

Browse files
Sukant Sondhi (HE HIM)cmendible
authored andcommitted
Added some resources and a cheatsheet for GitHub Copilot
1 parent 3167fe4 commit 9bcea90

File tree

4 files changed

+216
-0
lines changed

4 files changed

+216
-0
lines changed

Resources/GHCP Cheatsheet.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# GitHub Copilot Cheatsheet
2+
3+
Here are some useful shortcut commands for using GitHub Copilot:
4+
5+
- `Ctrl + Enter` (or `Cmd + Enter` on Mac): Open the suggestion panel to view alternative suggestions.
6+
7+
- `Tab`: Accept the current suggestion.
8+
9+
- `Shift + Tab`: Cycle through the available suggestions.
10+
11+
- `Ctrl + .` (or `Cmd + .` on Mac): Open the context menu to view more options.
12+
13+
- `Ctrl + Space` (or `Cmd + Space` on Mac): Trigger GitHub Copilot to generate code based on the context of your code.
14+
15+
- `Ctrl + Shift + Space` (or `Cmd + Shift + Space` on Mac): Trigger GitHub Copilot to generate code based on the context of your code, but with more context.
16+
17+
- `Ctrl + Shift + Enter` (or `Cmd + Shift + Enter` on Mac): Trigger GitHub Copilot to generate code based on the context of your code, but with even more context.
18+
19+
20+
### Things to try in the Copilot Chat Window
21+
22+
<img src="image.png" width="325" height="500">
23+
24+
- Select the code throwing error(s) and type `Handle error` in the chat.
25+
26+
### "/" Commands
27+
28+
- Type `/api` in the chat to get the API for the code.
29+
30+
- Type `/explain` in the chat to get an explanation of the code.
31+
32+
- Type `/fix` in the chat to get a fixed version of the code.
33+
34+
- Type `/new` in the chat to create a new project with some scaffold code.
35+
36+
- Type `/newNotebook` in the chat to create a new Jupyter notebook.
37+
38+
- Type `/test` in the chat to generate unit test.
39+
40+
- Type `/help` in the chat to get help with the commands.
41+
42+
- Type `/clear` in the chat to clear the chat window.
43+
44+
### "@" Commands
45+
46+
- Type `@terminal` in the chat to handle/run queries on/about terminal output(s)/error(s).
47+
48+
- Type `@vscode` in the chat to handle/run queries on/about VSCode output(s)/error(s).
49+
50+
- Type `@workspace` in the chat to run queries on/about workspace.
51+
52+
### "#" Commands
53+
54+
- Type `#editor` in the chat to handle/run queries on/about editor output(s)/error(s).
55+
56+
- Type `#file` in the chat to handle/run queries on/about file output(s)/error(s).
57+
58+
- Type `#selection` in the chat to handle/run queries on/about selected output(s)/error(s).
59+
60+
- Type `#TerminalLastCommand` in the chat to handle/run queries on/about the last command in the terminal.
61+
62+
- Type `#TerminlSelection` in the chat to handle/run queries on/about selected terminal output(s)/error(s).
63+
64+
## In-Line Chat Shortcuts
65+
66+
Press `Ctrl + I` to open inline GitHub Copilot Chat
67+
68+
![alt text](image-1.png)
69+
70+
- Type `/doc` in the chat to get the documentation for the code.
71+
72+
- Type `/explain` in the chat to get an explanation of the code.
73+
74+
- Type `/fix` in the chat to get a fixed version of the code.
75+
76+
- Type `/test` in the chat to generate unit test.
77+
78+
## Easter Eggs
79+
80+
GitHub Copilot has a few easter eggs too! For example, try typing `import antigravity` in a Python file and see what happens.
81+
82+
## Conclusion
83+
84+
GitHub Copilot is a powerful tool that can significantly speed up your coding process. With these tips and tricks, you'll be able to get the most out of it. Happy coding!
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Setting Up GitHub Copilot\n",
8+
"Instructions on how to install and set up GitHub Copilot in your IDE."
9+
]
10+
},
11+
{
12+
"cell_type": "code",
13+
"execution_count": null,
14+
"metadata": {},
15+
"outputs": [],
16+
"source": [
17+
"# Step 1: Open Visual Studio Code\n",
18+
"# Step 2: Click on the Extensions view icon on the Sidebar\n",
19+
"# Step 3: Search for 'GitHub Copilot'\n",
20+
"# Step 4: Click on the first result to open the extension's details\n",
21+
"# Step 5: Click on the install button\n",
22+
"# Step 6: Once installed, GitHub Copilot will automatically start providing suggestions when you write code"
23+
]
24+
},
25+
{
26+
"cell_type": "markdown",
27+
"metadata": {},
28+
"source": [
29+
"# Using Inline Ghost Prompts\n",
30+
"Exercises to practice using inline ghost prompts, which provide suggestions as you type."
31+
]
32+
},
33+
{
34+
"cell_type": "code",
35+
"execution_count": null,
36+
"metadata": {},
37+
"outputs": [],
38+
"source": [
39+
"# Step 7: Start a new Python file\n",
40+
"# Step 8: Begin typing a Python function or statement\n",
41+
"# For example, let's define a function to calculate factorial of a number\n",
42+
"\n",
43+
"def factorial(n):\n",
44+
" # As you type, GitHub Copilot will automatically suggest the rest of the code\n",
45+
" # Here, it might suggest the base case for the recursive function\n",
46+
" if n == 0:\n",
47+
" return 1\n",
48+
" # It might then suggest the recursive case\n",
49+
" else:\n",
50+
" return n * factorial(n-1)\n",
51+
"\n",
52+
"# Step 9: Accept the suggestion by pressing the Tab key on your keyboard\n",
53+
"# Step 10: Test the function with some inputs\n",
54+
"\n",
55+
"print(factorial(5)) # Expected output: 120\n",
56+
"print(factorial(3)) # Expected output: 6\n",
57+
"\n",
58+
"# Step 11: Continue practicing with other functions and observe the suggestions provided by GitHub Copilot\n",
59+
"# Remember, the suggestions are based on patterns and code snippets from public code repositories, so they might not always be perfect or optimal. Always review and test the code before using it."
60+
]
61+
},
62+
{
63+
"cell_type": "markdown",
64+
"metadata": {},
65+
"source": [
66+
"# Interacting with GitHub Copilot Chat\n",
67+
"Guidelines on how to use the GitHub Copilot chat for interactive programming help."
68+
]
69+
},
70+
{
71+
"cell_type": "code",
72+
"execution_count": null,
73+
"metadata": {},
74+
"outputs": [],
75+
"source": [
76+
"# Step 12: Interacting with GitHub Copilot Chat\n",
77+
"# GitHub Copilot also provides a chat interface for interactive programming help\n",
78+
"# To use this feature, follow these steps:\n",
79+
"\n",
80+
"# Step 12.1: Open the command palette with `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)\n",
81+
"# Step 12.2: Type `GitHub Copilot: Open Chat` and select the command\n",
82+
"# Step 12.3: In the chat interface, you can ask programming questions or request code snippets\n",
83+
"# For example, you can ask \"How to write a function to calculate Fibonacci series in Python?\"\n",
84+
"\n",
85+
"# Note: The chat interface is a new feature and might not be available in all regions or for all users. If you don't see the `GitHub Copilot: Open Chat` command, make sure you have the latest version of the GitHub Copilot extension and Visual Studio Code.\n",
86+
"\n",
87+
"# Step 13: Practice with GitHub Copilot Chat\n",
88+
"# Try asking some programming questions or requesting code snippets in the chat\n",
89+
"# Remember, just like with the inline suggestions, always review and test the code before using it."
90+
]
91+
},
92+
{
93+
"cell_type": "markdown",
94+
"metadata": {},
95+
"source": [
96+
"# Working with Inline Chat\n",
97+
"Exercises to practice using the inline chat feature for collaborative coding."
98+
]
99+
},
100+
{
101+
"cell_type": "code",
102+
"execution_count": null,
103+
"metadata": {},
104+
"outputs": [],
105+
"source": [
106+
"# Step 14: Working with Inline Chat\n",
107+
"# GitHub Copilot also provides an inline chat feature for collaborative coding\n",
108+
"# To use this feature, follow these steps:\n",
109+
"\n",
110+
"# Step 14.1: Open the command palette with `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)\n",
111+
"# Step 14.2: Type `GitHub Copilot: Start Inline Chat` and select the command\n",
112+
"# Step 14.3: OYou cn also use 'Ctrl+I' (Windows/Linux) or `Cmd+I` (Mac) to start the inline chat\n",
113+
"# Step 14.4: In the inline chat interface, you can ask programming questions or request code snippets\n",
114+
"# For example, you can ask \"How to write a function to calculate the nth prime number in Python?\"\n",
115+
"\n",
116+
"# Note: The inline chat feature is a new feature and might not be available in all regions or for all users. If you don't see the `GitHub Copilot: Start Inline Chat` command, make sure you have the latest version of the GitHub Copilot extension and Visual Studio Code.\n",
117+
"\n",
118+
"# Step 15: Practice with GitHub Copilot Inline Chat\n",
119+
"# Try asking some programming questions or requesting code snippets in the inline chat\n",
120+
"# Remember, just like with the inline suggestions and the chat interface, always review and test the code before using it."
121+
]
122+
}
123+
],
124+
"metadata": {
125+
"language_info": {
126+
"name": "python"
127+
},
128+
"orig_nbformat": 4
129+
},
130+
"nbformat": 4,
131+
"nbformat_minor": 2
132+
}

Resources/image-1.png

45.4 KB
Loading

Resources/image.png

127 KB
Loading

0 commit comments

Comments
 (0)