Last active
September 24, 2021 08:06
-
-
Save dhbradshaw/fcd67df6564eae64a0a5 to your computer and use it in GitHub Desktop.
Customize tab titles in atom text editor.
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
# place this snippet into init.coffee in ~/.atom directory | |
atom.workspace.observeTextEditors (editor) -> | |
if editor.getTitle() isnt "untitled" | |
sp = editor.getPath().split('/') | |
title = sp.slice(sp.length-2).join('/') | |
editor.getTitle = -> title | |
editor.getLongTitle = -> title | |
for item in atom.workspace.getPaneItems() | |
if item.emitter? | |
item.emitter.emit "did-change-title", item.getTitle() |
For some reason, Atom wasn't refreshing the title consistently on the OneDark UI theme. If anyone else experienced this, I found a different event hook to use with this slightly altered script here:
https://gist.github.com/tribou/53b508b65b390183e4b23678e5b0816f
Please note if anyone needs it just because of multiple 'index.…' tabs, a CSS solution is possible too
[in Atom -> Stylesheet add:]
.tab-bar .tab .title[data-name^="index"] {
letter-spacing: -1px;
direction: rtl;
text-align: left;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very useful if you use the ${componentName}/index.js pattern for organising your react projects.