Created
February 22, 2025 15:32
-
-
Save pachun/03bce79151e9a0c99976ca77ed2288d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Rename tmux window when nvim opens | |
if vim.fn.exists("$TMUX") == 1 then | |
local function rename_tmux_tab() | |
local cwd = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") | |
vim.fn.system('tmux rename-window "' .. cwd .. '"') | |
end | |
local function reset_tmux_tab() | |
vim.fn.system("tmux set-window-option automatic-rename on") | |
end | |
rename_tmux_tab() | |
vim.api.nvim_create_autocmd("DirChanged", { callback = rename_tmux_tab }) | |
vim.api.nvim_create_autocmd("VimLeavePre", { callback = reset_tmux_tab }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment