{"id":17724329,"url":"https://github.com/zutto/book.vim","last_synced_at":"2025-03-31T13:53:47.072Z","repository":{"id":159142057,"uuid":"365345690","full_name":"zutto/book.vim","owner":"zutto","description":"a poor mans not-a-notebook-book","archived":false,"fork":false,"pushed_at":"2021-05-08T09:24:53.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T08:33:42.375Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zutto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-07T20:26:59.000Z","updated_at":"2021-05-08T09:24:55.000Z","dependencies_parsed_at":"2023-05-01T22:31:33.723Z","dependency_job_id":null,"html_url":"https://github.com/zutto/book.vim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zutto%2Fbook.vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zutto%2Fbook.vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zutto%2Fbook.vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zutto%2Fbook.vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zutto","download_url":"https://codeload.github.com/zutto/book.vim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246476893,"owners_count":20783903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-25T15:46:31.657Z","updated_at":"2025-03-31T13:53:47.038Z","avatar_url":"https://github.com/zutto.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"## note\nThis is not actively maintained, and has been left in a semi-working state of work-in-progress. Hopefully one day I'll get back to actually finishing this properly. I am just throwing this out to public, so it doesn't just sit on my computer, it's a fun plugin made in a rush during 2020 advent of code.\n\n# book.vim\nVim plugin to evaluate scripts \u0026 code inline with ease!\n\n## Features\n* Easy to use - just write your shebang under your code.\n* Configurable!\n* Evaluate multiple chunks of code\n* Evaluate output of previous code chunk in a following chunk! (* note: theres probably bugs with this)\n* Code is still usable outside of vim!\n\n## Usage\nJust write `#!/bin/bash` and run :Book to get output! ( asciinema recording explains better than thousand words!)\n\n#### Simple usage\n[![asciicast](https://asciinema.org/a/93QJfa7hAlm5fmf7UXI6GA1q6.svg)](https://asciinema.org/a/93QJfa7hAlm5fmf7UXI6GA1q6)\n### Long running scripts with a piped output and not just a simple command? Not a problem!\n[![asciicast](https://asciinema.org/a/eh9lYJo3vCkPecSkXRZLObjG1.svg)](https://asciinema.org/a/eh9lYJo3vCkPecSkXRZLObjG1)\n#### Previous commands output to next chunk of code? can do. Default replacement variable: `!!`\n[![asciicast](https://asciinema.org/a/412725.svg)](https://asciinema.org/a/412725)\n\n#### want to have code cut from the chunk? not a problem.\nJust insert a shebang line without command to split the output.\n\n```\n#!/bin/bash\necho \"Hello World!\";    \n#!    \necho \"foo bar!\";    \n#!/bin/bash\n# foo bar!\n```\n\n\n##  Configuration\n#### Basic settings\n```\n\" comment is the character(S) prefixing all output lines, \n\" to preserve the executability of the code outside of vim.\nlet g:book_comment='#' \n\n\" Shebang is the *nix magic, prefixed by a comment character with this as a suffix\n\" #!/bin/bash as an example.\nlet g:book_shebang='!'\n\n\" Embed output of previous chunk into the following chunk of code with this value.\n\" It literally replaces the inlineEmbed value with the output of previous command.\n\" This is a buggy feature, and possibly removed later on.\nlet g:book_inlineEmbed='!!'\n\n\" Don't think that this works, but is a plan to ensure that there are\n\" no code that just keep executing forever if configured.\nlet g:book_timeout='2' \" don't this this currently works..\n\n\" Another planned feature of evaluating single lines of code.\nlet g:book_inline='#!' \" this is a planned feature.\n\n\" evaluate only on change. I don't this this is implemented either,\n\" all code blocks are re-evaluated upon execution of :Book.\nlet g:book_onchange='0' \"\n```\n\n#### How do I  evaluate my code right after leaving input mode?\nAdd this to your vimrc.\n```\nautocmd InsertLeave * :Book\n```\n\n#### different shebang lines for different languages? no problem!\n take a look at this example and adjust it to your preferences!\n```\naugroup book_settings    \n        autocmd!    \n        autocmd BufNewFile,BufRead,Filetype *.sh let g:book_comment='#'    \n        autocmd BufNewFile,BufRead,Filetype *.sh let g:book_shebang='!'    \n        autocmd BufNewFile,BufRead,Filetype *.sh let g:book_inline='#!'    \n        autocmd BufNewFile,BufRead,Filetype *.sh let g:book_inlineEmbed='!!'    \n        autocmd BufNewFile,BufRead,Filetype *.sh let g:book_timeout='0'    \n        autocmd BufNewFile,BufRead,Filetype *.sh let g:book_onchange='0' \"only re-run on change    \n    \n        autocmd!    \n        autocmd BufNewFile,BufRead,Filetype *.lua let g:book_comment='--'    \n        autocmd BufNewFile,BufRead,Filetype *.lua let g:book_shebang='!'    \n        autocmd BufNewFile,BufRead,Filetype *.lua let g:book_inline='--'    \n        autocmd BufNewFile,BufRead,Filetype *.lua let g:book_inlineEmbed='!!'    \n        autocmd BufNewFile,BufRead,Filetype *.lua let g:book_timeout='0'    \n        autocmd BufNewFile,BufRead,Filetype *.lua let g:book_onchange='0' \"only re-run on change    \n    \naugroup end    \n```\n#### Compiled language?\nHeres an example of a script I made for golang, modify it for your own usage, and add it tosomewhere in your env and refer to it in your shebang.\n```\n#!/bin/bash    \n#disable gomod    \nGO111MODULE=off    \n    \n##create temp file and redirect STDIN to it    \nTMP=$(mktemp \"/dev/shm/XXXXXXXXXXXXXXXXX.go\");    \nwhile read -r line; do echo \"$line\" \u003e\u003e \"$TMP\"; done    \nshift;    \n#evaluate code \u0026 acquire exitcode    \ngo run \"$TMP\" ${@/#/};    \nec=$?;    \n    \n#clear tmp    \nrm \"$TMP\"    \n    \n#exit with go run exit code    \nexit $ec;\n```\n\n\n---\n---\n---\n\n[![asciicast](https://asciinema.org/a/412666.svg)](https://asciinema.org/a/412666)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzutto%2Fbook.vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzutto%2Fbook.vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzutto%2Fbook.vim/lists"}