oil.nvim icon indicating copy to clipboard operation
oil.nvim copied to clipboard

show relative path in window title rather than absolute path

Open santhosh-tekuri opened this issue 1 year ago • 2 comments
trafficstars

Did you check existing requests?

  • [X] I have searched the existing issues

Describe the feature

show relative path in window title rather than absolute path

I am using floating window. and absolute path for my project is very long and gets truncated in window title it would be better if there is an option to show relative path from current working directory in window title

Provide background

trying to show relative path in window title rather than absolute path when shown in floating mode

What is the significance of this feature?

nice to have

Additional details

No response

santhosh-tekuri avatar May 19 '24 08:05 santhosh-tekuri

With the merged PR (#482) now you can add the following to your config to achieve that:

{
  'stevearc/oil.nvim',
  opts = {
    float = {
      get_win_title = function(winid)
        local cwd = vim.fn.getcwd()
        local buf = vim.api.nvim_win_get_buf(winid)
        local file_path = vim.api.nvim_buf_get_name(buf)
        local relative_path = file_path:sub(#cwd - 1)

        -- leading and trailing spaces just as a personal preference
        return ' ' .. relative_path .. ' '
      end,
    },
  },
}

rtalexk avatar Apr 22 '25 18:04 rtalexk

the above code does not work as expected. since file_path is in the format oil:///.....

santhosh-tekuri avatar May 03 '25 15:05 santhosh-tekuri