A smart alias management system to shorten your shell commands.
Project description
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.
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
- Install package
- With pip:
pip install acronym-alias
- With AUR helper:
yay -S acronym
- 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]
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file acronym-alias-0.1.0.tar.gz
.
File metadata
- Download URL: acronym-alias-0.1.0.tar.gz
- Upload date:
- Size: 953.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8f9f63739951e2df312ef4d5da5c7878e09fa775f8f9b14a84052d2208f07f2 |
|
MD5 | 9e13ae6f3b6ef6d5b5ec9d187ce72749 |
|
BLAKE2b-256 | 07f8e57a2e4bd38bfc3eb4771b32fb5cc625ab77d854b6d196836579ce0ea052 |
File details
Details for the file acronym_alias-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: acronym_alias-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.27.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 057951ee3cf08a158ca8563ab593224fb539f3beae83ecfee0399b7102dd3423 |
|
MD5 | b31e64699de1d2732f9f4ba59a2f45da |
|
BLAKE2b-256 | fa3d20cf6777507b1c078f0f22c877daa88d1de559b4ffde4ff91c7cfd1f785b |