Skip to content

Commit f0ca9b7

Browse files
committed
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.
1 parent 145dce4 commit f0ca9b7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lua/orgmode/babel/tangle.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ function Tangle:tangle()
6060
vim.fn.mkdir(path, 'p')
6161
end
6262

63+
local shebang = info.header_args[':shebang']
64+
if shebang then
65+
shebang = shebang:gsub('[\'"]', '')
66+
utils.echo_info(('shebang: %s'):format(shebang))
67+
table.insert(parsed_content, 1, shebang)
68+
end
69+
6370
if info.name then
6471
block_content_by_name[info.name] = parsed_content
6572
end

0 commit comments

Comments
 (0)