Created
September 26, 2024 02:41
-
-
Save Tekunogosu/1e25d3c8e578cd039b25b8a26e0825a1 to your computer and use it in GitHub Desktop.
Kitty: Open new tab with set title from within kitty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| # create a new tab and set the title | |
| # make sure to update your ~/.conf/kitty/kitty.conf to enable: allow_remote_control on | |
| import subprocess | |
| import argparse | |
| import sys | |
| def open_kitty_tab_with_title(title: str) -> None: | |
| # The command to open a new tab with the specified title | |
| kitty_command = ["kitty", "@", "launch", "--type", "tab", "--tab-title", title] | |
| try: | |
| # Execute the command to open a new tab with the specified title | |
| subprocess.run(kitty_command, check=True) | |
| print(f"New tab opened with title: {title}") | |
| except subprocess.CalledProcessError as e: | |
| print(f"Error opening new tab: {e}") | |
| sys.exit(1) | |
| def main(): | |
| # Argument parser setup | |
| parser = argparse.ArgumentParser(description="Open a new kitty tab with a specified title") | |
| parser.add_argument("title", type=str, help="Title of the new tab") | |
| args = parser.parse_args() | |
| # Call the function with the provided title | |
| open_kitty_tab_with_title(args.title) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment