Skip to content

A powerful command-line tool for managing ZSH aliases, written in Swift.

License

Notifications You must be signed in to change notification settings

OCA-Creations/Ally

Repository files navigation

Ally Logo

Ally - ZSH Alias Manager

Love the terminal again! Ally removes the need to repeatedly write long commands, and insteadaliases them to much shorter ones.

To install with a one-liner (inspired byHomebrew):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent /OCA-Creations/Ally/main/install.sh)"

Overview

Ally is meant to functionexactlylike the ZSHaliascommand, except with afewsuperpowers. This means that the invocation is exactly the same:

alias helloworld='echo "Hello, World\!" '
# Same thing below!
ally helloworld='echo "Hello, World\!" '

However, there is one key difference:

Allypersistsaliases

That is the whole point. Ally adds the aliases not to the local terminal session, but rather to the user's.allyfile, which is thensourced in the ZSHRC. This means that, while the behavior ofallyis the same asaliasfor a terminal session, the aliases remain throughout sessions! In the example above, if a user were to open a new tab having only runaliasin the original, they would see:

alias helloworld='echo "Hello, World\!" '
[NEW TERMINAL SESSION]


❯ helloworld
zsh: command not found: helloworld

However, if the user had runallyinstead:

ally helloworld='echo "Hello, World\!" '
[NEW TERMINAL SESSION]


❯ helloworld
Hello, World!

🚧 WARNING 🚧

This project is functional, but is⚠️⚠️NOT YET READY FOR USE! You might damage your system or config by running it! Ally is much more reliable than it was when first started, but still occasionally will exhibit unexpected behavior. The only documented example of this currently is in theinitcommand, which will overwrite the existing.allyfile if invoked again on a system with an existing install.

Installation

One-liner (inspired byHomebrew):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent /OCA-Creations/Ally/main/install.sh)"

Note

The one-liner above assumes this install isnotintended to be used for development of the Ally tool itself. Also, if you already have a directory namedAllyin the location in which you are running the script, then install will fail with the following error:

fatal: destination path 'Ally' already exists and is not an empty directory.

If you wish to install for development, follow the steps below:

  1. Download + Build the project (git cloneandswift buildin the folder)
  2. Locate the built executable and move it to the desired location.
  3. Run the executable with the parameterinit.
  4. Keep developing and buildingallyin the original directory - you may want to use it to add an alias to the Derived Data build!

This tool was hacked in a night - it is still being developed! It is actively in progress, and is currently used, but needs work!

Some ideas/todos (strikethrough indicates complete):

  • ally dotwill open the.ally file
  • ally edit ALIAS "OLD_COMMAND"will edit an alias
    • The old command may not need to be in quotes.
  • Allow equals signs:ally add test=echois as valid asally add test 'echo'.
  • ally install --reinstallwill reinstall and format the dotfile
  • ally dot formatwill format the dotfile
  • Can we call things likeally initfrom a Swift file with pure Swift? Call the class directly?
  • ally zshrcwill transfer all current aliases to the.zshrc
  • Improve the quality and organization of the project
  • Improve command docs
  • ally listwill print a list of aliases
  • ally add ALIAS "OLD_COMMAND" -docs "DOCS"will let the user add documentation for an alias (stored in a comment on the line above.)
  • Support bash and fish shells.
  • Currently, reload doesn't do anything. Can we fix this or remove it altogether?
    • Being worked on - see#8
  • Currently, quotes need to be escaped. Can we auto-escape them?
  • When installing, if--reinstallis not specified, don't overwrite the.ally file!
  • Should we rename to something other than.ally?
  • Should we have a custom file format likehttps://github /DannyBen/alf
  • Check outhttps://github /DannyBen/bashly
  • Should this be public? How can we improve it first?
  • Add an sh install script for oneliner install.
  • Add tests (and allow custom directories to be inputted for them)?
  • Allow the user to add a custom name for ally?ally name CUSTOM_NAME?
  • Improve code and args for all commands.
  • Add docs.
  • Add a man page? (#2
  • Convert all of these notes into issues on GitHub.
  • Should we have automatic alias generation based on frequently used commands?
  • Should we have a list of aliases that you can add?ally defaults DEFAULT_LIST_NAME?
  • ally debug -o OUTPUT_FILE_LOCATIONshould save a debug report (text file) for contributors to track bugs and other things.
  • Some ideas for defaults:
    • os-interopwill let you transport Windows or UNIX commands to your current OS. If you're on Windows, then this would enablels(dir),touch,etc. This would conversely enablediras a replacement forlson UNIX.
    • hacking- all the aliases and tools one needs to hack.
    • allyutilsorgeneralutils- these are things that make usingallyor the Terminal easier, such as areloadcommand that reloads everything -source $HOME_DIR/.ally,etc.
  • Improve verbosity, especially when adding a command. This could be specified with a degree of verbosity (like TensorFlow). We would need to warn users when entering aliases that already exist or aliasing over existing commands (see CommandRunner.swift to test out if a command already exists).
  • What if we allowed users to create their own CLI tools from scripts? So the user passes inally add SCRIPT.py(or another language), and then ally adds an alias for the script, and creates a CLI for it?
  • Add to PATH instead of an alias.
  • Save and restore backups of.allyfiles
    • Allow sharing + install of custom.allyfiles?
  • Allow another syntax inaddcommand:->
    • This would allow us to add things like:
    ally add getPID -> "ps aux | grep"
    
    • Mimics Swift function naming