configHosts top-level property

FigGenerator configHosts
final

Implementation

final FigGenerator configHosts = FigGenerator(
  script: ['sh', '-c', 'cat ~/.ssh/config'],
  postProcess: (String out, [List<String>? tokens]) {
    return out
        .split('\n')
        .where((line) {
          final trimmedLine = line.trim().toLowerCase();
          return trimmedLine.startsWith('host ') && !line.contains('*');
        })
        .map((line) {
          final parts = line.trim().split(RegExp(r'\s+'));
          return parts.length > 1 ? parts[1] : null;
        })
        .where((name) => name != null)
        .map((name) => FigSuggestion(
              name: name!,
              description: 'SSH host',
              priority: 90,
            ))
        .toList();
  },
);