This is a Bash script designed to be bound to a keyboard shortcut. It takes the currently highlighted selection from the xwindows clipboard, sends it to chatgpt-cli as context, and display the response in a new XFCE4 terminal window. This way you can conveniently start at a chat about any text that you are working on, across all applications.
To use this script, you will need to have the following installed on your system:
xclip
: A command line utility to interact with the clipboard in X11.xfce4-terminal
: The XFCE terminal emulator.chatgpt-cli
: A command line interface tool for ChatGPT. Refer to the repo for instructions on how to configure it. You can install chatgpt-cli withpipx
as below:
pipx install git+https://github.com/marcolardera/chatgpt-cli
- Install
xclip
andxfce4-terminal
if they are not already installed on your system. This can typically be done via your distribution's package manager. For example:
sudo apt-get install xclip xfce4-terminal
-
Install the
chatgpt-cli
tool as per its documentation and ensure it is in the expected directory. -
Place the script file in a directory on the path, making sure that it has execution permissions. i.e.,
mv copy-to-chat /usr/local/bin/
chmod +x /usr/local/bin/copy-to-chat
- If you are on XFCE, you can bind this script to a keyboard shortcut by going into Settings > Keyboard > Application Shortcuts.