Skip to content

Commit fff89d6

Browse files
author
Rakshit Sinha
committed
Rename current tmux window based on directory name
1 parent 64bf4f0 commit fff89d6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lua/rakshit/core/options.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,19 @@ vim.opt.backspace = "indent,eol,start"
6969

7070
-- Enable break indent
7171
vim.opt.breakindent = true
72+
73+
-- Function to rename the current tmux window based on the directory name
74+
local function rename_tmux_window()
75+
if vim.env.TMUX then
76+
local cwd = vim.loop.cwd() -- Get the current working directory
77+
local dirname = vim.fn.fnamemodify(cwd, ":t") -- Extract the last part of the directory path
78+
os.execute("tmux rename-window " .. dirname)
79+
end
80+
end
81+
82+
-- Automatically rename tmux window when starting Neovim
83+
vim.api.nvim_create_autocmd("VimEnter", {
84+
callback = function()
85+
rename_tmux_window()
86+
end,
87+
})

0 commit comments

Comments
 (0)