Skip to content

Instantly share code, notes, and snippets.

@ChiChou
Last active April 18, 2025 21:40
Show Gist options
  • Save ChiChou/1c8df7334c0279e3c83810afb74ec0c1 to your computer and use it in GitHub Desktop.
Save ChiChou/1c8df7334c0279e3c83810afb74ec0c1 to your computer and use it in GitHub Desktop.
macOS cli shortcut to open file in IDA
  1. install swift
  2. install ida.swift to $PATH/ida
#!/usr/bin/env swift
import AppKit
import Foundation
guard CommandLine.arguments.count > 1 else {
fputs("Usage: \(CommandLine.arguments[0]) <file1> <file2> ...\n", stderr)
exit(1)
}
let workspace = NSWorkspace.shared
guard let appUrl = workspace.urlForApplication(withBundleIdentifier: "com.hexrays.ida64") else {
fputs("Error: IDA Pro is not installed.\n", stderr)
exit(1)
}
var urls: [URL] = []
for i in 1..<CommandLine.arguments.count {
let filePath = CommandLine.arguments[i]
if FileManager.default.fileExists(atPath: filePath) == false {
fputs("Error: File does not exist: \(filePath)\n", stderr)
exit(1)
}
urls.append(URL(fileURLWithPath: filePath))
}
let conf = NSWorkspace.OpenConfiguration()
let semaphore = DispatchSemaphore(value: 0)
workspace.open(urls, withApplicationAt: appUrl, configuration: conf) { (app, error) in
if let error = error {
fputs("Error: \(error.localizedDescription)\n", stderr)
exit(1)
}
semaphore.signal()
}
semaphore.wait()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment