Live Preview
-
- {/* Fake title bar */}
-
-
-
- user@server — bash
-
-
-
- {/* Terminal content */}
-
-
-
- user@server
- :
- ~
- $
- neofetch
-
-
- {' _,met$$$$$gg. '}
-
-
- {' ,g$$$$$$$$$$$$$$$P. '}
- user
- @
- server
-
-
- {' ,g$$P" """Y$$.". '}
- -----------
-
-
- {' ,$$P\' `$$$. '}
- OS
- : Ubuntu 22.04 LTS
-
-
- {'\',$$P ,ggs. `$$b: '}
- Kernel
- : 5.15.0-generic
-
-
- {'`d$$\' ,$P"\' . $$$ '}
- Uptime
- : 42 days, 3 hours
-
-
- {' $$P d$\' , $$P '}
- Shell
- : bash 5.1.16
-
-
- {' $$: $$. - ,d$$\' '}
- Memory
- : 4.2G / 16G (26%)
-
-
-
- user@server
- :
- ~
- $
- ls -la
-
-
- drwxr-xr-x
- 5 user group
- 4.0K
- Dec 12 10:30
- .config
-
-
- -rwxr-xr-x
- 1 user group
- 2.1K
- Dec 11 15:22
- deploy.sh
-
-
- lrwxrwxrwx
- 1 user group
- 24
- Dec 10 09:15
- logs
- -{'>'}
- /var/log/app
-
-
-
- user@server
- :
- ~
- $
- ▋
-
-
-
-
+
{/* Info line */}
diff --git a/components/terminal/index.ts b/components/terminal/index.ts
index 7b8112f6f..2dba93dee 100644
--- a/components/terminal/index.ts
+++ b/components/terminal/index.ts
@@ -17,3 +17,5 @@ export type { ChainProgress,TerminalConnectionDialogProps } from './TerminalConn
export { TerminalContextMenu } from './TerminalContextMenu';
export type { TerminalContextMenuProps } from './TerminalContextMenu';
+
+export { createHighlightProcessor, highlightKeywords, compileHighlightRules } from './keywordHighlight';
diff --git a/components/terminal/keywordHighlight.ts b/components/terminal/keywordHighlight.ts
new file mode 100644
index 000000000..d0a2c90eb
--- /dev/null
+++ b/components/terminal/keywordHighlight.ts
@@ -0,0 +1,136 @@
+import { KeywordHighlightRule } from "../../types";
+
+// ESC character as unicode escape for ESLint compatibility
+const ESC = "\u001b";
+
+/**
+ * Convert a hex color to ANSI 24-bit true color escape sequence
+ * Format: ESC[38;2;R;G;Bm for foreground color
+ */
+function hexToAnsi(hex: string): string {
+ // Remove # if present
+ const cleanHex = hex.replace("#", "");
+ const r = parseInt(cleanHex.slice(0, 2), 16);
+ const g = parseInt(cleanHex.slice(2, 4), 16);
+ const b = parseInt(cleanHex.slice(4, 6), 16);
+ return `${ESC}[38;2;${r};${g};${b}m`;
+}
+
+const ANSI_RESET = `${ESC}[0m`;
+
+// Regex to match ANSI escape sequences (to skip them during highlighting)
+// Using RegExp constructor to avoid ESLint control character warning
+// eslint-disable-next-line no-control-regex
+const ANSI_ESCAPE_REGEX = /\u001b\[[0-9;]*[a-zA-Z]/g;
+
+interface CompiledRule {
+ regex: RegExp;
+ ansiColor: string;
+}
+
+/**
+ * Pre-compile keyword highlight rules for better performance
+ */
+export function compileHighlightRules(
+ rules: KeywordHighlightRule[],
+ enabled: boolean
+): CompiledRule[] {
+ if (!enabled) return [];
+
+ return rules
+ .filter((rule) => rule.enabled && rule.patterns.length > 0)
+ .map((rule) => {
+ // Combine all patterns with OR, case-insensitive
+ const combinedPattern = rule.patterns.join("|");
+ return {
+ regex: new RegExp(`(${combinedPattern})`, "gi"),
+ ansiColor: hexToAnsi(rule.color),
+ };
+ });
+}
+
+/**
+ * Apply keyword highlighting to terminal output
+ * This processes text and adds ANSI color codes for matched keywords
+ *
+ * Note: This is a simplified approach that works well for most cases.
+ * It processes the text while preserving existing ANSI escape sequences.
+ */
+export function highlightKeywords(
+ text: string,
+ compiledRules: CompiledRule[]
+): string {
+ if (compiledRules.length === 0 || !text) {
+ return text;
+ }
+
+ // Split text into segments: ANSI sequences and regular text
+ const segments: Array<{ isAnsi: boolean; content: string }> = [];
+ let lastIndex = 0;
+
+ // Find all ANSI escape sequences
+ let match: RegExpExecArray | null;
+ const ansiRegex = new RegExp(ANSI_ESCAPE_REGEX.source, "g");
+
+ while ((match = ansiRegex.exec(text)) !== null) {
+ // Add text before this ANSI sequence
+ if (match.index > lastIndex) {
+ segments.push({
+ isAnsi: false,
+ content: text.slice(lastIndex, match.index),
+ });
+ }
+ // Add the ANSI sequence itself
+ segments.push({
+ isAnsi: true,
+ content: match[0],
+ });
+ lastIndex = match.index + match[0].length;
+ }
+
+ // Add remaining text after last ANSI sequence
+ if (lastIndex < text.length) {
+ segments.push({
+ isAnsi: false,
+ content: text.slice(lastIndex),
+ });
+ }
+
+ // Process only non-ANSI segments
+ const processedSegments = segments.map((segment) => {
+ if (segment.isAnsi) {
+ return segment.content;
+ }
+
+ let processed = segment.content;
+
+ // Apply each rule
+ for (const rule of compiledRules) {
+ processed = processed.replace(rule.regex, (matched) => {
+ return `${rule.ansiColor}${matched}${ANSI_RESET}`;
+ });
+ }
+
+ return processed;
+ });
+
+ return processedSegments.join("");
+}
+
+/**
+ * Create a highlight processor function with pre-compiled rules
+ * Use this for better performance when processing multiple chunks
+ */
+export function createHighlightProcessor(
+ rules: KeywordHighlightRule[],
+ enabled: boolean
+): (text: string) => string {
+ const compiledRules = compileHighlightRules(rules, enabled);
+
+ if (compiledRules.length === 0) {
+ // Return identity function if no rules are enabled
+ return (text: string) => text;
+ }
+
+ return (text: string) => highlightKeywords(text, compiledRules);
+}
diff --git a/domain/models.ts b/domain/models.ts
index 7a8cc7105..761cbc740 100755
--- a/domain/models.ts
+++ b/domain/models.ts
@@ -311,11 +311,22 @@ export const DEFAULT_KEY_BINDINGS: KeyBinding[] = [
export type CursorShape = 'block' | 'bar' | 'underline';
export type RightClickBehavior = 'context-menu' | 'paste' | 'select-word';
export type LinkModifier = 'none' | 'ctrl' | 'alt' | 'meta';
+export type TerminalEmulationType = 'xterm-256color' | 'xterm-16color' | 'xterm';
+
+// Keyword highlighting configuration
+export interface KeywordHighlightRule {
+ id: string;
+ label: string; // Display name (e.g., "Error", "Warning", "OK")
+ patterns: string[]; // Regex patterns to match
+ color: string; // Highlight color (hex)
+ enabled: boolean;
+}
export interface TerminalSettings {
// Rendering
scrollback: number; // Number of lines kept in buffer
drawBoldInBrightColors: boolean; // Draw bold text in bright colors
+ terminalEmulationType: TerminalEmulationType; // Terminal emulation type (TERM env var)
// Font
fontLigatures: boolean; // Enable font ligatures
@@ -341,11 +352,25 @@ export interface TerminalSettings {
middleClickPaste: boolean; // Paste on middle-click
wordSeparators: string; // Characters for word selection
linkModifier: LinkModifier; // Modifier key to click links
+
+ // Keyword Highlighting
+ keywordHighlightEnabled: boolean;
+ keywordHighlightRules: KeywordHighlightRule[];
}
+export const DEFAULT_KEYWORD_HIGHLIGHT_RULES: KeywordHighlightRule[] = [
+ { id: 'error', label: 'Error', patterns: ['\\[error\\]', '\\[err\\]', '\\berror\\b', '\\bfail(ed)?\\b', '\\bfatal\\b', '\\bcritical\\b', '\\bexception\\b'], color: '#F87171', enabled: true },
+ { id: 'warning', label: 'Warning', patterns: ['\\[warn(ing)?\\]', '\\bwarn(ing)?\\b', '\\bcaution\\b', '\\bdeprecated\\b'], color: '#FBBF24', enabled: true },
+ { id: 'ok', label: 'OK', patterns: ['\\[ok\\]', '\\bok\\b', '\\bsuccess(ful)?\\b', '\\bpassed\\b', '\\bcompleted\\b', '\\bdone\\b'], color: '#34D399', enabled: true },
+ { id: 'info', label: 'Info', patterns: ['\\[info\\]', '\\[notice\\]', '\\[note\\]', '\\bnotice\\b', '\\bnote\\b'], color: '#3B82F6', enabled: true },
+ { id: 'debug', label: 'Debug', patterns: ['\\[debug\\]', '\\[trace\\]', '\\[verbose\\]', '\\bdebug\\b', '\\btrace\\b', '\\bverbose\\b'], color: '#A78BFA', enabled: true },
+ { id: 'ip-mac', label: 'IP address & MAC', patterns: ['\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b', '\\b([0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\\b'], color: '#EC4899', enabled: true },
+];
+
export const DEFAULT_TERMINAL_SETTINGS: TerminalSettings = {
scrollback: 10000,
drawBoldInBrightColors: true,
+ terminalEmulationType: 'xterm-256color',
fontLigatures: true,
fontWeight: 400,
fontWeightBold: 700,
@@ -361,6 +386,8 @@ export const DEFAULT_TERMINAL_SETTINGS: TerminalSettings = {
middleClickPaste: true,
wordSeparators: ' ()[]{}\'"',
linkModifier: 'none',
+ keywordHighlightEnabled: true,
+ keywordHighlightRules: DEFAULT_KEYWORD_HIGHLIGHT_RULES,
};
export interface TerminalTheme {
diff --git a/electron/main.cjs b/electron/main.cjs
index 8b8bef911..2a08b57a7 100644
--- a/electron/main.cjs
+++ b/electron/main.cjs
@@ -173,6 +173,14 @@ const registerBridges = (win) => {
return true;
});
+ // Open external URL in default browser
+ ipcMain.handle("netcatty:openExternal", async (_event, url) => {
+ const { shell } = electronModule;
+ if (url && typeof url === 'string' && (url.startsWith('http://') || url.startsWith('https://'))) {
+ await shell.openExternal(url);
+ }
+ });
+
console.log('[Main] All bridges registered successfully');
};
diff --git a/electron/preload.cjs b/electron/preload.cjs
index dde48109a..7eeb3aa2e 100644
--- a/electron/preload.cjs
+++ b/electron/preload.cjs
@@ -325,6 +325,9 @@ const api = {
openSettingsWindow: () => ipcRenderer.invoke("netcatty:settings:open"),
closeSettingsWindow: () => ipcRenderer.invoke("netcatty:settings:close"),
+ // Open URL in default browser
+ openExternal: (url) => ipcRenderer.invoke("netcatty:openExternal", url),
+
// Port Forwarding API
startPortForward: async (options) => {
return ipcRenderer.invoke("netcatty:portforward:start", options);
diff --git a/global.d.ts b/global.d.ts
index b69bb6e98..d82542e7f 100644
--- a/global.d.ts
+++ b/global.d.ts
@@ -230,6 +230,9 @@ interface NetcattyBridge {
// Known Hosts
readKnownHosts?(): Promise;
+ // Open URL in default browser
+ openExternal?(url: string): Promise;
+
// Chain progress listener for jump host connections
// Callback receives: (currentHop: number, totalHops: number, hostLabel: string, status: string)
onChainProgress?(cb: (hop: number, total: number, label: string, status: string) => void): () => void;
diff --git a/package-lock.json b/package-lock.json
index d7d400921..5f13b0f63 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -20,6 +20,7 @@
"@radix-ui/react-tabs": "1.1.13",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-serialize": "^0.13.0",
+ "@xterm/addon-web-links": "^0.11.0",
"@xterm/addon-webgl": "^0.18.0",
"@xterm/xterm": "^5.5.0",
"clsx": "2.1.1",
@@ -3298,6 +3299,15 @@
"@xterm/xterm": "^5.0.0"
}
},
+ "node_modules/@xterm/addon-web-links": {
+ "version": "0.11.0",
+ "resolved": "https://registry.npmmirror.com/@xterm/addon-web-links/-/addon-web-links-0.11.0.tgz",
+ "integrity": "sha512-nIHQ38pQI+a5kXnRaTgwqSHnX7KE6+4SVoceompgHL26unAxdfP6IPqUTSYPQgSwM56hsElfoNrrW5V7BUED/Q==",
+ "license": "MIT",
+ "peerDependencies": {
+ "@xterm/xterm": "^5.0.0"
+ }
+ },
"node_modules/@xterm/addon-webgl": {
"version": "0.18.0",
"resolved": "https://registry.npmmirror.com/@xterm/addon-webgl/-/addon-webgl-0.18.0.tgz",
diff --git a/package.json b/package.json
index 49b0193f9..54fa214e5 100755
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"@radix-ui/react-tabs": "1.1.13",
"@xterm/addon-fit": "^0.10.0",
"@xterm/addon-serialize": "^0.13.0",
+ "@xterm/addon-web-links": "^0.11.0",
"@xterm/addon-webgl": "^0.18.0",
"@xterm/xterm": "^5.5.0",
"clsx": "2.1.1",
@@ -59,4 +60,4 @@
"vite": "^7.2.7",
"wait-on": "^9.0.3"
}
-}
\ No newline at end of file
+}