Skip to main content

Contributors Forks Stargazers Issues MIT License


Acronym

A smart alias management system to shorten your shell commands.
Explore the docs »

Report Bug · Request Feature

Elevator pitch

alias is a POSIX shell command that replaces a single word with a string. As linuxize describes about alias:

If you often find youself typing a long command on the terminal, then you will find bash aliases handy... Bash aliases are essentially shortcuts that can save you from having to remember long commands and eliminate a great deal of typing when you are working on the command line.

So aliases are no doubt a boon for productive shell usage. The problem acronym attempts to solves is the difficulty keeping track of what aliases you've defined in your possibly long shell configuration, and the difficulty maintaining a consistent naming pattern.

Acronym solves this by greatly simplifying the process of defining new aliases in a standard and efficient way. Instead of having to edit your shell configuration, pick a memorable name that doesn't conflict with other aliases, and add the alias command, you would simply use the acronym add invocation to automatically use the command's acronym, or see usage for greater versatility.

Demonstration

This demo showcases how a very long command with sudo and specific flags can be easily shortened to a two letter alias.

https://user-images.githubusercontent.com/68311366/179607402-bbbd1114-0cf8-4aa3-b20d-1b6989ee0e26.mp4

The best way to do this example without acronym in my opnion is:

echo 'alias pu="sudo pacman -Syu --noconfirm --color=auto"' >> /path/to/aliases.sh

To view them, cat /path/to/aliases.sh, where the output is in the format

alias a="b"
alias m="n"
alias x="y"

And while this was the system I used before writing this tool, acronym allows for much needed abstraction. Note that the acronym commands come pre-registered for convenience, so to add an alias is aa x, to change the alias name is ac x with y, to remove it is ar y, and to print your aliases in toml format is ap, where the output is in the format

[acronym]
aa = "acronym add"
ar = "acronym rm"
ae = "acronym edit"
...

[pacman]
pu = "sudo pacman -Syu --noconfirm --colo=auto"

Installation

  1. Install package
  • With pip:

pip install acronym-alias

  • With AUR helper:

yay -S acronym

  1. Source the aliases in shellrc
  • With install script

acronym install

  • Manually edit rc (use pip show acronym to find install dir, which is either under ~/.local/lib/... or /usr/lib/...)

. ~/.local/lib/python3.10/site-packages/acronym/data/aliases.sh

If you're using zsh and want completion, add this line too:

fpath+=(~/.local/share/zsh/site-functions)

Usage

Usage: acronym [OPTIONS] COMMAND [ARGS]...

Note: The main file, aliases.toml, is structured as the following:

[jupyter]
jn = "jupyter notebook"
jl = "jupyter lab"

Where [jupyter] is the section, jn is the alias, and "jupyter notebook" is the command.

Options:
  add ... --flags    Include command line flags in auto-generated acronym.
  rm ...  --section  Delete whole sections instead of aliases from aliases.toml.
  -h, --help       Show this message and exit.


Commands:
  add       Add provided CMD with auto-generated alias, or add multiple with comma seperation.
            Keywords: "CMD as ALIAS" to give custom ALIAS.
                      "CMD under SECTION" to give custom SECTION for organization purposes.
            See usage examples for more explaination.
  rm        Remove provided aliases.
  edit      Directly edit aliases.toml with $EDITOR.
  change    Change OLD alias name with NEW.
  suggest   Suggest pre-defined aliases based on shell command history.
  print     Pretty print given sections of aliases.toml, or print all contents
            if no args given.


Usage Examples:
  Add "git reset --hard" as an acronymed alias (ignoring flags)
  $ acronym add git reset --hard
  gr = "git reset --hard"

  Add cmd (including flags) using "--flags" flag
  $ acronym add git reset --hard --flags
  grh = "git reset --hard"

  Add cmd with custom alias name "greset" using "as" keyword
  $ acronym add git reset --hard as greset
  greset = "git reset --hard"

  Add cmd under section "etc", instead of section "git" using "under" keyword
  $ acronym add git reset --hard under etc
  gr = "git reset --hard"

  Add multiple aliases by comma seperation (with same rules as above)
  $ acronym add git reset --hard --flags, jupyter notebook
  grh = "git reset --hard"
  jn = "jupyter notebook"

  Remove aliases "gc" and "asdf"
  $ acronym rm gc asdf

  Remove sections "jupyter" and "etc"
  $ acronym rm jupyter etc --section

  Edit the configuration file
  $ acronym edit

  Replace alias "gr" to "greset" without changing its command
  $ acronym change gr with greset

  Get suggestions for more aliases based on shell history file
  $ acronym suggest

  Print sections "pip" and "apt"
  $ acronym print pip apt
  [pip]
  ...

  [apt]
  ...

Metadata

Release files for acronym-alias 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for acronym-alias 0.1.0
File Size Uploaded
acronym-alias-0.1.0.tar.gz 953.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for acronym-alias 0.1.0
File Interpreter ABI Platform
acronym_alias-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 968.2 kB

Release files / acronym-alias-0.1.0.tar.gz

Download URL acronym-alias-0.1.0.tar.gz
Size 953.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f8f9f63739951e2df312ef4d5da5c7878e09fa775f8f9b14a84052d2208f07f2
BLAKE2b-256 checksum
How to use checksums
07f8e57a2e4bd38bfc3eb4771b32fb5cc625ab77d854b6d196836579ce0ea052
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.1

Release files / acronym_alias-0.1.0-py3-none-any.whl

Download URL acronym_alias-0.1.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
057951ee3cf08a158ca8563ab593224fb539f3beae83ecfee0399b7102dd3423
BLAKE2b-256 checksum
How to use checksums
fa3d20cf6777507b1c078f0f22c877daa88d1de559b4ffde4ff91c7cfd1f785b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.27.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page