Skip to content

Support sheband and tangle mode header tag #939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(babel): add shebang support for tangled code blocks
Add the ability to include a shebang line at the beginning of tangled code files
by supporting the `:shebang` header argument. The shebang value is cleaned of
quotes and inserted as the first line of the tangled content.
  • Loading branch information
SjB committed Apr 16, 2025
commit 8441de0b3b95ff0ec591e8ec3134531f6d369c7c
7 changes: 7 additions & 0 deletions lua/orgmode/babel/tangle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ function Tangle:tangle()
vim.fn.mkdir(path, 'p')
end

local shebang = info.header_args[':shebang']
if shebang then
shebang = shebang:gsub('[\'"]', '')
utils.echo_info(('shebang: %s'):format(shebang))
table.insert(parsed_content, 1, shebang)
end

if info.name then
block_content_by_name[info.name] = parsed_content
end
Expand Down