We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Current HEAD zsh-completion.py needs option_aliases update
**Small description**

`option_aliases` was removed in ce497f444db6d2f3fc0b8309f5ca839196c33c8b but is still referred to in the zsh completion code.

https://github.com/saulpw/visidata/blob/34808745232e798b0f25e893bb444fc9f3c034eb/dev/zsh-completion.py#L11C41-L11C41

I think the script needs a slight rejig to use the (present) `vd` import instead.

I wonder whether this can be included in future CI?

**Expected result**

The command succeeds.

**Actual result**

```
       > /build/visidata-src
       > Traceback (most recent call last):
       >   File "/build/visidata-src/dev/zsh-completion.py", line 11, in <module>
       >     from visidata.main import option_aliases
       > ImportError: cannot import name 'option_aliases' from 'visidata.main' (/build/visidata-src/visidata/main.py)
```

**Steps to reproduce**

```
python dev/zsh-completion.py
```

**Additional context**
~~Please include the version of VisiData and Python.~~

https://github.com/saulpw/visidata/tree/34808745232e798b0f25e893bb444fc9f3c034eb but I listed the commit above that causes the breakage — I suspect this is a two minute fix for somebody familiar with the codebase, though not me. I can help with extending CI, though it might just be a case of adding

```yaml
    - name: Ensure VisiData can create completions
      run: python dev/zsh-completion.py
```

