Configure synchronization of files and directories through a plugin.
removed -m flag
1 file changed, +13 -9
+13-9lua/syncmap/rsync.lua
| @@ -11,8 +11,15 @@ function M.run(args) | ||
| 11 | 11 | local result = vim.fn.system(cmd) |
| 12 | 12 | if vim.v.shell_error ~= 0 then |
| 13 | 13 | log.error(table.concat(cmd, " ") .. " failed:\n" .. result) |
| 14 | + log.error( | |
| 15 | + string.format( | |
| 16 | + "Failed to run the the following rsync command.\n%s\nResult: %s", | |
| 17 | + table.concat(cmd, " "), | |
| 18 | + result | |
| 19 | + ) | |
| 20 | + ) | |
| 14 | 21 | else |
| 15 | - log.info(table.concat(cmd, " ") .. " succeeded") | |
| 22 | + log.info("Successfully ran the following rsync command.\n" .. table.concat(cmd, " ")) | |
| 16 | 23 | end |
| 17 | 24 | return result |
| 18 | 25 | end |
| @@ -28,27 +35,24 @@ function M.spawn_watcher(args) | ||
| 28 | 35 | }) |
| 29 | 36 | end |
| 30 | 37 | |
| 31 | - local tag = string.format("syncmap:%s->%s", args.src, args.dst) | |
| 32 | - | |
| 33 | 38 | local cmd = string.format( |
| 34 | - "while inotifywait -r -m -e modify,create,delete %q; do rsync %s %q %q; done; : %s", | |
| 39 | + "while inotifywait -r -e modify,create,delete %q; do rsync %s %q %q; done", | |
| 35 | 40 | args.src, |
| 36 | 41 | table.concat(args.flags, " "), |
| 37 | 42 | args.src, |
| 38 | - args.dst, | |
| 39 | - tag | |
| 43 | + args.dst | |
| 40 | 44 | ) |
| 41 | - local cmd_str = "sh -c '" .. cmd .. "'" | |
| 45 | + local cmd_str_for_log = "sh -c '" .. cmd .. "'" | |
| 42 | 46 | |
| 43 | 47 | local _, pid = simple_cmd.spawn("sh", { |
| 44 | 48 | args = { "-c", cmd }, |
| 45 | 49 | path = "sh", |
| 46 | 50 | cwd = args.src, |
| 47 | 51 | callback = function(code, status, _, pid) |
| 48 | - log.info(string.format("%s\n%d completed with %d code and %d status", cmd_str, pid, code, status)) | |
| 52 | + log.info(string.format("%s\n%d completed with %d code and %d status", cmd_str_for_log, pid, code, status)) | |
| 49 | 53 | end, |
| 50 | 54 | }) |
| 51 | - log.info(string.format("%s\nPid is %d", cmd_str, pid)) | |
| 55 | + log.info(string.format("Started the following command with pid %d\n%s", pid, cmd_str_for_log)) | |
| 52 | 56 | return pid |
| 53 | 57 | end |
| 54 | 58 |