Skip to content

Instantly share code, notes, and snippets.

@zadjii-msft
Last active September 4, 2024 09:07
Show Gist options
  • Save zadjii-msft/2250c49c29e1fe1dc6ec510aaf06c31b to your computer and use it in GitHub Desktop.
Save zadjii-msft/2250c49c29e1fe1dc6ec510aaf06c31b to your computer and use it in GitHub Desktop.
Warp Workflows for the Windows Terminal

Add all the Warp Workflows to Windows Terminal

With a combination of features all available in Windows Terminal 1.22, you can now add all your favorite Warp Workflows directly to the Windows Terminal.

image image

This works by adding the workflows to your settings via a "settings fragment". You can then open a menu with all these workflows with the openSuggestions action.

  1. Go clone https://github.com/warpdotdev/workflows
  2. cd workflows
  3. py dump-workflows.py > "%localappdata%\Microsoft\Windows Terminal\Fragments\warp-workflows\actions.json"
  4. Add a keybinding for openSuggestions:
     {
         "command": { "action": "showSuggestions", "source": "all" },
         "keys": "ctrl+shift+y"
     },
    (it doesn't have to be ctrl+shift+y
  5. profit

Fair warning - there's a lot of workflows in Warp. You may want to further nest that list of actions under a "name": "workflows" command. Or you can spit them all into a flat list. Do whatever you like!

import yaml
import json
import sys
import os
def parse_yaml_files(tool, directory):
json_data = {}
json_data["name"] = f"{tool}..."
json_data["commands"] = []
for filename in os.listdir(directory):
if filename.endswith(".yaml") or filename.endswith(".yml"):
file_path = os.path.join(directory, filename)
with open(file_path, 'r', encoding="utf-8") as file:
try:
yaml_data = yaml.safe_load(file)
new_obj = {}
command = {}
command["input"] = yaml_data["command"]
command["action"] ="sendInput"
new_obj["command"]=command
new_obj["name"] = yaml_data["name"]
new_obj["description"] = yaml_data["description"] if "description" in yaml_data else ""
json_data["commands"].append(new_obj)
except yaml.YAMLError as e:
print(f"Error parsing {filename}: {e}")
sys.exit(-1)
return json_data
def main(directory) -> int:
json_data = {}
json_data["actions"] = []
for tool_dir in os.listdir(directory):
json_data["actions"].append(parse_yaml_files(tool_dir, os.path.join(directory, tool_dir)))
print(json.dumps(json_data, indent=4))
return 0
if __name__ == '__main__':
# Write this output to something like
# "%localappdata%\Microsoft\Windows Terminal\Fragments\warp-workflows\actions.json"
sys.exit(main(".\\specs"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment