terminal – How to automatically change iTerms tab title to that of currently open file?


My goal is that when I open a file in the Terminal (regardless of editor, FWIW I use Micro) to automatically show the filename in the tab title and when I exit/quit the editor revert the tab title back to what is was. How do I acheieve this?

Note: I am aware this easy enough with Neovim but thats not what I use, I almost exclusively use Micro editor and rarely Nano.