{"id":13394176,"url":"https://github.com/Jarred-Sumner/git-peek","last_synced_at":"2025-03-13T20:31:24.822Z","repository":{"id":43057218,"uuid":"337734158","full_name":"Jarred-Sumner/git-peek","owner":"Jarred-Sumner","description":"git repo to local editor instantly","archived":false,"fork":false,"pushed_at":"2021-02-20T10:43:43.000Z","size":18271,"stargazers_count":733,"open_issues_count":3,"forks_count":17,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-03-11T00:36:55.339Z","etag":null,"topics":["bbcode","cli","clone","fetch","github","github-api","github1s","githubcli","githubclient","homebrew","nvim","sublime-text","vim","vimrc","visual-studio-code"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jarred-Sumner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-10T13:34:56.000Z","updated_at":"2025-03-02T14:37:54.000Z","dependencies_parsed_at":"2022-07-19T22:00:00.960Z","dependency_job_id":null,"html_url":"https://github.com/Jarred-Sumner/git-peek","commit_stats":null,"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Fgit-peek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Fgit-peek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Fgit-peek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jarred-Sumner%2Fgit-peek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jarred-Sumner","download_url":"https://codeload.github.com/Jarred-Sumner/git-peek/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242956547,"owners_count":20212454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bbcode","cli","clone","fetch","github","github-api","github1s","githubcli","githubclient","homebrew","nvim","sublime-text","vim","vimrc","visual-studio-code"],"created_at":"2024-07-30T17:01:11.454Z","updated_at":"2025-03-13T20:31:23.573Z","avatar_url":"https://github.com/Jarred-Sumner.png","language":"JavaScript","readme":"# git-peek\n\n`git peek` is the fastest way to open a remote git repository in your local text editor.\n\n\u003c!-- \u003cvideo autoplay muted type=\"video/mp4\" src=\"demo.mp4\" autoplay loop muted playsinline width=\"960\" height=\"600\" /\u003e --\u003e\n\u003cimg src=\"demo.gif\" height=\"400\" /\u003e\n\nUse it when you want to browse or search other people's code with your own editor.\n\n## Installation:\n\nHomebrew:\n\n```\nbrew install jarred-sumner/git-peek/git-peek\n```\n\nFor Windows and Linux, install from npm directly:\n\n```\nnpm install -g @jarred/git-peek\n```\n\n1-click \"Peek\" button for GitHub:\n\n- [**Download peek for Chrome**](https://chrome.google.com/webstore/detail/peek-%E2%80%93-github-to-local-ed/lipffmbhaajmndiglgmmcfldgolfaooj)\n- [**Download peek for Firefox**](https://addons.mozilla.org/en-US/firefox/addon/git-peek-for-github/)\n\n## Usage:\n\n```\ngit peek https://github.com/ylukem/pin-go\ngit peek https://github.com/jarred-sumner/atbuild\ngit peek https://github.com/facebook/react/pull/20790\ngit peek hanford/trends\ngit peek react\ngit peek https://github.com/jarred-sumner/fastbench.dev/tree/main/\ngit peek https://github.com/evanw/esbuild/blob/master/lib/common.ts\n```\n\nPass `git peek` a git repository or a github link, and it will quickly fetch and open it in your local editor. It stores the repository in a temporary directory and deletes it when you close the editor or `git peek`.\n\nIt's fast.\n\n```bash\n❯ git peek https://github.com/nodejs/node/blob/master/lib/dgram.js\n⏳ Extracting repository to temp folder...\n💻 Launched editor in 0.20s\n```\n\nIf you paste a link to a pull request on GitHub, it will open it quickly:\n\n```\n❯ git peek https://github.com/facebook/react/pull/20790\n💻 Launched editor in 0.13s\n⏳ Extracting repository to temp folder...\n💿 Finished downloading repository!\n```\n\nMuch faster than cloning.\n\nIf you don't pass `git peek` input, it will let you search Github repositories and show [trending repositories](https://trends.now.sh):\n\n```\n❯ git peek\nSearch Github repositories:\n\u003e Search\n❯ iam-abbas/Reddit-Stock-T | Fetch currently trending stocks on Reddit\n  codeSTACKr/free-develope | Free Developer Resources\n  justjavac/1s             | 天若有情天亦老，我为网站加一秒\n  PaddlePaddle/PaddleNLP   | NLP Core Library and Model Zoo based on PaddlePa\n  ModernPwner/cicuta_viros |\n  jevakallio/vscode-live-f | Run your web app inside VS Code\n  getActivity/AndroidCodeS | Android 代码规范文档\n  gigantz/react-xpress     | React renderer to build Node.js server\n```\n\nIf you type a repository name without the owner (`react` instead of `facebook/react`), it will search:\n\n```\n❯ git peek react\nSearch Github repositories:\n\u003e react\n❯ facebook/react           | A declarative, efficient, and flexible JavaScrip\n  typescript-cheatsheets/r | Cheatsheets for experienced React developers get\n  duxianwei520/react       |  React+webpack+redux+ant design+axios+less全家桶后台管\n  discountry/react         | React docs in Chinese | React 中文文档翻译\n  Cathy0807/react          | 京东首页构建\n  react-redux-antd-es6/rea | 基于react的企业后台管理开发框架\n  HackYourFuture/React     | This repository contains all the material for th\n  geist-org/react          | Modern and minimalist React UI library.\n```\n\nIf you paste a link to a file on GitHub, it will quickly open the file in your local editor:\n\n```\n❯ git peek https://github.com/Jarred-Sumner/git-peek/blob/main/src/index.ts\n💻 Launched editor in 0.39s\n⏳ Extracting repository to temp folder...\n💿 Finished downloading repository!\n```\n\n```bash\n❯ git peek -h\n Quickly preview remote Git repositories in your local editor\n\n  USAGE\n    $ git-peek [git link or github link or search query or repository file path]\n\n  EXAMPLES\n    git peek https://github.com/evanw/esbuild/blob/master/lib/common.ts\n    git peek https://github.com/ylukem/pin-go\n    git peek https://github.com/jarred-sumner/atbuild\n    git peek hanford/trends\n    git peek react\n\n  OPTIONS\n    -e, --editor=editor  [default: auto] editor to open with, possible values:\n                          auto, code, subl, nvim, vim, vi, code-insiders.\n                          By default, it will search $EDITOR. If not found, it\n                          will try code, then subl, then vim.\n\n    -r, --register        [default: false] Register the git-peek:// url protocol\n                          This allows the \"Open\" buttons to work on\n                          github.com once you\\'ve installed the extension. Only\n                          supported on macOS and Windows\n\n    -o, --out=           [default: system temp directory] output directory to\n                          store repository files in. If youre cloning a large\n                          repo and your tempdir is an in-memory storage (/tmp),\n                          maybe change this.\n\n    -w, --wait           [default: false] wait to open the editor until the\n                          repository finishes downloading. always on for vi.\n\n    --no-keep            [default: false] keep the repository, rather than\n                         deleting it.\n\n    -b, --branch         [default: \"master\"] select a branch/ref to use.\n                         if the repository doesn't use master/main,\n                         you'll want to set this manually. but it will\n                         try to infer from the input by default.\n\n    -d                   [default: false] Ask the GitHub API\n                          for the default_branch to clone.\n\n    -h, --help           show CLI help\n\n  ENVIRONMENT VARIABLES:\n    $EDITOR: code --wait\n    $GITHUB_TOKEN: ********\n    .env: ✅ $HOME/.git-peek\n\n  For use with private GitHub repositories, set $GITHUB_TOKEN to a personal\n  access token. To persist it, store it in your shell config or the .env shown above.\n```\n\n### Private repositories \u0026 choosing an editor\n\nTo use `git-peek` with private repositories, set a `$GITHUB_TOKEN` to a personal access token. If you don't want a global shell `$GITHUB_TOKEN`, you can set in `$HOME/.git-peek`.\n\nIts a `.env` file, so the syntax looks like this:\n\n```bash\nEDITOR=\"code\"\nGITHUB_TOKEN=\"**********\"\n```\n\nYou can also save a custom editor this way. So you don't have to add `-e vim` everytime if `$EDITOR` is not propagating to the process.\n\n## How does this work?\n\nIf you pass it a GitHub repository, it fetches a tarball instead of using git and decompresses it while downloading it (streaming). From unscientific benchmarks, this is about 2x faster than cloning. While downloading \u0026 decompressing the tarball, it also downloads the specific file linked to (or the `README.md`) via JSDelivr's CDN. Whichever happens first, it opens in the editor (usually JSDelivr), but it will keep fetching the repo until its complete or the program exits.\n\nIf you pass it a git repository rather than a Github url, it does a [partial clone](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/) instead of doing a full clone.\n\nWhen your editor closes or you close `git peek`, it deletes the repository from your computer.\n\n### Changelog\n\n##### `1.3.18`\n\n- Add support for BBCode on macOS\n- Adjust location for the shim that opens git-peek on macOS from extension (thanks @JayBrown)\n\n##### `1.3.14 - 1.3.17`\n\n- Fix $EDITOR detection bug\n\n##### `1.3.14`\n\n- Auto-detect `nvim`\n- Add `/n?vim?/` support for Peek (browser extension) on macoS.\n\n##### `1.3.8 - 1.3.13`\n\n- Improve reliability of `git peek -r` on macOS\n- Support skipping JSDelivr requests when we know in advance its a private repository\n- Fix the homebrew build\n\n##### `1.3.7`\n\n- Fix AbortController polyfill in Node 14.\n\n##### `1.3.6`\n\n- Fix windows path bug\n\n##### `1.3.5`\n\n- Improve start performance by about 25% via code splitting\n\n##### `1.3.4`\n\n- Improve reliability of deleting files on Windows. On POSIX systems, you can delete files when they're in use. Windows will refuse, even if \"in use\" means, the process' current working directory is set to it but there aren't necessarily files open for it. The fix was to make it so that the current working directory on Windows is the parent directory, and also to tell `rimraf` to first delete all the files inside the folder and then delete the folder itself. This probably isnt' ideal for performance, maybe there's a more \"native\" system call for this.\n- Fix logs that were supposed to only show up with `VERBOSE` env var set\n- More reliably exit the process when opened from browser extension on Windows. Trying to prevent lots of extraneous `subl.exe` from showing up\n\n##### `1.3.3`\n\n- Add support for GitHub Enterprise! (Thanks @Thau)\n- Fix detecting when you closed Visual Studio Code after opening it from `git-peek://` (this already worked in the CLI). `git-peek` should now automatically delete the repository when using the browser extension (when your editor is Visual Studio Code)\n\n#### `1.3.0 - 1.3.2`\n\n##### Windows\n\n- Add Windows support for registering the `git-peek://` protocol!! (related: https://github.com/Jarred-Sumner/register-url-windows). This enables 1-click open buttons on GitHub. Run `git peek --register`\n- Add `./bin/git-peek-win32.exe` that runs `git-peek` without the CMD.exe window appearing (source code is in the `win32` folder). It just receives `git-peek://` URLs, so if you run it by itself, nothing will show up and you'll be kind of confused.\n\n##### Mac\n\n- Prevent homebrew from running cleanup and auto update when you run `git-peek --register`. So that it runs faster.\n- Prevent the applescript from stealing focus when you click the open button in the browser extension. To use this, you'll have to re-run `git-peek --register` if you haven't already.\n\n#### Misc\n\n- Temp folder names now start with the `repository@branchOrRef` name e.g. `esbuild@main`, so its clearer what you're looking at in your editor. Its still a long string, but the beginning at least makes more sense now.\n- Temp folder names now end in `peekautodelete`. This will later be used for a `git-peek purge` command that will automatically delete any folders it finds in the temp directory containing `\"peekautodelete\"` incase anything was missed.\n- Fix bug where sometimes empty text would appear in your editor when it guessed the default filename wrong. Please open an issue if you see this happen again.\n- Will now confirm closing for Sublime Text instead of failing to detect when it closed and then hanging. Sublime Text's `--wait` CLI argument does not support folders, so it's pretty tough to detect when the user closes Sublime Text without some kind of process monitoring.\n- Add sourcemap file because why not\n- Made the \"Deleted repository\" log double check that the repository is no longer there before logging it.\n\n---\n\n- `1.2.2`: Prevent process from sticking around longer than necessary if its still extracting the repository when its supposed to close. Add `fs.rmSync` polyfill\n\n- `1.2.1`: Slightly improve reliability \u0026 performance of launching the editor (using child_process.spawn instead of using child_process.exec) and allow the AppleScript to launch multiple instances\n\n- `1.2.0`: Create a `git-peek://` URL handler, so that you can click a link to open a repository in your local editor. Register the URL handler with `git peek -r`.\n\n- `1.1.37`: Add easter egg to search results\n\n- `1.1.36`: Add optional `-d` flag that automatically asks github what the default branch is before cloning instead of guessing its either `main` or `master`.\n\n- `1.1.35`: Add optional `--branch` flag so you can choose which branch to clone if its not shown in the url. See [#17](https://github.com/Jarred-Sumner/git-peek/issues/17)\n\n- `1.1.34`: Fix home directory path resolution on Windows\n\n- `1.1.33`: Add precompiled binary for windows in releases script.\n\n- `1.1.32` Add `--no-keep` flag which skips deleting repositories on exit. Fix support for unknown editors. When the editor is unknown, it asks to confirm deleting the repository.\n\n- `1.1.31`: Fix issue where when `vim` is loaded with a specific file (rather than the repository root dir), it would log text on top of `vim`.\n\n### `1.1.30`\n\ngit-peek now starts 32% faster (delayed loading `ink` until its used for search)\n\nYou can now store `$EDITOR` and `$GITHUB_TOKEN` in `$HOME/.git-peek`. Its a `.env` file, so the syntax looks like this:\n\n```bash\nEDITOR=\"code\"\nGITHUB_TOKEN=\"**********\"\n```\n\nRemoved using the `$GITHUB_TOKEN` from `~/.hubs/config`.\n\n- `1.1.28-29`: Fix for Node 12+ [#14](https://github.com/Jarred-Sumner/git-peek/issues/14)\n- `1.1.27`: Added `--wait` flag which waits to open the editor until the entire repository is downloaded. Added `--out` flag which changes the temp directory to store files in (see #8)\n- `1.1.22-26`: Fix windows bug.\n- `1.1.21`: Add Pull Request support. Now you can use this to quickly read a pull request. For example: `git peek https://github.com/facebook/react/pull/20790`.\n- `1.1.20`: Fix bug when using with Fedora\n- `1.1.16-1.1.19`: trying to get `release-it` to work\n- `1.1.15`: Move `code-insiders` to end of preference list\n- `1.1.14`: Fix code-insiders and fix passing in editor manually when its `subl` or `code`.\n- `1.1.13`: Use `Authorization` header instead of `access_token` query string.\n- `1.1.12`: When available, also use github access token for fetching tarballs (instead of just search)\n- `1.1.11`: When available, use github access token for github API requests to enable private repositories to work. To enable this, either set a `GITHUB_TOKEN` environment variable or if you've installed [hub](https://github.com/github/hub), it will automatically use `oauth_token` from `$HOME/.config/hub`. In other words, if you use `hub`, this should just work by default.\n- `1.1.10`: Fix vim\n- `1.1.9`: Fix Windows\n\n### Known Bugs\n\n#### Sublime Text\n\n`subl --wait` does not support folders, so git-peek is unable to detect when Sublime Text closes. On the CLI, this isn't a problem – it just shows a \"Delete Repository Y/n\" confirm message, same as other editors.\n\n![image](https://user-images.githubusercontent.com/709451/107998350-d3431380-6f99-11eb-9088-cda304e73e06.png)\n\nOn the browser extension, I'm not really sure yet what to do about this.\n\nVisual Studio Code doesn't have this problem because passing a directory to `--wait` correctly waits until the window is closed.\n\nOriginally inspired by [github1s.com](https://github.com/conwnet/github1s).\n","funding_links":[],"categories":["JavaScript","cli","\u003ca name=\"git\"\u003e\u003c/a\u003eGit and accessories"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJarred-Sumner%2Fgit-peek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJarred-Sumner%2Fgit-peek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJarred-Sumner%2Fgit-peek/lists"}