colab-xterm
colab-xterm copied to clipboard
feat: add user-configurable font family, font size, and initial command for xterm sessions (#13)
This pull request implements and documents the feature request in #13, allowing users to customize the font family, font size, and initial shell command for colab-xterm sessions.
Key changes:
-
Backend (notebook magic):
- Updated
%xtermmagic innotebook.pyto acceptfontfamily,fontsize, andcommandas arguments (e.g.%xterm port=8080 fontfamily="consolas" fontsize=18 command="top"). - These arguments are parsed and passed to the frontend as query parameters.
- The backend launches the requested initial shell command if provided.
- Updated
-
Frontend:
-
index.tsnow readsfontfamilyandfontsizefrom the URL query parameters and uses those settings when constructing the xterm.js terminal. - Defaults remain (
fontfamily=monospace,fontsize=14) if parameters are not provided.
-
-
CLI/Local Usage:
- While CLI arguments for font are not supported, users can now manually append
?fontFamily=...&fontSize=...to the local URL to preview different terminal styles.
- While CLI arguments for font are not supported, users can now manually append
Usage examples:
- In a notebook cell:
%xterm port=8080 fontfamily="courier" fontsize=16 command="htop" - In a browser:
http://localhost:8080/?fontfamily=Fira%20Mono&fontsize=16
Other improvements:
- Fixed subprocess launching to use the correct Python executable with
sys.executable, which improves compatibility across environments. - Updated documentation and comments for maintainability.
Closes: #13