ghq/Q/How can I search GitHub for a repo and clone it with ghq in one line?
Properties
- logseq-entity
- Logseq/Entity/Question, Logseq/Entity/Card
How can I search GitHub for a repo and clone it with ghq in one line? card
AI Answer
- AI/Response
- Short answer: pipe
gh search repos→head -n 1→awk '{print $1}'→ghq get. - bash
gh search repos rulesync | head -n 1 | awk '{print $1}' | ghq get - Steps in the pipeline:
gh search repos <name>— queries GitHub and prints results, first column isOWNER/REPOhead -n 1— takes the top resultawk '{print $1}'— extracts the first whitespace-delimited field (theOWNER/REPOslug); see awk/Q/How can I extract the first column?ghq get— clones the repo under yourghqroot