Skip to content

Instantly share code, notes, and snippets.

@dhbradshaw
Last active September 24, 2021 08:06
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhbradshaw/fcd67df6564eae64a0a5 to your computer and use it in GitHub Desktop.
Save dhbradshaw/fcd67df6564eae64a0a5 to your computer and use it in GitHub Desktop.
Customize tab titles in atom text editor.
# 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()
@zenstate-old
Copy link

Very useful if you use the ${componentName}/index.js pattern for organising your react projects.

@tribou
Copy link

tribou commented Sep 17, 2017

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

@sebilasse
Copy link

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