If you’re like me, you usually have ten different terminal tabs open: one for the server, one for Neovim, a folder, one for the database, and maybe a few others for "vibe coding" sessions.
The problem? Terminator (and most emulators) defaults to showing the process name like zsh or nvim. It's a nightmare to find the right project!
Here is how I configured my Linux setup to automatically show the Folder Name in the tab whenever I run nvim . or move between projects.
The Goal
When I’m in /home/user/projects/project_name and I hit nvim ., I want my tab to say project_name, not nvim.
Step 1: Force Neovim to Talk to Your Terminal
Neovim is powerful enough to send "escape sequences" to your terminal emulator. We want it to set the titlestring to our current folder name on startup.
Open your Neovim config (e.g., init.lua or your custom config) and add this:
-- 1. Enable title support
vim.opt.title = true
-- 2. Create a function to grab the folder name and set the title
vim.api.nvim_create_autocmd({"VimEnter", "DirChanged"}, {
callback = function()
-- This gets the "tail" of the current working directory (the folder name)
local folder_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t")
vim.opt.titlestring = folder_name
end,
})
-- 3. Reset the title when you quit Neovim
vim.api.nvim_create_autocmd("VimLeave", {
callback = function()
vim.opt.titlestring = ""
end,
})
Step 2: Fix Your Shell (Zsh)
What if you aren't in Neovim? You still want your tabs to be labeled correctly. Add this "hook" to your ~/.zshrc:
# Auto-rename tab to current folder name
function chpwd() {
# This escape sequence \e]2; sets the window/tab title
# ${PWD##*/} is a Zsh shortcut to get just the current folder name
print -Pn "\e]2;${PWD##*/}\a"
}
# Set the title immediately when you open a new terminal
print -Pn "\e]2;${PWD##*/}\a"
Reload with source ~/.zshrc and you're good to go!
Step 3: Check Your Terminator Preferences
If it’s still not working, Terminator might be overriding your titles.
- Right-click in Terminator > Preferences.
- Go to Profiles > General.
- Ensure "Show terminal title" is checked.
- Set "Title Bar" to "Initial Title" or ensure it isn't set to a static string like "Terminal."
Top comments (0)