Skip to main content

Linux bash alias generator

Project description

topalias

Test Status Coverage GitLab pipeline Python Version Downloads Code style: black Imports: isort DeepSource

topalias - Linux alias generator from bash/zsh command history with statistics, written on Python.

Features

  • Generate short alias for popular command from bash/zsh shell history
  • Command history statistics & analytics
  • Parametrised input
  • Console help for all commands, options and arguments
  • Shell workflow hints

Installation

From pypi.org repository:

pip3 install -U --user topalias

From source:

git clone https://github.com/CSRedRat/topalias
python3 topalias/setup.py install --user

Run as python script without install:

git clone https://github.com/CSRedRat/topalias
python3 topalias/topalias/cli.py -h

Install requirements

sudo apt install python3 python3-pip -y

Add PATH environment variable for run Python tools as Linux utility:

echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
source ~/.bashrc

Usage

generated bash aliases

Without parameters utility check if you use alias in ~/.bash_aliases - analyze and print usage statistics, then find new simple aliases

python3 -m topalias  # run as python module
topalias  # check aliases and print suggestion bash command history
topalias -h  # print help
topalias --zsh  # work with zsh shell command history
topalias --min=2  # set minimal length for generated acronym filter, so that exclude some short command and find long, hard, usable command
topalias --debug history  # only analyze local bash history and print filtered rows

Files path search order:

  • directory from execution parameter
  • .bash_history in . current directory
  • .bash_history in ~ user home directory
  • example development files in topalias/data

You can change dot files search path to another user home directory:

topalias -f /home/user  # or topalias --path /home/user

Also you can use topalias utility in Bash for Git on Windows and in WSL.

Documentation

Usage: topalias [OPTIONS] COMMAND [ARGS]

Options:
  -l, --min INTEGER     Print alias acronym not less that value. Default: 1
  -c, --count INTEGER   Print specified number acronym suggestions. Default:
                        20

  --filter              Filter used aliases in history. Default: False
  -z, --zsh             Use zsh shell history file .zsh_history. Default:
                        False

  -f, --path TEXT       Change custom directory for files: .bash_aliases,
                        .bash_history, .zsh_history

  --version             Print current program version and check latest on
                        pypi.org.

  --debug / --no-debug  Enable debug strings in output.
  -h, --help            Show this message and exit.

Commands:
  hint     Print all hints.
  history  Print bash history file.
  version  Get program current and available version.

TODO

  • check if alias name already used
  • check if alias already added
  • add any another acronym algorithm with semantic
  • more statistics & analytics (used dir, utils, parameters, time)
  • alias max length parameter
  • command ignore list flag: top, emacs, vim
  • often used command "ssh username@servername" suggest add to .ssh/config/

License

GPLv3

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Sergey Chudakov

💻 🚇 🤔 🚧 📦

Sergey Morozik

🚧 📦💻

GitLab repository mirror with CI/CD: https://gitlab.com/CSRedRat/topalias

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

topalias-4.0.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

topalias-4.0.0-py2.py3-none-any.whl (32.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file topalias-4.0.0.tar.gz.

File metadata

  • Download URL: topalias-4.0.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for topalias-4.0.0.tar.gz
Algorithm Hash digest
SHA256 4f50707d81a1db79d405556439556383de7aae4524308ec6cbec066c973a29e9
MD5 6e6af10cde512562410e046094e7925f
BLAKE2b-256 d687b6f70223908d8aa9444757ef8e2630039d98ba9f645f0dca6d61807a8196

See more details on using hashes here.

File details

Details for the file topalias-4.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: topalias-4.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2

File hashes

Hashes for topalias-4.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 650f604dab13645cdf02837a60e760a09a31d1bc2e2f2ea9ebe5ed91145be73f
MD5 e8b5e50f3fa8c7428fada8a7992d8716
BLAKE2b-256 e5f488bf53db0a3da1cb3a83073d9b3053387e3038e7b435b5ec2df53fc6643a

See more details on using hashes here.

Supported by

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