Locate Args and Execute

Overview

Lax

An argument substitution utility intended to make working on projects with deeply nested directories a bit easier.

"Lax" stands for "Locate Args and Execute."

Basic Usage

Given a binary and an "@" pattern "@foo", Lax will will find the file "foo" and replace "@foo" with "foo"'s full path, then execute the binary with the new arguments

lax echo @foo -> echo ./foobar/foo

Multiple "@" patterns's are possible:

lax stat @foo @bar @baz -> stat ./foobar/foo ./foobar/target/bar ./foobar/src/baz

Mixing and matching "@" patterns and normal arguments is also possible:

lax cat -n @foo bar @baz -> cat -n ./foobar/foo bar ./foobar/src/baz

Globbing

Globbing is fully supported via globset.

lax echo @*.rs -> echo ./some/directory/main.rs

** is also supported, but is treated specially. The portion of the pattern before the first /**/(note the surrounding slashes) is the search entry point. That is, given a pattern like @foo/**/bar, Lax will look in the directory ./foo for a file that matches bar. Any following ** are handled normally:

lax echo @foo/**/bar/**/baz

Will look in directory ./foo for a path that matches bar/**/baz. That is, any entity baz that is a descendent of directory bar.

Making use of the search entry point can speed up searches if you know which top-level subdirectory your query is in, but you don't want to cd into it for whatever reason. It can also be used to specify a path outside your directory.

Selectors

If there are multiple files matching the given name, Lax will prompt you to choose.
However, you can also specify which file you'd want ahead of time:

lax echo @*.rs^1 # Select the first match  
lax echo @*.rs^2 # Select the second match  
lax echo @*.rs^a # Expand to all matches

Now you know the full syntax for "@" patterns:

@[SEARCH_ENTRY_POINT/**/]GLOB_PATTERN[^SELECTOR]

Where SEARCH_ENTRY_POINT is a directory, GLOB_PATTERN is a glob pattern, and SELECTOR is [1..n|'a']

Primary Use Case

In your .bashrc, you can write alias vim="lax vim"

From now on, you can just write:

vim @foo -> vim ./foobar/foo

This makes working on projects with deep directories, like U-Boot and Yocto, easier. If the compiler complains about an error in my_stupid_little_c_file.c, you can:

vim @*stupid*file.c

Using With cd

You might try to use Lax to do things like:

lax cd @some_deep_nested_subdirectory

But you will quickly discover this does not work as intended, as cd is affecting the current directory of its environment, which belongs to a child process of the shell.

Instead, you can add this to your .bashrc:

cd(){
	local args;
	if ! args=$(lax -pd -- ${@}); then
		return 1
	fi
	command cd ${args}
}

The -p flag tells Lax to not execute anything, but simply transform arguments and print them to stdout. The -d flag tells it to only match with directories, as cd has no interest in files. You could also use the -D flag if you want to match files, but cd to their parent directory, instead.

Installing

git clone [email protected]:Property404/lax
cargo install --path lax

License

MIT or Apache-2.0

You might also like...
💥 Fast State-of-the-Art Tokenizers optimized for Research and Production
💥 Fast State-of-the-Art Tokenizers optimized for Research and Production

Provides an implementation of today's most used tokenizers, with a focus on performance and versatility. Main features: Train new vocabularies and tok

Rust native ready-to-use NLP pipelines and transformer-based models (BERT, DistilBERT, GPT2,...)

rust-bert Rust native Transformer-based models implementation. Port of Hugging Face's Transformers library, using the tch-rs crate and pre-processing

👄 The most accurate natural language detection library in the Rust ecosystem, suitable for long and short text alike
👄 The most accurate natural language detection library in the Rust ecosystem, suitable for long and short text alike

Table of Contents What does this library do? Why does this library exist? Which languages are supported? How good is it? Why is it better than other l

Semantic text segmentation. For sentence boundary detection, compound splitting and more.

