Skip to content

gh gist edit: use prefix matching for gist id #7000

Description

@tuananhlai

Describe the feature or problem you’d like to solve

Currently, gh gist edit command requires the user to put in the full Gist ID. I'd like to put in only the first few characters from the gist ID.

Proposed solution

  • Select the gist with the longest-matching prefix. If no gist matched, display gist not found as usual.
  • If there are 2 or more gists with the same prefix, display a selector.
vscode ➜ /workspaces/cli (trunk) $ gh gist edit 0c909
Editing gist 0c9097af4101ce6d43615d01e66dbbfa
? Edit which file?  [Use arrows to move, type to filter]
> Makefile
  README.md
  btree.go
  btree_test.go
vscode ➜ /workspaces/cli (trunk) $ gh gist edit 0c909
There are multiple gist matching '0c909'. Which one do you want to edit?
> 0c9097af4101ce6d43615d01e66dbbfa
  0c9098122c98006d2fd5b9f9eb5c5ac3

Activity

  1. added
    needs-designAn engineering task needs design to proceed
    and removed on Feb 27, 2023
  2. kousikmitra commented on May 6, 2023

    @kousikmitra
    Contributor

    @vilmibI can we use something similar to existing gh gist view which shows a picker to pick from a list in case no gist id provided?

  3. vilmibm commented on May 16, 2023

    @vilmibm
    Contributor

    can we use something similar to existing gh gist view which shows a picker to pick from a list in case no gist id provided?

    I'm in favor of gh gist edit matching gh gist view in that regard, yeah.

  4. dardo82 commented on May 30, 2023

    @dardo82

    Could we do the same thing matching the description?

  5. kousikmitra commented on May 31, 2023

    @kousikmitra
    Contributor

    can we use something similar to existing gh gist view which shows a picker to pick from a list in case no gist id provided?

    I'm in favor of gh gist edit matching gh gist view in that regard, yeah.

    Great, I will raise a PR once I get sometime to work on this.

  6. 0xdevalias commented on Sep 15, 2025

    @0xdevalias

    This might be useful as a semi-partial workaround (or inspiration towards one) in the meantime:

    This workaround command using fzf from another tangentially related thread is actually quite useful here:

    workaround:

    alias gist='gh gist edit $(gh gist list | fzf --reverse | awk "{print \$1}")'

    Originally posted by @hholst80 in #2471 (comment)

    And because it uses gh gist list, it means we could also pass in extra args like --limit, --filter, --public, --secret, etc. eg:

    gist-edit() {
      local search="$1"
      gh gist edit "$(
        gh gist list --filter "$search" --limit 100 |
        fzf --reverse |
        awk '{print $1}'
      )"
    }

    Though maybe the 'official' implementation could include caching / local filtering / similar maybe, so we're not having to hit the API with a high --limit all the time?

    Originally posted by @0xdevalias in #11738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-gistrelating to the gh gist commandneeds-designAn engineering task needs design to proceed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions