summaryrefslogtreecommitdiff
path: root/config/essentials
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-04-28 10:14:53 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-04-28 10:14:53 +0200
commitfb429acf4c6526dede38975abcee85fff0c86c9c (patch)
tree9c6cc0ebbcdef9ba976d11869e65081b5dbd7499 /config/essentials
parent7a07aeab94fba6c437cb9413393acb5dae8b5043 (diff)
show last three dirs only
Diffstat (limited to 'config/essentials')
-rw-r--r--config/essentials/nvim/lua/user/set.lua12
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