Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xonsh/xontrib-abbrevs

Command abbreviations. This expands input words as you type.
https://github.com/xonsh/xontrib-abbrevs

abbrev cli terminal xonsh xontrib

Last synced: about 1 month ago
JSON representation

Command abbreviations. This expands input words as you type.

Awesome Lists containing this project

README

        


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:

```bash
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:

```xsh
xontrib load abbrevs
abbrevs['gst'] = 'git status'
gst # Once you hit or '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

```xsh
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,

```xsh
abbrevs['gp'] = "git push --force"
```

## Credits

This package was created with [xontrib template](https://github.com/xonsh/xontrib-template).