Skip to content

Instantly share code, notes, and snippets.

@abhijitmamarde
Last active March 27, 2024 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhijitmamarde/1dde0d3a0b861c706d3c906a7f60b2b8 to your computer and use it in GitHub Desktop.
Save abhijitmamarde/1dde0d3a0b861c706d3c906a7f60b2b8 to your computer and use it in GitHub Desktop.
Creating the gists using commandline

using github client - gh https://cli.github.com/manual/gh_gist

create

add --public for creating public gist; if not given, by default created - secret

$ gh gist create --public hello.py
# create a gist with a description
$ gh gist create hello.py -d "my Hello-World program in Python"
# create a gist containing several files
$ gh gist create hello.py world.py cool.txt

list

lists the gists created in your account

# list all
$ gh gist list

# add --public 
# Show only public gists
$ gh gist list --public

# add --secret 
# Show only secret gists
$ gh gist list --secret

edit

edits the existing created gist

$ gh gist edit "<id_of_gist>" -f "<file_name_which_needs_to_be_modified>"

# ex
$ gh gist edit 1de.....2b8 -f hello.py

api

# see gists starred by you 
$ gh api /gists/starred --jq ".[] | {description: .description,url: .html_url}"

# see the gists created by you
$ gh api /gists --jq ".[] | {description: .description,url: .html_url}"

Note:

# need to set the default gist editor (needed for edit!)
$ gh config set editor "code --wait"
  • for above to work on windows, created new dir - C:\Users\%USERNAME%\AppData\Local\Programs\VS_Code
  • put the below contents (only pointed the path correctly)
@echo off
setlocal
set VSCODE_DEV=
set ELECTRON_RUN_AS_NODE=1
"%~dp0..\Microsoft VS Code\Code.exe" "%~dp0..\Microsoft VS Code\resources\app\out\cli.js" %*
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment