Skip to content

Instantly share code, notes, and snippets.

@ykpythemind
Last active March 14, 2018 06:38
Show Gist options
  • Save ykpythemind/9f9ac4e42c0bfe38c2d8f726c02ef72f to your computer and use it in GitHub Desktop.
Save ykpythemind/9f9ac4e42c0bfe38c2d8f726c02ef72f to your computer and use it in GitHub Desktop.
'use babel';
// for Rails haml view file
const setTabTitle = () => {
const tabs = atom.views.getView(atom.workspace).querySelectorAll('.vertical li.tab .title');
Array.from(tabs, (tab) => {
if (tab.innerText.match(/\.(haml|erb)/)) {
tab.innerText = tab.dataset.path.split(path.sep).slice(-2).join('/').replace(/\.html\.(haml|erb)/, '');
}
});
};
atom.workspace.onDidChangeActiveTextEditor(() => {
setTabTitle();
});
atom.workspace.onDidOpen(() => {
setTabTitle();
});
atom.workspace.onDidDestroyPaneItem(() => {
setTabTitle();
});
// ---
atom.commands.add('atom-text-editor', 'pry:toggle-binding-pry', () => {
const editor = atom.workspace.getActiveTextEditor();
if (!editor) {
return;
}
const row = editor.getCursorBufferPosition().row;
const line = editor.lineTextForBufferRow(row);
if (line.includes('binding.pry')) {
const buffer = editor.getBuffer();
const range = buffer.rangeForRow(row, false);
editor.setTextInBufferRange(range, '');
} else {
editor.insertText('binding.pry');
}
});
atom.keymaps.add('frominit', {
"body": {
"alt-p": "pry:toggle-binding-pry"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment