         item = pane.addItem termView
         pane.activateItem item
         @focusedTerminal = [pane, item]
+        @disposables.add @attachSubscriptions(termView, item, pane)
       else
         splitter()
     else

  onTerm: (callback) ->
    @emitter.on 'term', callback

  newTerm: (forkPTY=true, rows=30, cols=80, title='tty') ->
    termView = @createTermView forkPTY, rows, cols
    pane = atom.workspace.getActivePane()
    model = Terminals.add {
      local: !!forkPTY,
      term: termView,
      title: title,
    }


    subscriptions = new CompositeDisposable

    subscriptions.add pane.onDidChangeActiveItem ->
      activeItem = pane.getActiveItem()
      if activeItem != termView
        if termView.term
          termView.term.constructor._textarea = null

    opts.cwd = opts.cwd or atom.project.getPaths()[0] or editorPath or process.env.HOME

    termView = new TermView opts
    model = Terminals.add {
      local: !!forkPTY,
      term: termView,
      title: title,
    }
    id = model.id
    termView.id = id

    termView.on 'remove', @handleRemoveTerm.bind this
    termView.on 'click', =>
      # get focus in the terminal
      # avoid double click to get focus
      termView.term.element.focus()
      termView.term.focus()

      @focusedTerminal = termView

    termView.onDidChangeTitle () ->
      if forkPTY
        model.title = termView.getTitle()
      else
        model.title = title + '-' + termView.getTitle()

    @termViews.push? termView
    process.nextTick () => @emitter.emit 'term', termView
    termView

  splitTerm: (direction) ->
    openPanesInSameSplit = atom.config.get 'term3.openPanesInSameSplit'
    termView = @createTermView()
    direction = capitalize direction

    splitter = =>
      pane = activePane["split#{direction}"] items: [termView]
      activePane.termSplits[direction] = pane
      @focusedTerminal = [pane, pane.items[0]]
      @disposables.add @attachSubscriptions(termView, @focusedTerminal, pane)

    activePane = atom.workspace.getActivePane()
    activePane.termSplits or= {}
