From fff89d603463200011c1d80a808dda03b72d2788 Mon Sep 17 00:00:00 2001 From: Rakshit Sinha Date: Wed, 27 Nov 2024 23:31:00 -0800 Subject: [PATCH] Rename current tmux window based on directory name --- lua/rakshit/core/options.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/rakshit/core/options.lua b/lua/rakshit/core/options.lua index ab8145b2..07bf2d13 100644 --- a/lua/rakshit/core/options.lua +++ b/lua/rakshit/core/options.lua @@ -69,3 +69,19 @@ vim.opt.backspace = "indent,eol,start" -- Enable break indent vim.opt.breakindent = true + +-- Function to rename the current tmux window based on the directory name +local function rename_tmux_window() + if vim.env.TMUX then + local cwd = vim.loop.cwd() -- Get the current working directory + local dirname = vim.fn.fnamemodify(cwd, ":t") -- Extract the last part of the directory path + os.execute("tmux rename-window " .. dirname) + end +end + +-- Automatically rename tmux window when starting Neovim +vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + rename_tmux_window() + end, +})