Code Monkey home page Code Monkey logo

topalias's Introduction

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

topalias's People

Contributors

meteoritt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

topalias's Issues

TypeError: print_version() takes 2 positional arguments but 3 were given

  • topalias version: topalias-2.0.20
  • Python version: Python 3.10.9
  • Operating System:

Description

Just trying to test this out, do I need a lower version of python3?

What I Did

python3 -m topalias

My error:

  File "/Users/ari/Library/Python/3.10/lib/python/site-packages/click/core.py", line 2322, in process_value
    value = self.callback(ctx, self, value)
TypeError: print_version() takes 2 positional arguments but 3 were given

Click argument error

โฏ ./topalias.sh
Traceback (most recent call last):
  File "/mnt/build/software/topalias/topalias/cli.py", line 167, in <module>
    sys.exit(cli())  # pragma: no cover # pylint: disable=no-value-for-parameter
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1052, in main
    with self.make_context(prog_name, args, **extra) as ctx:
  File "/usr/lib/python3.9/site-packages/click/core.py", line 914, in make_context
    self.parse_args(ctx, args)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1615, in parse_args
    rest = super().parse_args(ctx, args)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 1370, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 2347, in handle_parse_result
    value = self.process_value(ctx, value)
  File "/usr/lib/python3.9/site-packages/click/core.py", line 2309, in process_value
    value = self.callback(ctx, self, value)
TypeError: print_version() takes 2 positional arguments but 3 were given
Report you great ideas and any feedback: https://github.com/CSRedRat/topalias/issues/new

Cool project. Looks like the Click api use is incorrect or has changed. Also, I think you mean 'your great ideas'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.