Skip to content

Default permissions when creating new file #708

Answered by pysan3
dpetka2001 asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately the permissions are hard-coded here.

But you can write a file_added handler to overwrite the permission right after the files / directories are created. Something like this should work.

(This implementation does not handle permissions of parent directories created together (if any) tho. Feel free to customize it if you need.)

*Tested only on Linux...

event_handlers = {
  {
    event = "file_added",
    handler = function (destination)
      local uv = vim.loop
      local file_info = uv.fs_stat(destination)
      if not file_info then
        return
      elseif file_info.type == "file" then
        uv.fs_chmod(destination, 436) -- (436 base 10) == (664 base 8)
      elseif f…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dpetka2001
Comment options

@dpetka2001
Comment options

Answer selected by dpetka2001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants