Skip to content

Commit

Permalink
fix(main): build pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji4n1ng committed Apr 21, 2019
1 parent 4d283ae commit 659f844
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
1 change: 0 additions & 1 deletion OpenInTerminal/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
TerminalManager.shared.openTerminal()
return true
}
}
Expand Down
33 changes: 27 additions & 6 deletions OpenInTerminalCore/Terminals/TerminalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,39 @@ public class TerminalManager {
return option.map(NewOptionType.init(rawValue: )) ?? nil
}

public func getVisble(_ terminal: TerminalType) -> VisibleType? {
var visble: String?
public func getVisible(_ terminal: TerminalType) -> VisibleType? {
var visible: String?
switch terminal {
case .terminal:
visble = Defaults[.terminalVisible]
visible = Defaults[.terminalVisible]
case .iTerm:
visble = Defaults[.iTermVisible]
visible = Defaults[.iTermVisible]
case .hyper:
visble = Defaults[.hyperVisible]
visible = Defaults[.hyperVisible]
}

return visble.map(VisibleType.init(rawValue: )) ?? nil
return visible.map(VisibleType.init(rawValue: )) ?? nil
}

public func openTerminal(_ terminalType: TerminalType) {
do {
var path = try FinderManager.shared.getPathToFrontFinderWindowOrSelectedFile()
if path == "" {
// No Finder windows are opened or selected, so open home directory
path = NSHomeDirectory()
}

let terminal = terminalType.instance()

if let newOption = TerminalManager.shared.getNewOption(terminalType) {
try terminal.open(path, newOption)
} else {
try terminal.open(path, .window)
}

} catch {
log(error, .error)
}
}

// MARK: private methods
Expand Down

0 comments on commit 659f844

Please sign in to comment.