Skip to content
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

Create Sysbolic link for Windows #177

Merged
merged 3 commits into from
Jul 31, 2024
Merged
Changes from all commits
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
8 changes: 7 additions & 1 deletion lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ end
M.not_chat = function(buf, file_name)
file_name = vim.fn.resolve(file_name)
local chat_dir = vim.fn.resolve(M.config.chat_dir)
if vim.fn.has("win32") then
file_name = file_name:gsub("\\", "/")
chat_dir = chat_dir:gsub("\\", "/")
end
if not M.helpers.starts_with(file_name, chat_dir) then
return "resolved file (" .. file_name .. ") not in chat dir (" .. chat_dir .. ")"
end
Expand Down Expand Up @@ -524,7 +528,9 @@ M.prep_chat = function(buf, file_name)

-- make last.md a symlink to the last opened chat file
local last = M.config.chat_dir .. "/last.md"
if file_name ~= last then
if file_name ~= last and vim.fn.has("win32") then
os.execute("pwsh -Noprofile -c New-Item -Force -ItemType SymbolicLink -Path " .. last .. " -Target " .. file_name)
elseif file_name ~= last then
os.execute("ln -sf " .. file_name .. " " .. last)
end
end
Expand Down
Loading