diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-04-28 10:14:53 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-04-28 10:14:53 +0200 |
commit | fb429acf4c6526dede38975abcee85fff0c86c9c (patch) | |
tree | 9c6cc0ebbcdef9ba976d11869e65081b5dbd7499 /config/essentials/nvim/lua/user | |
parent | 7a07aeab94fba6c437cb9413393acb5dae8b5043 (diff) |
show last three dirs only
Diffstat (limited to 'config/essentials/nvim/lua/user')
-rw-r--r-- | config/essentials/nvim/lua/user/set.lua | 12 |
1 files changed, 10 insertions, 2 deletions
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 |