(I guess you might want to run a linter, instead.)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `dev/zsh-completion.py`
Content:
```
1 #!/usr/bin/env python
2 from __future__ import unicode_literals
3 
4 import os
5 from os.path import dirname as dirn
6 import sys
7 import re
8 
9 sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
10 from visidata import vd
11 from visidata.main import option_aliases
12 
13 ZSH_COMPLETION_FILE = "_visidata"
14 ZSH_COMPLETION_TEMPLATE = "dev/zsh-completion.in"
15 pat_class = re.compile("'(.*)'")
16 pat_select = re.compile("^\([^)]*\)")
17 
18 
19 def generate_completion(opt):
20     prefix = "--" + opt.name
21     shortnames = [key for key, value in option_aliases.items() if value[0] == opt.name]
22     if len(shortnames):
23         if len(shortnames[0]) == 1:
24             shortname = "-" + shortnames[0]
25         else:
26             shortname = "--" + shortnames[0]
27         prefix = "{" + f"{shortname},{prefix}" + "}"
28     if isinstance(opt.value, bool):
29         completion = ""
30     else:
31         completion = ":" + pat_class.findall(str(opt.value.__class__))[0]
32     if opt.name in ["play", "output", "visidata_dir", "config"]:
33         completion += ":_files"
34     elif opt.name in ["plugins_url", "motd_url"]:
35         completion += ":_urls"
36     helpstr = opt.helpstr
37     selections = pat_select.findall(helpstr)
38     if len(selections):
39         completion += f":{selections[0].replace('/', ' ')}"
40     # TODO: use `zstyle ':completion:*' extra-verbose true`
41     # to control the display of default value
42     helpstr = helpstr + f" (default: {opt.value})"
43     helpstr = helpstr.replace("[", "\\[").replace("]", "\\]")
44     return f"{prefix}'[{helpstr}]{completion}'"
45 
46 
47 flags = [generate_completion(vd._options[opt]["default"]) for opt in vd._options]
48 
49 with open(ZSH_COMPLETION_TEMPLATE) as f:
50     template = f.read()
51 
52 template = template.replace("{{flags}}", " \\\n    ".join(flags))
53 
54 with open(ZSH_COMPLETION_FILE, "w") as f:
55     f.write(template)
56
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/dev/zsh-completion.py b/dev/zsh-completion.py
--- a/dev/zsh-completion.py
+++ b/dev/zsh-completion.py
@@ -8,7 +8,6 @@
 
 sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))
 from visidata import vd
-from visidata.main import option_aliases
 
 ZSH_COMPLETION_FILE = "_visidata"
 ZSH_COMPLETION_TEMPLATE = "dev/zsh-completion.in"
@@ -18,7 +17,9 @@
 
 def generate_completion(opt):
     prefix = "--" + opt.name
-    shortnames = [key for key, value in option_aliases.items() if value[0] == opt.name]
+    shortnames = [
+        key for key, value in vd.option_aliases.items() if value[0] == opt.name
+    ]
     if len(shortnames):
         if len(shortnames[0]) == 1:
             shortname = "-" + shortnames[0]

{"golden_diff": "diff --git a/dev/zsh-completion.py b/dev/zsh-completion.py\n--- a/dev/zsh-completion.py\n+++ b/dev/zsh-completion.py\n@@ -8,7 +8,6 @@\n \n sys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))\n from visidata import vd\n-from visidata.main import option_aliases\n \n ZSH_COMPLETION_FILE = \"_visidata\"\n ZSH_COMPLETION_TEMPLATE = \"dev/zsh-completion.in\"\n@@ -18,7 +17,9 @@\n \n def generate_completion(opt):\n     prefix = \"--\" + opt.name\n-    shortnames = [key for key, value in option_aliases.items() if value[0] == opt.name]\n+    shortnames = [\n+        key for key, value in vd.option_aliases.items() if value[0] == opt.name\n+    ]\n     if len(shortnames):\n         if len(shortnames[0]) == 1:\n             shortname = \"-\" + shortnames[0]\n", "issue": "Current HEAD zsh-completion.py needs option_aliases update\n**Small description**\r\n\r\n`option_aliases` was removed in ce497f444db6d2f3fc0b8309f5ca839196c33c8b but is still referred to in the zsh completion code.\r\n\r\nhttps://github.com/saulpw/visidata/blob/34808745232e798b0f25e893bb444fc9f3c034eb/dev/zsh-completion.py#L11C41-L11C41\r\n\r\nI think the script needs a slight rejig to use the (present) `vd` import instead.\r\n\r\nI wonder whether this can be included in future CI?\r\n\r\n**Expected result**\r\n\r\nThe command succeeds.\r\n\r\n**Actual result**\r\n\r\n```\r\n       > /build/visidata-src\r\n       > Traceback (most recent call last):\r\n       >   File \"/build/visidata-src/dev/zsh-completion.py\", line 11, in <module>\r\n       >     from visidata.main import option_aliases\r\n       > ImportError: cannot import name 'option_aliases' from 'visidata.main' (/build/visidata-src/visidata/main.py)\r\n```\r\n\r\n**Steps to reproduce**\r\n\r\n```\r\npython dev/zsh-completion.py\r\n```\r\n\r\n**Additional context**\r\n~~Please include the version of VisiData and Python.~~\r\n\r\nhttps://github.com/saulpw/visidata/tree/34808745232e798b0f25e893bb444fc9f3c034eb but I listed the commit above that causes the breakage \u2014 I suspect this is a two minute fix for somebody familiar with the codebase, though not me. I can help with extending CI, though it might just be a case of adding\r\n\r\n```yaml\r\n    - name: Ensure VisiData can create completions\r\n      run: python dev/zsh-completion.py\r\n```\r\n\r\n(I guess you might want to run a linter, instead.)\n", "before_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import unicode_literals\n\nimport os\nfrom os.path import dirname as dirn\nimport sys\nimport re\n\nsys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))\nfrom visidata import vd\nfrom visidata.main import option_aliases\n\nZSH_COMPLETION_FILE = \"_visidata\"\nZSH_COMPLETION_TEMPLATE = \"dev/zsh-completion.in\"\npat_class = re.compile(\"'(.*)'\")\npat_select = re.compile(\"^\\([^)]*\\)\")\n\n\ndef generate_completion(opt):\n    prefix = \"--\" + opt.name\n    shortnames = [key for key, value in option_aliases.items() if value[0] == opt.name]\n    if len(shortnames):\n        if len(shortnames[0]) == 1:\n            shortname = \"-\" + shortnames[0]\n        else:\n            shortname = \"--\" + shortnames[0]\n        prefix = \"{\" + f\"{shortname},{prefix}\" + \"}\"\n    if isinstance(opt.value, bool):\n        completion = \"\"\n    else:\n        completion = \":\" + pat_class.findall(str(opt.value.__class__))[0]\n    if opt.name in [\"play\", \"output\", \"visidata_dir\", \"config\"]:\n        completion += \":_files\"\n    elif opt.name in [\"plugins_url\", \"motd_url\"]:\n        completion += \":_urls\"\n    helpstr = opt.helpstr\n    selections = pat_select.findall(helpstr)\n    if len(selections):\n        completion += f\":{selections[0].replace('/', ' ')}\"\n    # TODO: use `zstyle ':completion:*' extra-verbose true`\n    # to control the display of default value\n    helpstr = helpstr + f\" (default: {opt.value})\"\n    helpstr = helpstr.replace(\"[\", \"\\\\[\").replace(\"]\", \"\\\\]\")\n    return f\"{prefix}'[{helpstr}]{completion}'\"\n\n\nflags = [generate_completion(vd._options[opt][\"default\"]) for opt in vd._options]\n\nwith open(ZSH_COMPLETION_TEMPLATE) as f:\n    template = f.read()\n\ntemplate = template.replace(\"{{flags}}\", \" \\\\\\n    \".join(flags))\n\nwith open(ZSH_COMPLETION_FILE, \"w\") as f:\n    f.write(template)\n", "path": "dev/zsh-completion.py"}], "after_files": [{"content": "#!/usr/bin/env python\nfrom __future__ import unicode_literals\n\nimport os\nfrom os.path import dirname as dirn\nimport sys\nimport re\n\nsys.path.insert(0, dirn(dirn((os.path.abspath(__file__)))))\nfrom visidata import vd\n\nZSH_COMPLETION_FILE = \"_visidata\"\nZSH_COMPLETION_TEMPLATE = \"dev/zsh-completion.in\"\npat_class = re.compile(\"'(.*)'\")\npat_select = re.compile(\"^\\([^)]*\\)\")\n\n\ndef generate_completion(opt):\n    prefix = \"--\" + opt.name\n    shortnames = [\n        key for key, value in vd.option_aliases.items() if value[0] == opt.name\n    ]\n    if len(shortnames):\n        if len(shortnames[0]) == 1:\n            shortname = \"-\" + shortnames[0]\n        else:\n            shortname = \"--\" + shortnames[0]\n        prefix = \"{\" + f\"{shortname},{prefix}\" + \"}\"\n    if isinstance(opt.value, bool):\n        completion = \"\"\n    else:\n        completion = \":\" + pat_class.findall(str(opt.value.__class__))[0]\n    if opt.name in [\"play\", \"output\", \"visidata_dir\", \"config\"]:\n        completion += \":_files\"\n    elif opt.name in [\"plugins_url\", \"motd_url\"]:\n        completion += \":_urls\"\n    helpstr = opt.helpstr\n    selections = pat_select.findall(helpstr)\n    if len(selections):\n        completion += f\":{selections[0].replace('/', ' ')}\"\n    # TODO: use `zstyle ':completion:*' extra-verbose true`\n    # to control the display of default value\n    helpstr = helpstr + f\" (default: {opt.value})\"\n    helpstr = helpstr.replace(\"[\", \"\\\\[\").replace(\"]\", \"\\\\]\")\n    return f\"{prefix}'[{helpstr}]{completion}'\"\n\n\nflags = [generate_completion(vd._options[opt][\"default\"]) for opt in vd._options]\n\nwith open(ZSH_COMPLETION_TEMPLATE) as f:\n    template = f.read()\n\ntemplate = template.replace(\"{{flags}}\", \" \\\\\\n    \".join(flags))\n\nwith open(ZSH_COMPLETION_FILE, \"w\") as f:\n    f.write(template)\n", "path": "dev/zsh-completion.py"}]}