{"id":13786664,"url":"https://github.com/pokanop/nostromo","last_synced_at":"2025-05-11T22:32:00.003Z","repository":{"id":38944238,"uuid":"196679648","full_name":"pokanop/nostromo","owner":"pokanop","description":"👽 CLI for building powerful aliases and tools","archived":false,"fork":false,"pushed_at":"2024-06-25T20:16:49.000Z","size":14663,"stargazers_count":143,"open_issues_count":13,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-11-15T14:42:24.748Z","etag":null,"topics":["aliases","bash","cli","go","hacktoberfest","nostromo","shell","tool","zsh"],"latest_commit_sha":null,"homepage":"https://nostromo.sh/","language":"Go","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/pokanop.png","metadata":{"files":{"readme":"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":"2019-07-13T04:51:46.000Z","updated_at":"2024-11-14T08:25:36.000Z","dependencies_parsed_at":"2024-06-18T22:49:49.844Z","dependency_job_id":"9678c88d-1477-4f8a-ba62-43f2c098b041","html_url":"https://github.com/pokanop/nostromo","commit_stats":null,"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokanop%2Fnostromo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokanop%2Fnostromo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokanop%2Fnostromo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pokanop%2Fnostromo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pokanop","download_url":"https://codeload.github.com/pokanop/nostromo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225101335,"owners_count":17421075,"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":["aliases","bash","cli","go","hacktoberfest","nostromo","shell","tool","zsh"],"created_at":"2024-08-03T19:01:27.519Z","updated_at":"2024-11-17T22:32:36.001Z","avatar_url":"https://github.com/pokanop.png","language":"Go","funding_links":["https://www.buymeacoffee.com/pokanopapps"],"categories":["Utilities","Go","公用事业公司","工具库","Utility","工具库`可以提升效率的通用代码库和工具`"],"sub_categories":["Utility/Miscellaneous","HTTP Clients","实用程序/Miscellaneous","查询语","Fail injection"],"readme":"[![Travis (.com)](https://img.shields.io/travis/com/pokanop/nostromo)](https://app.travis-ci.com/pokanop/nostromo) [![Go Report Card](https://goreportcard.com/badge/github.com/pokanop/nostromo)](https://goreportcard.com/report/github.com/pokanop/nostromo) [![Coveralls github](https://img.shields.io/coveralls/github/pokanop/nostromo)](https://coveralls.io/github/pokanop/nostromo) [![GitHub](https://img.shields.io/github/license/pokanop/nostromo)](https://github.com/pokanop/nostromo/blob/master/LICENSE) [![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/mess-hall.png\" alt=\"mess-hall\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"left\" style=\"margin: 12px 0px\"\u003e\n  \u003cimg src=\"images/nostromo-drop-ship.png\" alt=\"nostromo\"\u003e\u0026nbsp;\n  \u003cimg src=\"images/nostromo-logo.png\" alt=\"nostromo\" style=\"height: 32px\"\u003e\n\u003c/p\u003e\n\n`nostromo` is a CLI to rapidly build declarative aliases making multi-dimensional tools on the fly.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/intro.gif\" alt=\"intro\" style=\"border-radius: 15px\"\u003e\n\u003c/p\u003e\n\nManaging aliases can be tedious and difficult to set up. `nostromo` makes this process easy and reliable. The tool adds shortcuts to your `.bashrc` / `.zshrc` that call into the `nostromo` binary. It reads and manages all aliases within its manifest. This is used to find and execute the actual command as well as swap any substitutions to simplify calls.\n\n`nostromo` can help you build complex tools in a declarative way. Tools commonly allow you to run multi-level commands like `git rebase master branch` or `docker rmi b750fe78269d` which are clear to use. Imagine if you could wrap your aliases / commands / workflow into custom commands that describe things you do often. Well, now you can with nostromo. 🤓\n\nWith `nostromo` you can take aliases like these:\n\n```sh\nalias ios-build='pushd $IOS_REPO_PATH;xcodebuild -workspace Foo.xcworkspace -scheme foo_scheme'\nalias ios-test='pushd $IOS_REPO_PATH;xcodebuild -workspace Foo.xcworkspace -scheme foo_test_scheme'\nalias android-build='pushd $ANDROID_REPO_PATH;./gradlew build'\nalias android-test='pushd $ANDROID_REPO_PATH;./gradlew test'\n```\n\nand turn them into declarative commands like this:\n\n```sh\nbuild ios\nbuild android\ntest ios\ntest android\n```\n\nThe possibilities are endless 🚀 and up to your imagination with the ability to compose commands as you see fit.\n\n\u003e Check out the [examples](https://github.com/pokanop/nostromo/tree/main/examples) folder for sample manifests with commands.\n\n## \u003cimg align=\"left\" src=\"images/sleep-pod.png\" alt=\"sleep pod\"\u003e\u0026nbsp;Getting Started\n\n### Prerequisites\n\n- Works for MacOS and `bash` / `zsh` shells (other combinations untested _but may work_)\n\n### Installation\n\nUsing `brew`:\n\n```sh\nbrew install pokanop/pokanop/nostromo\n```\n\nUsing `go get`:\n\n```sh\ngo get -u github.com/pokanop/nostromo\n```\n\n### Initialization\n\nThis command will initialize `nostromo` and create a manifest under `~/.nostromo`:\n\n```sh\nnostromo init\n```\n\nTo customize the directory (and change it from `~/.nostromo`), set the `NOSTROMO_HOME` environment variable to a location of your choosing.\n\n\u003e With every update, it's a good idea to run `nostromo init` to ensure any manifest changes are migrated and commands continue to work. `nostromo` will attempt to perform any migrations as well at this time to files and folders so 🤞\n\nThe quickest way to populate your commands database is using the `dock` feature:\n\n```sh\nnostromo dock \u003csource\u003e\n```\n\nwhere `source` can be any local or remote file sources. See the [Distributed Manifests](#distributed-manifests) section for more details.\n\nTo destroy the core manifest and start over you can always run:\n\n```sh\nnostromo destroy\n```\n\nBackups of manifests are automatically taken to prevent data loss in case of shenanigans gone wrong. These are located under `${NOSTROMO_HOME}/cargo`. The maximum number of backups can be configured with the `backupCount` manifest setting.\n\n```sh\nnostromo set backupCount 10\n```\n\n## \u003cimg align=\"left\" src=\"images/derelict-ship.png\" alt=\"derelict ship\"\u003e\u0026nbsp;Key Features\n\n- [Simplified alias management](#managing-aliases)\n- [Scoped commands and substitutions](#scoped-commands-and-substitutions)\n- [Build complex command trees](#complex-command-tree)\n- [Shell completion support](#shell-completion)\n- [Execute code snippets](#execute-code-snippets)\n- [Distributed manifests](#distributed-manifests)\n- [Powerful tree management](#command-tree-management)\n- [Neato themes](#themes)\n\n### Managing Aliases\n\nAliases to commands is one of the core features provided by `nostromo`. Instead of constantly updating shell profiles manually, `nostromo` will automatically keep it updated with the latest additions.\n\n\u003e Given that `nostromo` is not a shell command there are some things to note on how it makes its magic:\n\u003e\n\u003e - _Commands are generated by `nostromo` and executed using the `eval` method in a shell function._\n\u003e - _Commands and changes will be available immediately since `nostromo` reloads completions automatically_\n\u003e\n\u003e If you want create boring standard **shell aliases** you can do that with an additional flag or a config setting described below.\n\nTo add an alias (or command in `nostromo` parlance), simply run:\n\n```sh\nnostromo add cmd foo \"echo bar\"\n```\n\nAnd just like that you can now run `foo` like any other alias.\n\nDescriptions for your commands can easily be added as well:\n\n```sh\nnostromo add cmd foo \"echo bar\" -d \"My magical foo command that prints bar\"\n```\n\n\u003e Your descriptions will show up in the shell when autocompleting!\n\n#### Interactive Mode\n\nYou can also add commands and substitutions **interactively** by using just `nostromo add` without any arguments. This command will walk through prompts to guide adding new commands easily.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/interactive.gif\" alt=\"interactive\" style=\"border-radius: 15px\"\u003e\n\u003c/p\u003e\n\n#### Keypaths\n\n`nostromo` uses the concept of keypaths to simplify building commands and accessing the command tree. A keypath is simply a `.` delimited string that represents the path to the command.\n\nFor example:\n\n```sh\nnostromo add cmd foo.bar.baz 'echo hello'\n```\n\nwill build the command tree for `foo` 👉 `bar` 👉 `baz` such that any of these commands are now valid (of course the first two do nothing _yet_ 😉):\n\n```sh\nfoo\nfoo bar\nfoo bar baz\n```\n\nwhere the last one will execute the `echo` command.\n\nYou can compose several commands together by adding commands at any node of the keypath. The **default** behavior is to concatenate the commands together as you walk the tree. Targeted use of `;` or `\u0026\u0026` can allow for running multiple commands together instead of concatenating. More easily, you can change the command `mode` for any of the commands to do this for you automatically. More info on this later.\n\n#### Shell Aliases\n\n`nostromo` allows users to manage shell aliases. By default, all commands are designed to execute the binary and resolve a command to be evaluated in the shell. This allows you to run those declarative commands easily like `foo bar baz` in the shell. It only creates an alias as a shell function for the root command `foo` and passes the remaining arguments to `nostromo eval` to evaluate the command tree. The result of that is executed with `eval` in the shell. Standard shell aliases **do not** get this behavior.\n\n\u003e The use of standard shell aliases provides limited benefit if you only want single tiered aliases. Additionally, commands persist in the shell since they are evaluated (i.e., changing directories via `cd`).\n\nThere are two methods for adding aliases to your shell profile that are considered standard aliases:\n\n- Use the `--alias-only` or `-a` flag when using `nostromo add cmd`\n- Set the `aliasesOnly` config setting to affect all command additions\n\nFor example, you can see both methods here:\n\n```sh\nnostromo add cmd foo.bar.baz \"cd /tmp\" --alias-only\n\nnostromo set aliasesOnly true\nnostromo add cmd foo.bar.baz \"cd /tmp\"\n```\n\nAdding a standard alias will produce this line that gets sourced:\n\n```sh\nalias foo.bar.baz='cd /tmp'\n```\n\ninstead of a `nostromo` command which adds a shell function:\n\n```sh\nfoo() { eval $(nostromo eval foo \"$*\") }\n```\n\n\u003e Notice how the keypath has no affect in building a command tree when using the **alias only** feature. Standard shell aliases can only be root level commands.\n\n### Scoped Commands And Substitutions\n\nScope affects a tree of commands such that a parent scope is prepended first and then each command in the keypath to the root. If a command is run as follows:\n\n```sh\nfoo bar baz\n```\n\nthen the command associated with `foo` is concatenated first, then `bar`, and finally `baz`. So if these commands were configured like this:\n\n```sh\nnostromo add cmd foo 'echo oof'\nnostromo add cmd foo.bar 'rab'\nnostromo add cmd foo.bar.baz 'zab'\n```\n\nthen the actual execution would result in:\n\n```sh\necho oof rab zab\n```\n\n\u003e Standard behavior is to `concatenate` but you can easily change this with the `mode` flag when using `add` or globally. More information under Execution Modes.\n\n#### Substitutions\n\n`nostromo` also provides the ability to add substitutions at each one of these scopes in the command tree. So if you want to shorten common strings that are otherwise long into substitutions, you can attach them to a parent scope and `nostromo` will replace them at execution time for all instances.\n\nA substitution can be added with:\n\n```sh\nnostromo add sub foo.bar //some/long/string sls\n```\n\nSubsequent calls to `foo bar` would replace the subs before running. This command:\n\n```sh\nfoo bar baz sls\n```\n\nwould finally result in the following since the substitution is in scope:\n\n```sh\nfoo bar baz //some/long/string\n```\n\n### Complex Command Tree\n\nGiven features like **keypaths** and **scope** you can build a complex set of commands and effectively your own tool 🤯 that performs additive functionality with each command node.\n\nYou can get a quick snapshot of the command tree using:\n\n```sh\nnostromo show\n```\n\nWith nostromo, you can also visualize the command tree (or manifest) in several other ways including as `json`, `yaml` and a tree itself.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/tree.gif\" alt=\"tree\" style=\"border-radius: 15px\"\u003e\n\u003c/p\u003e\n\nSetting the `verbose` config setting prints more detailed information as well for all commands.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/verbose.gif\" alt=\"verbose\" style=\"border-radius: 15px\"\u003e\n\u003c/p\u003e\n\n#### Execution Modes\n\nA command's mode indicates how it will be executed. By default, `nostromo` concatenates parent and child commands along the tree. There are 3 modes available to commands:\n\n```sh\n  concatenate  Concatenate this command with subcommands exactly as defined\n  independent  Execute this command with subcommands using ';' to separate\n  exclusive    Execute this and only this command ignoring parent commands\n```\n\nThe mode can be set when adding a command with the `-m` or `--mode` flag:\n\n```sh\nnostromo add cmd foo.bar.baz -m exclusive \"echo baz\"\n```\n\nA global setting can also be set to change the mode from the default `concatenate` with:\n\n```sh\nnostromo set mode independent\n```\n\n\u003e All subsequent commands would inherit the above mode if set.\n\n### Shell Completion\n\n`nostromo` provides completion scripts to allow tab completion. This is added by default to your shell init file:\n\n```sh\neval \"$(nostromo completion)\"\n```\n\nEven your commands added by `nostromo` get the full red carpet treatment with shell completion. Be sure to add a description and tab completion will show hints at each junction of your command. Cool right! 😎\n\n### Execute Code Snippets\n\n`nostromo` provides the ability to supply code snippets in the following languages for execution, in lieu of the standard shell command:\n\n- `ruby` - runs ruby interpreter\n- `python` - runs python interpreter\n- `js` - runs node\n- `perl` - runs perl interpreter\n\n```sh\nnostromo add cmd foo --code 'console.log(\"hello js\")' --language js\n```\n\nFor more complex snippets you can edit `~/.nostromo/ships/manifest.yaml` directly but multiline YAML must be escaped correctly to work.\n\n### Distributed Manifests\n\n`nostromo` now supports keeping multiple manifest sources 💪 allowing you to organize and distribute your commands as you please. This feature enables synchronization functionality to get remote manifests from multiple data sources including:\n\n- Local Files\n- Git\n- Mercurial\n- HTTP\n- Amazon S3\n- Google GCS\n\n\u003e Details on supported file formats and requirements can be found in the [go-getter](https://github.com/hashicorp/go-getter) documentation as `nostromo` uses that for downloading files\n\nConfigs can be found in the `~/.nostromo/ships` folder. The **core manifest** is named `manifest.yaml`.\n\nYou can add as many additional manifests in the same folder and `nostromo` will parse and aggregate all the commands, useful for organizations wanting to build their own command suite.\n\nTo add or dock manifests, use the following:\n\n```sh\nnostromo dock \u003csource\u003e...\n```\n\nAnd that's it! Your commands will now incorporate the new manifest.\n\nTo update docked manifests to the latest versions (omit sources to update all manifests), just run:\n\n```sh\nnostromo sync \u003cname\u003e...\n```\n\n`nostromo` syncs manifests using version information in the manifest. It will only update if the version identifier is different. To force update a manifest, run:\n\n```sh\nnostromo sync -f \u003cname\u003e...\n```\n\nIf you're tired of someone else's manifest or it just isn't making you happy ☹️ then just undock it with:\n\n```sh\nnostromo undock \u003cname\u003e\n```\n\n### Command Tree Management\n\nMoving and copying command subtrees can be done easily using `nostromo` as well to avoid manual copy pasta with yaml. If you want to move command nodes around just use:\n\n```sh\nnostromo move cmd \u003csource\u003e \u003cdestination\u003e\n```\n\nwhere the source and destinations are expected to be key paths like `foo.bar`.\n\nYou can rename a node with:\n\n```sh\nnostromo rename cmd \u003csource\u003e \u003cname\u003e\n```\n\nNext up, you might want to copy entire nodes around, which can also be done between manifests using `copy`. Again use key paths for `source` and `destination` and `nostromo` will attempt to replicate the branch to the new location.\n\n```sh\nnostromo copy cmd \u003csource\u003e \u003cdestination\u003e\n```\n\nSo you've created an awesome suite of commands and you like to share, am I right? Well `nostromo` makes it super easy to create manifests with any set of your commands from the tree using the `detach` command. It lets you slice and dice your manifests by extracting out a command node into a new manifest.\n\n```sh\nnostromo detach \u003cname\u003e \u003ckey.path\u003e...\n```\n\nBy default, this removes the command nodes from the manifest but can be kept intact as well with the `-k` option. Additionally, detaching any command nodes from a docked manifest may have unwanted side effects when running `nostromo sync` again since the commands will likely be added back from the original source.\n\nSince `nostromo` updates manifests if the identifier is unique, there might be times you want to update the `yaml` files manually for whatever reason. In this case you can run the handy `uuidgen` command to update the identifier so you can push the manifest to others:\n\n```sh\nnostromo uuidgen \u003cname\u003e\n```\n\n### Themes\n\n`nostromo` now supports themes to make it look even more neat. There's 3 themes currently which can be set with:\n\n```sh\nnostromo set theme \u003cname\u003e\n```\n\nwhere valid themes include:\n\n- `default`: The basic theme and previous default\n- `grayscale`: Gray colored things are sometimes nice\n- `emoji`: The new default obviously\n\nEnjoy!\n\n🐳📑🍥🌞🍓🕖🕐💘🎵🌑🐻🐜📙💥👡🍈👝🎭🐄🌓🎏👔📁🍝🔼🕔💩🌒📥\n\n## \u003cimg align=\"left\" src=\"images/sulaco-drop-ship.png\" alt=\"sulaco\"\u003e\u0026nbsp;Credits\n\n- This tool was bootstrapped using [cobra](https://github.com/spf13/cobra).\n- Colored logging provided by [aurora](https://github.com/logrusorgru/aurora/v3).\n- Fan art supplied by [Ian Stewart](https://www.artstation.com/artwork/EBBVN).\n- Gopher artwork by [@egonelbre](https://github.com/egonelbre/gophers) and original by [Renee French](http://reneefrench.blogspot.com/).\n- File downloader using [go-getter](https://github.com/hashicorp/go-getter)\n\n## \u003cimg align=\"left\" src=\"images/facehugger.png\" alt=\"facehugger\"\u003e\u0026nbsp;Contributing\n\nContributions are what makes the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## \u003cimg align=\"left\" src=\"images/loader.png\" alt=\"loader\"\u003e\u0026nbsp;License\n\nDistributed under the MIT License.\n\n## If You ♥️ What We Do\n\n\u003ca href=\"https://www.buymeacoffee.com/pokanopapps\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" height=\"60\" width=\"217\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokanop%2Fnostromo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpokanop%2Fnostromo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpokanop%2Fnostromo/lists"}