{"id":15524568,"url":"https://github.com/adoy/cmdalias","last_synced_at":"2025-10-27T11:19:16.644Z","repository":{"id":66812693,"uuid":"84865571","full_name":"adoy/cmdalias","owner":"adoy","description":"Just a small tool to help me (and you but without any guaranty) to create command alias and sub-aliases (multi word alias)","archived":false,"fork":false,"pushed_at":"2024-02-14T18:56:14.000Z","size":236,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-29T22:41:22.370Z","etag":null,"topics":["alias","bash","multi-word","productivity","sub-alias","tool","zsh"],"latest_commit_sha":null,"homepage":"https://cmdalias.adoy.io","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adoy.png","metadata":{"files":{"readme":"docs/README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-13T19:20:35.000Z","updated_at":"2025-03-08T21:18:36.000Z","dependencies_parsed_at":"2024-02-14T20:36:22.154Z","dependency_job_id":null,"html_url":"https://github.com/adoy/cmdalias","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2Fcmdalias","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2Fcmdalias/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2Fcmdalias/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adoy%2Fcmdalias/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adoy","download_url":"https://codeload.github.com/adoy/cmdalias/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250391910,"owners_count":21422988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alias","bash","multi-word","productivity","sub-alias","tool","zsh"],"created_at":"2024-10-02T10:51:43.146Z","updated_at":"2025-10-27T11:19:16.561Z","avatar_url":"https://github.com/adoy.png","language":"C","readme":"# What is cmdalias\n\n`cmdalias` is an nested alias tool that I created for myself and inspired from the [git-config alias](https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases) mechanism. It lets you create context aware aliases and nested aliases (subaliases / multi word alias).\n\nWhy? I was tired of using too many keystrokes for commands that I'm using everyday in my shell. For example, with docker, I often want to list images or clean containers and images.\n\nExample: \n\n```bash\ndocker\nalias: d\n\ndocker images -a\nalias: d i\n\ndocker network ls\nalias: d n l\n```\n\nWith traditional aliases, you can only have one level of depth within your short names. With cmdalias, you can easily nest short names and transform `kubectl get pod` to `k g p`. More examples will be provided below.\n\n## Installation\n\nCompile the binary and put it in your `$PATH`\n\n```bash\n./configure [--prefix=/path/to/location]\nmake \u0026\u0026 make install\n```\n\n**cmdalias** will install itself by default with the prefix `/usr/local` with the binary located at `/usr/local/bin`.\n\n## Usage\n\n### Configure your commands\n\nChoose your configuration method, either:\n\n- one alias file named `.cmdalias` under your **$HOME** directory\n- multiple alias files in a directory named `.cmdalias/` under your **$HOME** directory. The names can be whatever you like.\n\nFor example:\n\n```\n$HOME/\n│   .cmdalias\n└───.cmdalias/\n│   │   docker\n│   │   k18n\n│   │   utilities\n```\n\n### Run\n\nTo **dry-run** the aliases that will be created run `cmdalias -i`, they will be printed to stdout. Moreover, you can check if the syntax you wrote is correct by running `cmdalias --check-config`\n\nWhen satisfied, run the following  \n\n```bash\nsource \u003c(cmdalias -i)\n```\n\nIf you want **cmdalias** to create the aliases each time you login, add it to the configuration of your favorite command line interpreter.\n\n```bash\necho \"source \u003c(cmdalias -i)\" \u003e\u003e ~/.bashrc\n```\n\n## Configuration examples\n\n### Single alias\n\n```\nd = docker;\n```\n\n### Nested/subalias\n\n```\nd = docker {\n    i = images;\n};\n```\n\nYou can add command line arguments and options to aliases and subaliases\n\n```\n// to pipe copy, for example: echo \"bar\" | copy\ncopy = xclip -selection c;\n\nd = docker {\n    i = images;\n    e = exec -it;\n};\n```\n\n### Wildcard subalias using `*`\n\nLet's take the kubernetes command to list a single pod in a JSON output format\n```\nkubectl get -o json pod \u003csome_pod\u003e\n```\n\nWe could write the following configuration:\n\n```\nk = kubectl {\n    * {\n        p          = pod;\n        -j      = -o json;\n    };\n    g  = get;\n};\n```\n\nAnd be able to execute `k g p -j`.\n\nThe `*` basically means that the subalias is permitted at any level of the command.\n\n## More complex configuration examples\n\n### Docker\n\n```\nd = docker {\n    i = images;\n    l = logs -f;\n    e = exec -it;\n    k = kill;\n    s = stop;\n    r = run;\n    n = network {\n        l = ls;\n    };\n    v = volume {\n        ls  = ls | grep -v docker | grep -v nuglif | grep -v DRIVER | gawk '{ print $2 }';\n    };\n\n    clean = !sh -c \"docker container prune --force; docker rmi $(docker images -f 'dangling=true' -q)\";\n};\n```\n\nWith this `docker` alias you can use commands like:\n\n| Short command using cmdalias | Real command |\n| --- | --- |\n| `d i` | `docker images` |\n| `d n l` | `docker network ls` |\n| `d v ls` | \u003ccode\u003edocker volume ls \u0026#124; grep -v docker \u0026#124; grep -v data \u0026#124; grep -v DRIVER \u0026#124; gawk '{ print $2 }'\"\u003c/code\u003e |\n| `d r \u003csome_image\u003e` | `docker run \u003csome_image\u003e` |\n| ... | and so on... |\n\n##### Kubernetes\n\n```\nk = kubectl {\n    * {\n        p          = pod;\n        i          = ingress;\n        d          = deploy;\n        s          = svc;\n        pp         = podpreset;\n        -a         = --all-namespaces;\n        -json      = -o json;\n        -yaml,-yml = -o yaml;\n    };\n    ns = config set-context `kubectl config current-context` --namespace;\n    gc = config get-contexts;\n    uc = config use-context;\n    cc = config current-context;\n    g  = get;\n    d, desc  = describe;\n    a, apply = apply {\n        -f = -R -f;\n    };\n    e = edit;\n    tail = !kail;\n};\n```\n\nWith this `kubectl` alias you can use commands like:\n\n| Real command | Short command using cmdalias |\n| --- | --- |\n| `kubectl config get-contexts` | `k gc` |\n| `kubectl config use-context production` | `k uc production` |\n| `kubectl get pod --all-namespaces` | `k g p -a` |\n| `kubectl apply -R -f \u003csome_folder\u003e` | `k a -f \u003csome_folder\u003e` |\n| ``kubectl config set-context `kubectl config current-context` --namespace production`` | `k ns production` |\n| ... | and so on... |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoy%2Fcmdalias","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadoy%2Fcmdalias","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadoy%2Fcmdalias/lists"}