Skip to content

Instantly share code, notes, and snippets.

@fukayatsu
Last active November 7, 2015 09:53
Show Gist options
  • Save fukayatsu/c3b74f2864e7e950ff76 to your computer and use it in GitHub Desktop.
Save fukayatsu/c3b74f2864e7e950ff76 to your computer and use it in GitHub Desktop.
atomのterminal-plusでfocusをいい感じにtoggleするやつ
focusMain = (e) ->
atom.workspace.getActivePane().activate()
for panel in atom.workspace.getBottomPanels()
if panel.item[0]?.className == 'terminal-plus terminal-view'
panel.item.terminal?.blur()
focusTerminal = (e) ->
terminalFound = false
for panel in atom.workspace.getBottomPanels()
if panel.item[0]?.className == 'terminal-plus terminal-view'
terminalFound = true
if panel.isVisible()
panel.item.focusTerminal()
else
panel.item.toggle()
unless terminalFound
for panel in atom.workspace.getBottomPanels()
if panel.item[0]?.className == 'terminal-plus status-bar'
panel.item.toggle()
atom.commands.add 'atom-workspace',
'editor:focus-main': focusMain
'editor:focus-terminal': focusTerminal
'editor:toggle-focus-terminal': ->
if document.activeElement.className == 'terminal'
focusMain()
else
focusTerminal()
'.workspace':
'cmd-;': 'editor:toggle-focus-terminal'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment