Rename current tmux window based on directory name

This commit is contained in:
Rakshit Sinha 2024-11-27 23:31:00 -08:00
parent 64bf4f0db8
commit fff89d6034
1 changed files with 16 additions and 0 deletions

View File

@ -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,
})