colab-xterm icon indicating copy to clipboard operation
colab-xterm copied to clipboard

feat: add user-configurable font family, font size, and initial command for xterm sessions (#13)

Open Akash-nath29 opened this issue 8 months ago • 0 comments

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 %xterm magic in notebook.py to accept fontfamily, fontsize, and command as 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.
  • Frontend:

    • index.ts now reads fontfamily and fontsize from 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.

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

Akash-nath29 avatar Jun 03 '25 20:06 Akash-nath29