Skip to content

Instantly share code, notes, and snippets.

View mountaineerbr's full-sized avatar
🌴
On vacation

mountaineerbr mountaineerbr

🌴
On vacation
View GitHub Profile

$ cat ./README.md ./gpt | gpt Please update the README > README.md

Just kidding, I wrote the readme... or did I?

$ gpt

This Bash script uses the OpenAI API to generate a response to a user-specified query using the GPT-3 language model. The response is appended to a specified context file, which contains the history of messages and responses.

@pjeby
pjeby / shelldown-demo
Last active October 9, 2024 08:32
"You got your markdown in my shell script!" "No, you got your shell script in my markdown!"

Mixed Markdown and Shell Scripting

: By the power of this magic string: ex: set ft=markdown ;:<<'```shell' #, this file is now both a markdown document and an executable shell script. chmod +x it and try running it!

The above line does just what it says. More specifically, when placed within in the first 5 lines and preceded only by blank lines or #-prefixed markdown headers:

  1. The first part of the magic string makes github and various editors (e.g. atom with the vim-modeline packge) treat the file as having markdown syntax (even if the file doesn't have an extension)
  2. The second part (if run in a shell), makes the shell skip execution until it encounters the next ```shell block.

(The line also has to start with a : so that it's valid shell code.)