shellInfo top-level property

String? get shellInfo

Implementation

String? get shellInfo {
  if (Dart.isAndroid) {
    return "terminal";
  }
  String? shellPath = Platform.environment["SHELL"];
  if (shellPath == null) return null;
  final String shell = shellPath.split("/").last.trim();
  String version = "";
  switch (shell) {
    case "zsh":
      version = (Process.runSync(shellPath, ["--version"])).stdout.toString().split(" ")[1].trim();
      break;
    default:
      try {
        version = (Process.runSync(shellPath, ["--version"])).stdout.toString().split(" ")[1].trim();
      } catch (e) {}
      break;
  }
  return "${shell} ${version}".trim();
}