Skip to content

Instantly share code, notes, and snippets.

@iliojunior
Forked from tribou/init.coffee
Last active July 11, 2019 13:58
Show Gist options
  • Save iliojunior/455434a87b6bc08bc4049292f1b2cab0 to your computer and use it in GitHub Desktop.
Save iliojunior/455434a87b6bc08bc4049292f1b2cab0 to your computer and use it in GitHub Desktop.
Customize Atom tab titles to display folder and file name
# Just create 'init.coffee' in your .atom directory
# Add folder and filename to tab title
# Suggested when using many 'index.js'
# When the file name is 'index.js' it uses the last two paths
# EX: src/components/pages/Domain/SubDomain/index.js -> Domain/SubDomain
atom.workspace.observeTextEditors (editor) ->
if editor.getTitle() isnt "untitled"
pathNames = editor.getPath().split('/')
length = pathNames.length
title = pathNames[length - 1]
if pathNames[length - 1] == 'index.js'
title = pathNames[length - 3...length - 1].join '/'
editor.getTitle = -> title
editor.getLongTitle = -> title
editor.emitter.emit "did-change-title", editor.getTitle()
atom.workspace.onDidOpen (event) ->
for item in event.pane.items
if item.emitter?
item.emitter.emit "did-change-title", item.getTitle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment