From fb429acf4c6526dede38975abcee85fff0c86c9c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Fri, 28 Apr 2023 10:14:53 +0200 Subject: show last three dirs only --- config/essentials/nvim/lua/user/set.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'config/essentials/nvim/lua') diff --git a/config/essentials/nvim/lua/user/set.lua b/config/essentials/nvim/lua/user/set.lua index 864ffbd..64ff2fd 100644 --- a/config/essentials/nvim/lua/user/set.lua +++ b/config/essentials/nvim/lua/user/set.lua @@ -42,6 +42,14 @@ opt.backup = false opt.spelllang = "en_us,nl" opt.formatoptions = "cqrnj" --- current dir, where $HOME is replaced by ~ -opt.titlestring = "%{substitute(getcwd(), getenv('HOME'), '~', 'g')} -> %t " +-- Get the current working directory, replace the $HOME portion of the path with ~, +-- and extract the last three directories +local cwd = vim.fn.getcwd():gsub(os.getenv('HOME'), '~') +local last_dirs = string.match(cwd, "[^/]+/[^/]+/[^/]+/?$") +if last_dirs then + opt.titlestring = last_dirs .. " -> %t" +else + opt.titlestring = cwd .. " -> %t" +end + opt.title = true -- cgit v1.2.3