detectJetBrainsIDEFromParentProcessAsync function
Implementation
Future<String?> detectJetBrainsIDEFromParentProcessAsync() async {
if (_jetBrainsDetected) return _jetBrainsIDECache;
if (Platform.isMacOS) {
_jetBrainsDetected = true;
return null;
}
try {
final result = await Process.run('ps', ['-o', 'command=', '-p', '$pid']);
final commands = (result.stdout as String).split('\n');
for (final command in commands) {
final lower = command.toLowerCase();
for (final ide in jetbrainsIdes) {
if (lower.contains(ide)) {
_jetBrainsIDECache = ide;
_jetBrainsDetected = true;
return ide;
}
}
}
} catch (_) {}
_jetBrainsDetected = true;
return null;
}