Skip to content

Instantly share code, notes, and snippets.

@Tekunogosu
Created September 26, 2024 02:41
Show Gist options
  • Select an option

  • Save Tekunogosu/1e25d3c8e578cd039b25b8a26e0825a1 to your computer and use it in GitHub Desktop.

Select an option

Save Tekunogosu/1e25d3c8e578cd039b25b8a26e0825a1 to your computer and use it in GitHub Desktop.
Kitty: Open new tab with set title from within kitty
#!/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