NNSplit A tool to split text using a neural network. The main application is sentence boundary detection, but e. g. compound splitting for German is a

A fast, low-resource Natural Language Processing and Text Correction library written in Rust.

nlprule A fast, low-resource Natural Language Processing and Error Correction library written in Rust. nlprule implements a rule- and lookup-based app

Rust-tokenizer offers high-performance tokenizers for modern language models, including WordPiece, Byte-Pair Encoding (BPE) and Unigram (SentencePiece) models

rust-tokenizers Rust-tokenizer offers high-performance tokenizers for modern language models, including WordPiece, Byte-Pair Encoding (BPE) and Unigra

Read and modify constituency trees in Rust.

lumberjack Read and process constituency trees in various formats. Install: From crates.io: cargo install lumberjack-utils From GitHub: cargo install

Simple, extendable and embeddable scripting language.

duckscript duckscript SDK CLI Simple, extendable and embeddable scripting language. Overview Language Goals Installation Homebrew Binary Release Ducks

Fast and easy random number generation.

alea A zero-dependency crate for fast number generation, with a focus on ease of use (no more passing &mut rng everywhere!). The implementation is bas

Releases(0.2.0)
Owner
Dagan Martinez
There are a lot of incomplete projects on my profile - don't mind them. They're harmless as long as they're not...disturbed
Dagan Martinez
A simple and fast linear algebra library for games and graphics

glam A simple and fast 3D math library for games and graphics. Development status glam is in beta stage. Base functionality has been implemented and t

Cameron Hart 953 Jan 3, 2023
A Markdown to HTML compiler and Syntax Highlighter, built using Rust's pulldown-cmark and tree-sitter-highlight crates.

A blazingly fast( possibly the fastest) markdown to html parser and syntax highlighter built using Rust's pulldown-cmark and tree-sitter-highlight crate natively for Node's Foreign Function Interface.

Ben Wishovich 48 Nov 11, 2022
Text calculator with support for units and conversion

cpc calculation + conversion cpc parses and evaluates strings of math, with support for units and conversion. 128-bit decimal floating points are used

Kasper 82 Jan 4, 2023
A command-line tool and library for generating regular expressions from user-provided test cases

Table of Contents What does this tool do? Do I still need to learn to write regexes then? Current features How to install? 4.1 The command-line tool 4

Peter M. Stahl 5.8k Dec 30, 2022
Find and replace text in source files

Ruplacer Find and replace text in source files: $ ruplacer old new src/ Patching src/a_dir/sub/foo.txt -- old is everywhere, old is old ++ new is ever

Tanker 331 Dec 28, 2022
An efficient and powerful Rust library for word wrapping text.

Textwrap Textwrap is a library for wrapping and indenting text. It is most often used by command-line programs to format dynamic output nicely so it l

Martin Geisler 322 Dec 26, 2022
An implementation of regular expressions for Rust. This implementation uses finite automata and guarantees linear time matching on all inputs.

regex A Rust library for parsing, compiling, and executing regular expressions. Its syntax is similar to Perl-style regular expressions, but lacks a f

The Rust Programming Language 2.6k Jan 8, 2023
Rust edit distance routines accelerated using SIMD. Supports fast Hamming, Levenshtein, restricted Damerau-Levenshtein, etc. distance calculations and string search.

triple_accel Rust edit distance routines accelerated using SIMD. Supports fast Hamming, Levenshtein, restricted Damerau-Levenshtein, etc. distance cal

Daniel Liu 75 Jan 8, 2023
Web 3.0 Realized with Traceless Privacy and Seamless Compatibility

Automata Build On Ubuntu/Debian (or similar distributions on WSL), install the following packages: sudo apt-get update sudo apt-get install -y build-e

Automata Network 81 Nov 29, 2022
Text Expression Runner – Readable and easy to use text expressions

ter - Text Expression Runner ter is a cli to run text expressions and perform basic text operations such as filtering, ignoring and replacing on the c

Maximilian Schulke 72 Jul 31, 2022