enableOptionAsMetaForProfile function
Enable Option as Meta key for a Terminal.app profile.
Uses PlistBuddy to modify the profile's useOptionAsMetaKey setting.
Implementation
Future<bool> enableOptionAsMetaForProfile(String profileName) async {
// First try to add the property (in case it doesn't exist).
var result = await Process.run('/usr/libexec/PlistBuddy', [
'-c',
"Add :'Window Settings':'$profileName':useOptionAsMetaKey bool true",
getTerminalPlistPath(),
]);
// If adding fails (likely because it already exists), try setting it.
if (result.exitCode != 0) {
result = await Process.run('/usr/libexec/PlistBuddy', [
'-c',
"Set :'Window Settings':'$profileName':useOptionAsMetaKey true",
getTerminalPlistPath(),
]);
if (result.exitCode != 0) return false;
}
return true;
}