Skip to content

Commit f285180

Browse files
committed
docs: test
1 parent bb72231 commit f285180

File tree

1 file changed

+303
-0
lines changed

1 file changed

+303
-0
lines changed

README.md

Lines changed: 303 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,306 @@ See `gh workflow list --help` for available options
170170
```sh
171171
gh fzf workflow --all
172172
```
173+
174+
### Command: `release`
175+
176+
`gh fzf release [flags]`
177+
178+
#### Aliases
179+
180+
`releases`, `--release`, `--releases`
181+
182+
#### Flags
183+
184+
See `gh release list --help` for available options
185+
186+
#### Keybindings
187+
188+
| Key | Description | Configuration Environment Variable |
189+
| ------- | ------------------------------------------------------------------------------------- | ------------------------------------- |
190+
| `enter` | Download the assets from the selected release (see `gh release download --help`) | `GH_FZF_RELEASE_DOWNLOAD_KEY` |
191+
| `alt-X` | Delete the selected release (see `gh release delete --help`) | `GH_FZF_RELEASE_DELETE_KEY` |
192+
| `alt-s` | Filter the list, showing stable releases (exclude prereleases) | `GH_FZF_RELEASE_STABLE_FILTER_KEY` |
193+
| `alt-p` | Filter the list, showing published releases (exclude drafts) | `GH_FZF_RELEASE_PUBLISHED_FILTER_KEY` |
194+
| `alt-a` | Filter the list, showing releases in ascending order by date (defaults to descending) | `GH_FZF_RELEASE_ASCENDING_SORT_KEY` |
195+
196+
#### Examples
197+
198+
- Filter the initial list to exclude drafts and prereleases:
199+
200+
```sh
201+
gh fzf release --exclude-drafts --exclude-prereleases
202+
```
203+
204+
### Command: `label`
205+
206+
`gh fzf label [flags]`
207+
208+
#### Aliases
209+
210+
`labels`, `--label`, `--labels`
211+
212+
#### Flags
213+
214+
See `gh label list --help` for available options
215+
216+
#### Keybindings
217+
218+
| Key | Description | Configuration Environment Variable |
219+
| ------- | ------------------------------------------------------------------------------------- | ----------------------------------- |
220+
| `enter` | Print the name of the selected label(s) to stdout | `GH_FZF_LABEL_PRINT_KEY` |
221+
| `alt-n` | Edit the name of the most recently selected label (see `gh label edit --help`) | `GH_FZF_LABEL_EDIT_NAME_KEY` |
222+
| `alt-d` | Edit the description of the most recently selected label (see `gh label edit --help`) | `GH_FZF_LABEL_EDIT_DESCRIPTION_KEY` |
223+
| `alt-c` | Edit the color of the mostly recently selected label (see `gh label edit --help`) | `GH_FZF_LABEL_EDIT_COLOR_KEY` |
224+
| `alt-X` | Delete the most recently selected label (see `gh label delete --help`) | `GH_FZF_LABEL_DELETE_KEY` |
225+
| `alt-N` | Filter the list, sorting labels by name (defaults to creation date) | `GH_FZF_LABEL_NAME_SORT_KEY` |
226+
| `alt-D` | Filter the list, showing labels in descending order (defaults to ascending) | `GH_FZF_LABEL_DESCENDING_ORDER_KEY` |
227+
228+
#### Examples
229+
230+
- Filter the initial list to sort by label name in descending order
231+
232+
```sh
233+
gh fzf label --sort name --order desc
234+
```
235+
236+
### Command: `milestone`
237+
238+
`gh fzf milestone`
239+
240+
#### Aliases
241+
242+
`milestones`, `--milestone`, `--milestones`
243+
244+
#### Keybindings
245+
246+
| Key | Description | Configuration Environment Variable |
247+
| ------- | ------------------------------------------------------------------------------- | ---------------------------------------- |
248+
| `enter` | Print the name of the selected milestone to stdout | `GH_FZF_MILESTONE_PRINT_KEY` |
249+
| `alt-i` | Open `gh fzf issue` filtered for the selected milestone | `GH_FZF_MILESTONE_VIEW_ISSUES_KEY` |
250+
| `alt-X` | Close the selected milestone | `GH_FZF_MILESTONE_CLOSE_KEY` |
251+
| `alt-O` | Reopen the selected milestone | `GH_FZF_MILESTONE_REOPEN_KEY` |
252+
| `alt-t` | Edit the title of the selected milestone | `GH_FZF_MILESTONE_EDIT_TITLE_KEY` |
253+
| `alt-d` | Edit the description of the selected milestone | `GH_FZF_MILESTONE_EDIT_DESCRIPTION_KEY` |
254+
| `alt-s` | Filter the list, showing both open and closed milestones (defaults to open) | `GH_FZF_MILESTONE_STATE_FILTER_KEY` |
255+
| `alt-c` | Filter the list, sorting milestones by completeness (defaults to due date) | `GH_FZF_MILESTONE_COMPLETENESS_SORT_KEY` |
256+
| `alt-D` | Filter the list, showing milestones in descending order (defaults to ascending) | `GH_FZF_MILESTONE_DESCENDING_ORDER_KEY` |
257+
258+
### Command: `repo`
259+
260+
`gh fzf repo [flags]`
261+
262+
#### Aliases
263+
264+
`repos`, `--repo`, `--repos`
265+
266+
#### Flags
267+
268+
See `gh repo list --help` for available options
269+
270+
#### Keybindings
271+
272+
| Key | Description | Configuration Environment Variable |
273+
| ------- | ----------------------------------------------------------------------- | ---------------------------------- |
274+
| `enter` | Edit the selected repo's settings (see `gh repo edit --help`) | `GH_FZF_REPO_EDIT_KEY` |
275+
| `alt-i` | Run `gh fzf issue` on the selected repo (see [`issue`](#command-issue)) | `GH_FZF_REPO_VIEW_ISSUES_KEY` |
276+
| `alt-p` | Run `gh fzf pr` on the selected repo (see [`pr`](#command-pr)) | `GH_FZF_REPO_VIEW_PRS_KEY` |
277+
| `alt-r` | Run `gh fzf run` on the selected repo (see [`run`](#command-run)) | `GH_FZF_REPO_VIEW_RUNS_KEY` |
278+
| `alt-C` | Clone the selected repo (see `gh repo clone --help`) | `GH_FZF_REPO_CLONE_KEY` |
279+
| `alt-F` | Fork the selected repo (see `gh repo fork --help`) | `GH_FZF_REPO_FORK_KEY` |
280+
| `alt-c` | Filter the list, showing private repos (i.e. closed source) | `GH_FZF_REPO_PRIVATE_FILTER_KEY` |
281+
| `alt-o` | Filter the list, showing public repos (i.e. open source) | `GH_FZF_REPO_PUBLIC_FILTER_KEY` |
282+
| `alt-s` | Filter the list, showing source (non-forked) repos | `GH_FZF_REPO_SOURCE_FILTER_KEY` |
283+
| `alt-f` | Filter the list, showing forked repos | `GH_FZF_REPO_FORK_FILTER_KEY` |
284+
285+
#### Examples
286+
287+
- Filter the initial list to your non-archived, private repos with the "cli" topic:
288+
289+
```sh
290+
gh fzf repo --no-archived --visibility private --topic cli
291+
```
292+
293+
- Filter the initial list to archived repos created by the "google" organization where the primary language was "typescript":
294+
295+
```sh
296+
gh fzf repo google --archived --language typescript
297+
```
298+
299+
### Command: `gist`
300+
301+
`gh fzf gist [flags]`
302+
303+
#### Aliases
304+
305+
`gists`, `--gist`, `--gists`
306+
307+
#### Flags
308+
309+
See `gh gist list --help` for available options
310+
311+
#### Keybindings
312+
313+
| Key | Description | Configuration Environment Variable |
314+
| ------- | ----------------------------------------------------------------------------- | ---------------------------------- |
315+
| `enter` | Edit the selected gist (see `gh gist edit --help`) | `GH_FZF_GIST_EDIT_KEY` |
316+
| `alt-c` | Clone the selected gist to the current directory (see `gh gist clone --help`) | `GH_FZF_GIST_CLONE_KEY` |
317+
| `alt-X` | Delete the selected gist (see `gh gist delete --help`) | `GH_FZF_GIST_DELETE_KEY` |
318+
| `alt-p` | Filter the list, showing only public gists | `GH_FZF_GIST_PUBLIC_FILTER_KEY` |
319+
| `alt-s` | Filter the list, showing only secret gists | `GH_FZF_GIST_SECRET_FILTER_KEY` |
320+
321+
#### Examples
322+
323+
- Filter the initial list to only show public gists (excluding secret ones):
324+
325+
```sh
326+
gh fzf gist --public
327+
```
328+
329+
### Command: `search`
330+
331+
`gh fzf search <subcommand> [flags]`
332+
333+
> [!WARNING]
334+
> The `search` command is **experimental**, which means it is subject to breaking changes without a major version bump. Please report any bugs you find!
335+
336+
The `search` command works differently than the others. There are two different search modes:
337+
338+
1. **gh:** This is the initial mode and nothing is displayed until you type a query. The mode uses GitHub's search syntax, which you can read about in their documentation:
339+
- [`issues` & `prs`](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests)
340+
- [`repos`](https://docs.github.com/en/search-github/searching-on-github/searching-for-repositories)
341+
- [`commits`](https://docs.github.com/en/search-github/searching-on-github/searching-commits)
342+
- [`code`](https://docs.github.com/en/search-github/searching-on-github/searching-code)
343+
344+
2. **fzf:** This is the mode used by the rest of the commands, which uses `fzf` search syntax.
345+
346+
The mode is displayed in the bottom left corner. Start by searching with GitHub syntax. For example, you may type `author:@me` when using the `issues` or `prs` subcommands. When you switch modes from `gh` to `fzf`, the list remains the same and the GitHub query is saved to state and cleared from the search bar. You can then use `fzf` syntax to filter the list further. When you switch modes from `fzf` to `gh`, the GitHub query is restored and the list is reloaded.
347+
348+
#### Aliases
349+
350+
`s`, `-s`, `--search`
351+
352+
#### Subcommands
353+
354+
`issues`, `prs`, `repos`, `commits`, `code`
355+
356+
#### Flags
357+
358+
See `gh search <subcommand> --help` for available options
359+
360+
#### Keybindings
361+
362+
| Key | Description | Configuration Environment Variable |
363+
| ------- | ------------------------------------------ | ---------------------------------- |
364+
| `alt-/` | Toggle between `gh` and `fzf` search modes | `GH_FZF_SEARCH_TOGGLE_MODE_KEY` |
365+
366+
#### Examples
367+
368+
- Search for open issues that you're involved with, sorted by most recent update:
369+
370+
```sh
371+
gh fzf search issues state:open involves:@me sort:updated
372+
```
373+
374+
- Search for public repos that use the "lua" language and have the "neovim-plugin" topic, sorted by the number of stars:
375+
376+
```sh
377+
gh fzf search repos --visibility=public --language=lua --topic=neovim-plugin --sort=stars
378+
```
379+
380+
- Search for commits you made in 2024 that contain the phrase "breaking change" in the message:
381+
382+
```sh
383+
gh fzf search commits --author=$(gh api user --jq '.login') --author-date=2024-01-01..2024-12-31 \"breaking change\"
384+
```
385+
386+
- Search for code in repos you own that matches "fetch":
387+
388+
```sh
389+
gh fzf search code --owner=$(gh api user --jq '.login') fetch
390+
```
391+
392+
## Configuration
393+
394+
Environment variables are used to configure `gh-fzf`.
395+
396+
| Variable | Description | Default |
397+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
398+
| `GH_FZF_DEFAULT_LIMIT` | The initial number of items to request from GitHub. The number of items can be changed at runtime with the `alt-1` to `alt-9` commands, see the [Usage](#usage) section for more info. | 75 |
399+
| `GH_FZF_TRUNCATE_FIELDS` | Set the variable to any value to make `gh` truncate text to ensure all fields fit on the screen. When set, truncated text is **not** fuzzy findable. When unset, fields may be cut off, but all text is still fuzzy findable. | unset |
400+
| `GH_FZF_HIDE_HINTS` | Set the variable to any value to hide the header (where the keybinding hints are) on startup. The header can still be toggled with the `alt-H` keybinding. | unset |
401+
| `GH_FZF_BRANCH_PREFIX` | A string to prepend to the branch name entered for the `pr` command's `alt-o` keybinding. Spaces are replaced with hyphens. See the feature's [commit message] for examples. | unset |
402+
| `GH_FZF_BRANCH_ADD_ISSUE_NUMBER` | When set, the issue number is added after the prefix (if specified) for the `pr` command's `alt-o` keybinding. The variable's value is added after the number, unless it is a space. See the feature's [commit message] for examples. | unset |
403+
| `GH_FZF_NOTIFY_ICON` | A path to an icon for the desktop notification displayed by the `run` command's `alt-n` keybinding. Only supported by `dunstify` and `notify-send` for now. | unset |
404+
| `GH_FZF_COPY_CMD` | The command used by your operating system to copy an item's URL to the clipboard. Expects the URL from stdin. This only needs to be set if the default doesn't work on your machine. | [see code] |
405+
406+
[commit message]: https://github.com/benelan/gh-fzf/commit/f6f78e2dce617f17c6048f28f568fbdc57895119
407+
[see code]: https://github.com/benelan/gh-fzf/blob/65bfdb81a30fc55878e04758e5cbcec68a242a18/gh-fzf#L113-L125
408+
409+
You can also set the [`FZF_DEFAULT_OPTS`](https://github.com/junegunn/fzf/blob/master/README.md#environment-variables) environment variable to add/change `fzf` options used by `gh-fzf` commands.
410+
411+
For example, create aliases in the `gh` config file that add new keybindings to the [`issue`](#command-issue), [`pr`](#command-pr), [`run`](#command-run), and [`milestone`](#command-milestone) commands:
412+
413+
```yml
414+
# ~/.config/gh/config.yml
415+
aliases:
416+
i: |
417+
!FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
418+
--bind='alt-+:execute(gh issue edit --add-assignee @me {1})'
419+
--bind='alt--:execute(gh issue edit --remove-assignee @me {1})'
420+
--bind='alt-@:execute(
421+
selected=\"\$(gh fzf milestone)\"
422+
[ -n \"\$selected\" ] && gh issue edit --milestone \"\$selected\" {1}
423+
)'
424+
" gh fzf issue $*
425+
426+
p: |
427+
!FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
428+
--bind='alt-+:execute(gh pr review --approve --body \":+1:\" {1})'
429+
--bind='alt--:execute(gh pr review --request-changes {1})'
430+
--bind='alt-m:execute(gh pr merge --delete-branch --squash {1})'
431+
" gh fzf pr $*
432+
433+
r: |
434+
!FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
435+
--bind='alt-e:execute(gh run view --log-failed {-1})'
436+
--bind='alt-q:reload(eval \"\$FZF_DEFAULT_COMMAND --status queued\")'
437+
" gh fzf run $*
438+
439+
m: |
440+
!FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS
441+
--bind='alt-bspace:execute(
442+
gh api --silent --method DELETE /repos/{owner}/{repo}/milestones/{-1}
443+
)+reload(eval \"\$FZF_DEFAULT_COMMAND\")'
444+
" gh fzf milestone
445+
```
446+
447+
When adding or modifying fzf keybindings:
448+
449+
- Use `{1}` in place of:
450+
- the `<number>` for the [`issue`](#command-issue) and [`pr`](#command-pr) commands
451+
- the `<tag>` for the [`release`](#command-release) command
452+
- the `<id>` for the [`gist`](#command-gist) command
453+
- the `<name>` for the [`label`](#command-label) command
454+
- Use `{-1}` in place of:
455+
- the `<run-id>` for the [`run`](#command-run) command
456+
- the `<workflow-id>` for the [`workflow`](#command-workflow) command
457+
- the `<number>` for the [`milestone`](#command-milestone) command
458+
459+
Check out the `gh-fzf` author's [`~/.config/gh/config.yml`](https://github.com/benelan/dotfiles/blob/master/.config/gh/config.yml) for more inspiration.
460+
461+
See the [code](https://github.com/benelan/gh-fzf/blob/65bfdb81a30fc55878e04758e5cbcec68a242a18/gh-fzf#L157-L179) for the list of fzf options shared by all `gh-fzf` commands.
462+
463+
> [!WARNING]
464+
> If any of the shared keybindings set by `gh-fzf` don't work, you may be overriding them in your shell's start up scripts (e.g. `~/.bashrc`) by setting the `$FZF_DEFAULT_OPTS` environment variable.
465+
466+
## Related projects
467+
468+
There is another `fzf` wrapper around `gh` that also provides some `git` functionality. However, it doesn't provide as many `gh` commands, keybindings, or configuration options.
469+
470+
- [`gh-f`](https://github.com/gennaro-tedesco/gh-f)
471+
472+
The main focus of `gh-fzf` is providing keybindings to run `gh` subcommands on the selected item, so `git` functionality is left to other tools. The following `fzf` wrappers around `git` are good options to bridge that gap.
473+
474+
- [`forgit`](https://github.com/wfxr/forgit)
475+
- [`git-fuzzy`](https://github.com/bigH/git-fuzzy)

0 commit comments

Comments
 (0)