/xontrib-abbrevs

Command abbreviations. This expands input words as you type.

Primary LanguagePythonMIT LicenseMIT

Expands input words as you type in xonsh shell.

If you like the idea click ⭐ on the repo and tweet.

Installation

To install use pip:

xpip install xontrib-abbrevs
# or: xpip install -U git+https://github.com/xonsh/xontrib-abbrevs

Usage

This expands input words from abbrevs dictionary as you type. Adds abbrevs dictionary to hold user-defined "command abbreviations. The dictionary is searched as you type the matching words are replaced at the command line by the corresponding dictionary contents once you hit 'Space' or 'Return' key.

For instance a frequently used command such as git status can be abbreviated to gst as follows:

xontrib load abbrevs
abbrevs['gst'] = 'git status'
gst # Once you hit <space> or <return> 'gst' gets expanded to 'git status'.

one can set a callback function that receives current buffer and word to customize the expanded word based on context

abbrevs['ps'] = lambda buffer, word: "procs" if buffer.text.startswith(word) else word

It is also possible to set the cursor position after expansion with,

abbrevs['gp'] = "git push <edit> --force"

Credits

This package was created with xontrib template.