dotfiles/.config/keyb/merge.lua

30 lines
844 B
Lua
Executable File

#! nvim -l
local config_dir = "/home/bryan/.config/keyb"
local output_filename = "keyb.yml"
local output_filename_full = vim.fs.joinpath(config_dir, output_filename)
vim.print("\nBacking up " .. output_filename .. " to " .. output_filename .. ".bak\n")
vim.system({ "mv", output_filename_full, output_filename_full .. ".bak" }):wait()
local outfile = io.open(output_filename_full, "a")
vim.print("Merging files...\n\n")
if outfile then
for file in vim.fs.dir(config_dir) do
if file:match("%.yml$") and not file:match("config") and not file:match(output_filename) then
vim.print(file .. " >> " .. output_filename)
local infile = io.open(vim.fs.joinpath(config_dir, file), "r")
if infile then
local contents = infile:read("*a")
if contents then
outfile:write(contents)
end
end
end
end
end
vim.print("\n")