Skip to main content

Generate bash/zsh/fish shell aliases automatically.

Project description

ALIAS-GEN 𑗊

Screenshot

Shell aliases are shortcuts or abbreviations for commands that are used in a Unix/Linux shell. They can save you time if you have very long or complex commands that you frequently use. ALIAS-GEN is a script that will create bash/zsh/fish shell aliases automatically to simplify your command-line tasks.

This script will create bash/zsh/fish shell aliases automatically. You can generate a new alias file by following the prompts, or use the --stdout option to print results directly in your terminal.

Two types of aliases are suggested, the default algorithm matches all characters incrementally for each command, while the --use_min_alias algorithm aims to minimize the total length of characters per command. Additionally, --use_min_alias does not necessarily match all characters in the command.

The freq (frequency) column shows how often each command was used. For now, this script only generates aliases for the first word in a command. NOTE: Two character commands or less are not processed.

By default, fish shell generates abbr (abbreviations) rather than aliases.

Requirements

  • Python 3.6 or higher.
  • No dependences required for installation.

Install from pypi

pip install alias-gen

https://pypi.org/project/alias-gen/

CLI Usage

Full Help Menu:

aliaser -h

Example usage to generate the top 40 aliases:

aliaser -n 40

With stdout and min_alias:

aliaser --stdout --use_min_alias

The -s argument specifies the shell type. In this example, fish shell is used.

aliaser -s fish

The -f argument allows you to specify a custom history file path.

aliaser -s zsh -f ~/.custom_zsh_history

How does it work?

The alias column is generated by first sorting the most common commands found in the history file, then aliases are generated for commands more than two characters. These aliases just try to match character per character the given command and will continue with more characters if there is a previous common alias.

The min_alias column tries to minimize the total length of chars disregarding the rule of matching the command character per character. It is generated using the first char of the command always, followed by easy to reach keyboard characters defined as QUERTY layout middle row, top row, then bottom row.

Misc

I recommend using this script along with other shell plugins that help you remember your alias or abbreviation. One example for fish shell is fish-abbreviation-tips.

Buy me a coffee

Hope you found this project helpful, consider buying a coffee to show your support.

Buy Me A Coffee

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alias_gen-0.6.7.tar.gz (8.8 kB view hashes)

Uploaded Source

Built Distribution

alias_gen-0.6.7-py2.py3-none-any.whl (9.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page