52 lines
1.9 KiB
Dart
52 lines
1.9 KiB
Dart
import 'dart:io';
|
|
|
|
import '../command.dart';
|
|
|
|
const _nativeCsiuTerminals = <String>[
|
|
'ghostty', 'kitty', 'iTerm.app', 'WezTerm', 'WarpTerminal',
|
|
];
|
|
|
|
Future<CommandResult> run(CommandContext context, List<String> args) async {
|
|
final term = Platform.environment['TERM_PROGRAM']
|
|
?? Platform.environment['TERMINAL_EMULATOR']
|
|
?? '';
|
|
|
|
if (_nativeCsiuTerminals.contains(term)) {
|
|
context.writeLine(
|
|
'Terminal-setup: your terminal ($term) natively supports the Kitty keyboard protocol.',
|
|
);
|
|
context.writeLine('No additional setup is needed for Shift+Enter / newlines.');
|
|
return const CommandResult();
|
|
}
|
|
|
|
context.writeLine('Terminal setup');
|
|
context.writeLine('');
|
|
|
|
if (Platform.isMacOS && term == 'Apple_Terminal') {
|
|
context.writeLine('Detected: Apple Terminal (macOS)');
|
|
context.writeLine('');
|
|
context.writeLine(
|
|
'To enable Option+Enter for newlines:\n'
|
|
' 1. Open Terminal > Settings > Profiles > Keyboard\n'
|
|
' 2. Add a key binding: Option+Return → sends \\033\\012\n'
|
|
' 3. Alternatively run the legacy CLI interactively: /terminal-setup',
|
|
);
|
|
} else if (term == 'vscode' || term == 'cursor' || term == 'windsurf') {
|
|
context.writeLine('Detected: $term terminal');
|
|
context.writeLine('');
|
|
context.writeLine(
|
|
'To enable Shift+Enter for newlines, add this to your $term keybindings.json:\n'
|
|
' { "key": "shift+enter", "command": "workbench.action.terminal.sendSequence",\n'
|
|
' "args": { "text": "\\\\n" }, "when": "terminalFocus" }',
|
|
);
|
|
} else {
|
|
context.writeLine('Detected terminal: ${term.isEmpty ? '(unknown)' : term}');
|
|
context.writeLine('');
|
|
context.writeLine(
|
|
'Interactive terminal setup (key binding installation) is not ported to the Dart runtime.',
|
|
);
|
|
context.writeLine('Run the legacy CLI to use the full interactive setup wizard.');
|
|
}
|
|
|
|
return const CommandResult();
|
|
}
|