Skip to main content

Linux bash aliases generator

Project description

topalias

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

topalias - Linux bash/zsh alias generator and statistics from command history, 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.

Add you awesome aliases to Insights topic or .bash_aliases example.

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

  • multiline command in history
  • 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/
  • find password and other sensitivity data in history and suggest clean (now print "Hint: add space ' ' before sensitive command in terminal for skip save current command in history!")

Please add you feature requests: https://github.com/CSRedRat/topalias/issues/new

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

GitHub Pages: https://csredrat.github.io/topalias/

Version history

We follow Semantic Versions.

Version 2.0.13

  • Fix encoding issue with zsh history file (#13, #17)
  • Fix .bash_aliases path definition (#16)

Version 2.0.0

  • Add zsh shell support (-z/--zsh flag)
  • Add version check (version/--version)
  • --filter flag exclude used alias from command top chart
  • --debug mode
  • -f change dot files search path
  • -c count suggestion parameter
  • Add "example" command for give aliases example
  • Add aliases usage statistic

Version 1.1.7

  • Build and publish working package

Version 0.1.0

  • Initial release

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-2.0.15.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

topalias-2.0.15-py2.py3-none-any.whl (23.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: topalias-2.0.15.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for topalias-2.0.15.tar.gz
Algorithm Hash digest
SHA256 288b3d496475f813c465d37494b51d6330507b4c1288402d425089f5da61f5ae
MD5 dd783ab3057ade9b29d793d0330f713a
BLAKE2b-256 b368f501743b14510b8c53379f71f1afab9c6d87489db93a01a820d5e57e0876

See more details on using hashes here.

File details

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

File metadata

  • Download URL: topalias-2.0.15-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for topalias-2.0.15-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 48cac0e2593ce5084a213de5b464305b588a86cd02f51a522ca5a28b0dc21bf4
MD5 237a6e602f93a21ca61308f6abfb2211
BLAKE2b-256 9f729514b880e744d2385916fc266d5480c1aa797b61e56325a8e54cfa88e355

See more details on using hashes here.

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