You can install ipython-icat
using pip:
pip install ipython-icat
- Python 3.9+
- IPython
- matplotlib
- Pillow (PIL)
- terminal emulator with support for kitty graphics protocol (KGP) e.g., kitty, ghostty
In your IPython session, load the extension:
%load_ext icat
To use the kitty backend for matplotlib:
%plt_icat
After running this command, any matplotlib plots you create will be displayed directly in your kitty terminal.
To set the kitty backend for matplotlib as the default, add the following lines to your IPython configuration file:
c.InteractiveShellApp.extensions = ['icat']
c.InteractiveShellApp.exec_lines = ['%plt_icat']
You can quickly set up IPython to use the icat extension using the setup command:
python -m icat setup
This command will:
- Create an IPython profile if it doesn't exist (or use an existing one)
- Configure the profile to load the icat extension automatically
- Set matplotlib to use the icat backend by default
Additional options:
--profile NAME
- Use a specific profile instead of the default--ipython-path PATH
- Specify a custom path to the .ipython directory
Example with custom profile:
python -m icat setup --profile myprofile
To display an image file or a PIL Image object:
%icat path/to/your/image.jpg
or
from PIL import Image
img = Image.open('path/to/your/image.jpg')
%icat img
You can also resize the image when displaying:
%icat path/to/your/image.jpg -w 300 -h 200
If you'd like to use this plugin with Ghostty, make sure to install the static kitten binary which will allow you to run kitten icat
.
- Display matplotlib plots directly in kitty terminal
- Show PIL Image objects or image files
- Resize images on display
- Seamless integration with IPython workflow
Contributions are welcome! Please feel free to submit a Pull Request.
- matplotlib-backend-kitty for the original implementation
- matplotlib and Pillow for their excellent libraries
- kitty terminal for developing the graphics protocol
This project is licensed under the MIT License - see the LICENSE file for details.