لو شغلك كله عايش جوه GitHub — repos وissues وPRs وactions — فده الـ agent اللي بيلعب في ملعبه الأصلي. Copilot CLI مش standalone package، ده extension للـ GitHub CLI (gh) بياخد قوة Copilot ويحطها في الـ terminal.
⚠️ مهم: ده مش IDE extension!
|
IDE Extension |
CLI Extension |
| الاسم |
GitHub Copilot |
gh-copilot |
| التثبيت |
VS Code / JetBrains plugin |
gh extension install github/gh-copilot |
| الاستخدام |
جوه الـ editor |
جوه الـ terminal |
| الـ API |
نفس الـ API |
نفس الـ API |
التثبيت والدخول
| الأمر |
بيعمل إيه |
brew install gh |
تثبيت GitHub CLI (macOS/Linux) |
gh auth login |
تسجيل دخول بحساب GitHub |
gh extension install github/gh-copilot |
تثبيت Copilot extension |
gh extension upgrade github/gh-copilot |
تحديث الـ extension |
gh copilot --version |
التأكد من التثبيت |
كل الأوامر
| الأمر |
بيعمل إيه |
السيناريو |
gh copilot suggest "<query>" |
يولّد command من natural language |
"الحاجة الأساسية" — تحويل وصف لـ shell command |
gh copilot suggest |
يفتح interactive mode |
لو عايز conversation متعددة الخطوات |
gh copilot explain "<command>" |
يشرح command بالإنجليزي |
فهم command معقد من StackOverflow |
gh copilot explain |
interactive explain mode |
شرح متعدد أوامر |
gh copilot --help |
كل الأوامر والـ flags |
|
gh copilot --version |
النسخة المثبتة |
|
كل الـ Flags
suggest flags
| Flag |
Alias |
بيعمل إيه |
مثال |
--target <shell> |
-t |
تحديد الـ shell المستهدف |
-t bash, -t zsh, -t powershell, -t fish, -t git, -t gh |
--no-confirm |
— |
يشيل الـ y/n prompt (للـ scripting) |
gh copilot suggest --no-confirm "commit all" | bash |
--debug |
— |
يظهر الـ API calls والـ context |
لفهم ليه جاب suggestion غريب |
--help |
-h |
help للـ suggest |
|
explain flags
| Flag |
Alias |
بيعمل إيه |
مثال |
--target <shell> |
-t |
شرح مخصوص لـ shell معين |
gh copilot explain -t powershell "Get-Process" |
--debug |
— |
debug mode |
|
--help |
-h |
help للـ explain |
|
Keyboard Shortcuts (في interactive mode)
| الزرار |
السياق |
بيعمل إيه |
y أو Enter |
بعد suggest |
Accept ونفّذ |
n |
بعد suggest |
Reject |
Tab |
interactive mode |
يورّي alternative suggestion تاني |
↑/↓ |
interactive mode |
Navigate بين الـ options |
Ctrl+C |
أي وقت |
Cancel |
Escape |
confirmation |
Cancel |
السيناريوهات العملية
سيناريو 1: Natural language → shell command
gh copilot suggest "find all .txt files modified in the last 24 hours"
gh copilot suggest "backup my home directory excluding node_modules"
gh copilot suggest "show git log with graph and one line per commit"
سيناريو 2: Target shell معين
# PowerShell
gh copilot suggest -t powershell "list all running services"
# Git commands
gh copilot suggest -t git "undo last commit but keep changes"
gh copilot suggest -t git "create branch from old commit"
# GitHub CLI
gh copilot suggest -t gh "create issue with labels bug,urgent"
سيناريو 3: Pipe للـ shell مباشرة (automation)
#!/bin/bash
# One-liner: generate + execute بدون confirmation
gh copilot suggest --no-confirm -t bash "restart nginx" | bash
# In script: capture command
CMD=$(gh copilot suggest --no-confirm -t bash "deploy to staging")
$CMD
سيناريو 4: شرح أوامر معقدة
# فهم command من StackOverflow
grep -r 'TODO' . --include='*.js' | wc -l
gh copilot explain "awk '{print $1}' access.log | sort | uniq -c | sort -nr"
gh copilot explain "docker ps -a --filter 'status=exited'"
سيناريو 5: Debugging suggestions غريبة
gh copilot suggest --debug "delete old logs"
# يظهر الـ prompt والـ context اللي اتبعت للـ API
سيناريو 6: Git workflow كامل
# Triage issues
git copilot suggest -t gh "list open issues labeled bug sorted by oldest"
# PR review
git copilot suggest -t gh "show files changed in last PR"
# CI diagnosis
git copilot suggest "check why CI failed on my last push"
MCP Support
- Copilot CLI بيدعم Model Context Protocol (MCP) servers
- تقدر توصّله بأدوات خارجية: databases, documentation, APIs
- الـ config بيتم في GitHub Copilot settings أو workspace configs
- يخلي الـ CLI يقدر يعمل أكتر من shell commands بس
Hidden Features & Pro Tips
| # |
الحركة |
إزاي |
| 1 |
Tab cycles alternatives |
مش autocomplete بس — بيجيب suggestion مختلف تماماً |
| 2 |
Pipe لأي shell |
` |
| 3 |
No-confirm للـ scripting |
--no-confirm + pipe = fully automated |
| 4 |
Debug mode يكشف السحر |
--debug يظهر الـ prompt الحقيقي |
| 5 |
Target = context aware |
-t git بيفهم Git، -t gh بيفهم GitHub CLI |
| 6 |
Update منفصل |
gh extension upgrade مش محتاج update لـ gh core |
| 7 |
Works offline? لا |
بيعتمد على GitHub Copilot API — لازم internet |
Troubleshooting
| المشكلة |
الحل |
| "command not found: gh" |
brew install gh أو apt install gh |
| "Copilot is not enabled" |
gh auth login + تأكد من subscription نشط |
| "No suggestions returned" |
--debug شوف الـ API call |
| Suggestion غريب |
Tab جرب alternative |
| Permission denied لما بيعمل pipe |
تأكد إن الـ command نفسه مش محتاج sudo |
نصيحة الزتونة
أفضل استخدام: Workflow محوره GitHub — issues triage، PR review سريع، CI failure diagnosis. للـ code surgery عميق multi-file، قارن بينه وبين Claude Code و opencode — كل الزتونات عندنا والمقارنة في صفحة الـ Models.
الفرق الجوهري: Copilot CLI = "عايز أعمل إيه؟" → يولّد command. Claude Code = "صلّحلي الـ bug ده" → يقرا ويعدّل ويختبر لحد ما يخلّص.