selexec provides pipline selection the UNIX way. A simple example illustrates it best.
Let's say you want to edit a few Python files in your project tree, but you're not sure which ones you'd like to edit without seeing them. Normally, you might run the following:
$ find . -name '*.py'
eggs/bedevere.py
eggs/galahad.py
spam/lancelot.py
spam/robin.py
# oh, that's right, I wanted to edit galahad and lancelot
$ $EDITOR eggs/galahad.py spam/lancelot.py
There's a bit of extra typing in the second command, which involves re-typing the names of the files. Why not just select them from the already-produced list? With selexec, you can:
$ find . -name '*.py' | slxc | xargs $EDITOR
The slxc
command takes a list on standard input. It will then
bring up an interface which allows you to select one, many, or all
items in the list. Once the choice is made, the truncated list will be
echoed to standard output.
selexec is not limited to files only. Let's say you wanted to uninstall a couple plugins for pytest, but weren't sure of their names. It's pipeline time!
$ pip freeze | grep pytest | slxc | xargs pip uninstall --yes
As you can see, with selexec, you can save a lot of time avoiding retyping items you've already seen.
Enjoy using selexec!
The program can be run locally by following these steps. First install the requirements:
pip install -r requirements/dev.txt
Then run with the current directory on the PYTHONPATH
:
PYTHONPATH=$PWD python selexec/console/main.py
Tests are written using pytest and mock. To run unit tests and PEP8 enforcement, run:
shovel test_all
Continuous integration is provided by Travis-CI. Find the build status at https://secure.travis-ci.org/#!/seanfisk/selexec.
To view the test coverage report, run:
shovel coverage
Sean uses Emacs to edit code. To easily generate a tags file for Emacs, run:
shovel emacs_tags
This command uses Exuberant Ctags to generate a TAGS
file. Within Emacs, run M-x visit-tags-table
to load the generate
tags file. Then use ido-find-file-in-tag-files to find project files.
selexec is free software licensed under the GNU General Public License version 3.
selexec makes use of the following libraries/tools/services:
- Python programming language
- git version control system
- GitHub for git hosting
- pytest test framework
- mock for creating mock objects
- coverage.py and pytest-cov for test coverage statistics
- pep8 for enforced PEP8 compliance
- Travis-CI for continuous integration
- Sphinx and docutils for documentation generation
- shovel for running miscellaneous tasks
selexec is inspired by the vipe tool in moreutils that allows a user to insert a text editor into a pipe. It can be used for much the same purpose with somewhat greater hassle:
$ find . -name '*.py' | vipe | xargs $EDITOR
...which would allow me to edit a list of files I'd like to open in my editor before actually opening them.