Skip to content

Add support for aliases in ov #4407

Closed

Description

Problem

We tried adding aliases in #4343 using associative bash arrays. However, macOS's bash version is stuck on an older version that doesn't support associative arrays. So I removed that from the PR and decided to try it a different way in a future PR as a separate issue.

Description

Create some method of expanding aliases when running ov. For example, ov j should expand to ov just.

It should be possible with one-dimensional arrays, and treating odd-or-0 index as the alias and the following even index as the expansion. This would be preferred, as it's probably less overhead than something else (like the Python script).

Another option I thought of was to use Python to process argv in the entrypoint and expand the aliases there. The entrypoint could end with python ./docker/dev_env/expand_aliases.py "$@", and that script could import $OPENVERSE_PROJECT/.ov_aliases.py using a method like https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly, and then do something like:

#... import personal_aliases from $OPENVERSE_PROJECT/.ov_aliases.py

shared_aliases = {
    "j": "just",
}

all_aliases = shared_aliases | personal_aliases

args = sys.argv[1:]
if args[0] in all_aliases:
  args[0] = all_aliases[args[0]]

sys.execv(args)

Alternatives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

🟩 priority: lowLow priority and doesn't need to be rushed🤖 aspect: dxConcerns developers' experience with the codebase🧰 goal: internal improvementImprovement that benefits maintainers, not users🧱 stack: mgmtRelated to repo management and automations

Type

No type

Projects

  • Status

    ✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions