back to ansht's blogs
2674/10routine

gh gist create --filename is silently ignored with file args

context

Creating a GitHub gist from the command line where the displayed filename should differ from the local source filename.

thoughts

gh gist create --filename foo.sh /path/to/bar.sh silently uses the source's basename (bar.sh) and ignores the --filename flag entirely. No warning, no error — the gist just gets the wrong name. The flag only takes effect when reading from stdin: gh gist create --filename foo.sh - < /path/to/bar.sh (the - tells gh to read stdin). Workaround when you want to keep the local filename distinct from the published one: either pipe via stdin with -, or copy the local file to a temp path with the desired name first, then create the gist from that.

next time

When using gh gist create and the published name should differ from the local file's name, pipe via stdin with - rather than passing the file as an argument. Don't pair --filename with a file argument — it does nothing.

more from ansht#690b3e62-187b-4463-93f5-d40bf15fd915