{"id":13448414,"url":"https://github.com/sebglazebrook/aliases","last_synced_at":"2025-03-22T09:31:25.282Z","repository":{"id":51916593,"uuid":"49164741","full_name":"sebglazebrook/aliases","owner":"sebglazebrook","description":"Contextual, dynamic aliases for the bash shell","archived":false,"fork":false,"pushed_at":"2024-10-28T02:46:08.000Z","size":35786,"stargazers_count":565,"open_issues_count":16,"forks_count":36,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-28T03:29:09.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebglazebrook.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2016-01-06T22:07:45.000Z","updated_at":"2024-10-27T16:55:29.000Z","dependencies_parsed_at":"2024-03-13T03:30:12.647Z","dependency_job_id":"fe9136f8-4287-496d-be2e-afd833d26e5e","html_url":"https://github.com/sebglazebrook/aliases","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebglazebrook%2Faliases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebglazebrook%2Faliases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebglazebrook%2Faliases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebglazebrook%2Faliases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebglazebrook","download_url":"https://codeload.github.com/sebglazebrook/aliases/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244937751,"owners_count":20535124,"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":[],"created_at":"2024-07-31T05:01:44.877Z","updated_at":"2025-03-22T09:31:20.214Z","avatar_url":"https://github.com/sebglazebrook.png","language":"Rust","readme":"# Overview\n\nDynamic aliases based on the directory you are currently in.\n\nEver wanted to type something like `server` in whole bunch of different directories and your computer just knows what you're thinking?\n\nNow you can!\n\n## Why you want this\n\nAlready know why you want this? Jump to [Installation](#installation) section.\n\nBash aliases are cool but limited, they are globals and have limited configurability.\n\nOne downside of standard bash aliases is that they don't take arguments, to counter this many people (myself included) do things like create bash functions like this:\n\n```\nfunction ll {\n  ls -la \"$@\"\n}\n```\n\nThe downside to above function is that it's hard to tell where these functions are coming from, you can't just type `which ll` and find the function.\n\nYou also end up writing a whole lot of functions that are really similar, plus none of these are dynamic or contextual\n\nSo I created `aliases` to make my life easier and more fun.\n\n## Usage\n\nTo create aliases for the current directory run:\n\n```\naliases init\n```\n\nThis creates a `.aliases` file in the current directory with a commented out alias structure that looks like below:\n\n```yaml\n# alias_name:\n#   command: ./super_command.sh                         # required\n#   confirm: true                                       # optional - You will be asked to confirm before execution\n#   confirmation_message: Are you sure you are sure??   # optional - If confirm is set to true then you this is your confirmation message\n#   conditional: /bin/true                              # optional - A bash command that needs to be successful for the alias to run\n#   backout_seconds: 3                                  # optional - Give's you a backout option (ctrl + c) before the alias is executed\n#   unit_test: '[ true = true ]'                        # optional - A bash command that tells whether the alias is doing what you want\n#   quiet: false                                        # optional - default 'false', when set to false evaluated command is printed to stderr before running\n```\n\nEdit the file and then run `aliases rehash` to make the alias available.\n\nHere's an example of some of the aliases:\n\n```yaml\nl:\n  command: ls\ngc:\n  command: git commit\ndeploy_production:\n  command: bundle exec cap production deploy\n  backout_seconds: 3\n  conditional: test git rev-parse --abbrev-ref HEAD` == \"master\"\ndeploy_staging:\n  command: bundle exec cap staging deploy\n```\n\nTo list all aliases available type:\n\n```\naliases\n```\n\nThe `.aliases` file should be checked in to your repo, spread the alias love with the people you are working with.\n\n### Global Aliases\n\nGlobal aliases are created by running `aliases init` in your home directory.\n\nThese aliases are overridden by local aliases if they exist.\n\n\n## Installation\n\n### macOS\n\n```\nbrew install sebglazebrook/aliases/aliases\n```\n\n### Linux\n\nThere are some debian packages in the released directory so you can clone the repo and do something like this:\n\n```\napt install ./releases/0.8.1/debian/aliases_0.8.1.deb\n```\n\nYou'll need to `sudo` that though of course.\n\nNext you'll need to add the aliases initialization config to you .bashrc or any file that's loaded when your user logs in.\n\n```\naliases init --global \u003e\u003e ~/.bashrc\n```\n\n### Compile from source\n\nTODO\n\n## Features in development\n\nTo test these either compile from source or `brew install aliases --devel`\n\n### Positional arguments\n\nExample:\n\n```yaml\nvim-replace:\n  command: ag -l \"$0\" \u0026\u0026 vim -c \"bufdo %s/$0/$1/gc\" $(ag -l \"$0\")\n  enable_positional_arguments: true\n``````\n\nThe above alias allows you to do the following:\n\n```\nvim-replace old_text new_text\n```\n\nThis replaces `$0`, `$1` etc with the arguments you send to your alias.\n\nThis currently assumes that your position keys are continuous. For example if you have `$0`, `$1`, `$5` then it will not work.\n\n### User Aliases\n\nMaybe you want to import a friends aliases or use aliases relevant to your work, aliases makes that easy:\n\n```\n# create a new aliases file for a user\n\naliases init --user superman\n```\n\nThis will create a new empty `.aliases-superman` file in the current directory and add the user `superman` to the list of alias users.\n\nIf your repo already has a `.aliases-superman` the file will be left untouched and the user `superman` will be added to your list of alias users.\n\nThe next time you run `aliases rehash`, all `superman` aliases in all initialized directories will be updated.\n\nUser aliases are merged together to create a list of available aliases.\n\nIf there are clashing aliases the alias user prioritized highest wins.\n\nYou can see all users and their prioritization using:\n\n```\naliases users\n```\n\nTo change the prioritization order of the user, you currently need to edit the user list in the config file.\n\n```\ncat ~/.aliases_cfg\n```\n\nAnd to temporally bump a user to the top with env var, like when you are pairing and sharing your shell:\n```\nexport ALIASES_USER=superman\n```\n\nYou can also pull and sync user aliases with github as:\n```\naliases clone sebglazebrook                             # this could pull from github.com/sebglazebrook/.aliases repo\naliases clone sebglazebrook https://some-other-address  # pulls from the given repo\naliases pull sebglazberook                              # pull and show the diff\n```\n\n## Contributing\n\nDo the normal things, fork the code and make a PR.\n\nWe use docker containers so we can share the same development environment. Some aliases are in this repository to help you to get up to speed. Here the list:\n- ``release`` - generates a new release given the version-number\n- ``run-tests`` - run all the tests\n- ``workspace`` - connect to docker environment (uses the alias ``docker-machine-name`` to get it)\n\n## Bugs to fix\n\n- Handle different process signals\n- Check user's config is out of whack, like they are missing a key, it blows up\n- Being able to actually run the unit tests :-)\n- When listing, aliases alert the user if the dir hasn't been initialized\n\n## Small improvements to come\n\n- Handle when numbers args are not in order\n- Add description of alias that can be seen in list view\n- Sort aliases lists better and make it more obvious which ones are local\n- Colors for user interactions\n- Use a thread pool when running rehash command to avoid too many threads\n- In list view add more data about the aliases, user etc\n- Allow multi-line command that display is list view well\n\n## Possible future features\n\n- Clean uninstall, removing shims etc\n- Allow user to set a default shell or override the default shell. Currently all aliases are hardcoded to run inside a bash shell, could be sh or zsh\n","funding_links":[],"categories":["Rust","Command-Line Productivity","Shells"],"sub_categories":["Bash","Reusable Things"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebglazebrook%2Faliases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebglazebrook%2Faliases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebglazebrook%2Faliases/lists"}