Skip to content

[Help] How do i make the CWD change when I load a session via the telescope picker? #158

Answered by Ajaymamtora
Ajaymamtora asked this question in Q&A
Discussion options

You must be logged in to vote

This seems to work but idk if the path decode function is fully correct

    local function decode_session_path(session_file)
      local encoded_path = session_file:gsub("^" .. vim.pesc(save_dir), ""):gsub("%.vim$", "")
      local decoded_path = encoded_path:gsub("%%", "/")
      return "/" .. decoded_path -- Add leading slash
    end
    local function load_decoded_session()
      local session_file = vim.v.this_session
      if session_file and session_file ~= "" then
        print("SESSION POST:", session_file)
        print("OTHER POST", vim.g.persisted_loaded_session)

        local decoded_path = decode_session_path(session_file)
        print("Decoded session path: " .. decoded_path

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@Ajaymamtora
Comment options

Answer selected by Ajaymamtora
Comment options

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

@Ajaymamtora
Comment options

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