Scripting and shell integration
Jump into repositories with print-path, refresh the cache from cron, and rely on exit codes in scripts.
Jump into a repository
-p or --print-path changes what enter does. The action menu is skipped: enter on a repository picks it, clones it first when it is not on disk, and prints its absolute path on stdout. Everything else, including the screen and git's progress, goes to stderr.
A shell function that does not cd when you quit without picking:
Quitting without a pick exits with status 130, so the && stops and cd "" never runs.
Combine it with a clone root so new clones land in one place:
Refresh the cache on a schedule
gh select refresh fetches every repository you can access, saves the cache and prints the count. It never opens the screen, so it suits cron and timers.
Other commands, doctor, limits, version and help, also run once and exit.
Checking a version in a script
A newer release, when the last daily check found one, is named on stderr, so $(gh select version) still captures only the version line. A local build prints dev+COMMIT, with -dirty when the tree had uncommitted changes.
Exit codes
| Code | Meaning |
|---|---|
0 | success |
1 | a runtime error, printed on stderr after error |
2 | a command line that could not be understood, with the closest valid name suggested |
130 | --print-path ended without a pick |
See exit codes for details.
Plain output
Help and error output is colored only when stderr or stdout is a terminal. Set NO_COLOR to any value to turn color off.
Last updated on