2024-11-24 12:23:00
github.com
lla
is a high-performance, extensible alternative to the traditional ls
command, written in Rust. It offers enhanced functionality, customizable output, and a plugin system for extended capabilities.
- Efficient file listing: Optimized for speed, even in large directories
- Multiple view modes:
- Default view
- Long format (
-l
) - Tree view (
-t
) - Recursive listing (
-R
)
- Advanced sorting:
- Alphabetical (default)
- File size (
-s size
) - Modification date (
-s date
)
- Flexible filtering: Filter by filename or extension (
-f, --filter
) - Customizable recursion: Set maximum depth for subdirectory traversal
- Extensible plugin system: Develop and integrate custom functionality
- Color-coded output: Easily distinguish file types and permissions
- Git integration: Show git status for files (with plugin)
- File categorization: Categorize files by type (with plugin)
- Keyword search: Search file contents for specified keywords (with plugin)
- File hash display: Show file hashes (with plugin)
- Code complexity analysis: Analyze code complexity (with plugin)
- File size visualization: Visualize file sizes (with plugin)
- Duplicate file detection: Identify duplicate files (with plugin)
- Directory metadata: Display detailed directory information (with plugin)
- File metadata: Show extended file metadata (with plugin)
- Last git commit info: Display information about the last git commit (with plugin)
and more!
(we see you, netbsd. we appreciate you.)
First you need to initialize the configuration file:
lla init
lla config # to view the config file
Then you can start using lla
:
lla [OPTIONS] [DIRECTORY]
-l, --long
: Use long listing format-R, --recursive
: List subdirectories recursively-t, --tree
: Display files in a tree structure-s, --sort
: Sort by “name”, “size”, or “date”-f, --filter
: Filter files by name or extension-d, --depth
: Set maximum recursion depth
--enable-plugin
: Enable a specific plugin--disable-plugin
: Disable a specific plugin--plugins-dir
: Specify custom plugins directory--plugin-arg
: Pass arguments to enabled plugins
lla
supports plugin-specific actions, allowing you to interact with plugins directly:
lla plugin --name --action [--args ...]
--name
: Specify the name of the plugin--action
: Specify the action to perform--args
: Provide arguments for the action (optional)...
lla install
: Install plugins--git
: Install from a Git repository--dir
: Install from a local directory
lla list-plugins
: Display all available pluginslla init
: Initialize configuration filella config
: View configuration file
lla
uses a TOML configuration file located at ~/.config/lla/config.toml
. Initialize with default settings:
lla init
lla config # to view the config file
Example configuration:
default_sort = "name"
default_format = "default"
enabled_plugins = ["git_status", "file_hash"]
plugins_dir = "/home/user/.config/lla/plugins"
default_depth = 3
You can install plugins from a local directory or from a Git repository.
You can find official plugins here.
lla install --git github_url>
Develop custom plugins to extend lla
‘s functionality. Plugins are dynamic libraries that implement the Plugin
trait from the lla_plugin_interface
crate.
-
Create a new Rust library:
cargo new --lib my_lla_plugin
-
Add dependencies to
Cargo.toml
:[dependencies] lla_plugin_interface = "*" [lib] crate-type = ["cdylib"]
-
Implement the
Plugin
trait:
use lla_plugin_interface::{Plugin, DecoratedEntry, EntryDecorator, CliArg};
pub struct MyPlugin;
impl Plugin for MyPlugin {
fn name(&self) -> &'static str {
"my_plugin"
}
fn version(&self) -> &'static str {
env!("CARGO_PKG_VERSION")
}
fn description(&self) -> &'static str {
env!("CARGO_PKG_DESCRIPTION")
}
fn cli_args(&self) -> VecCliArg> {
vec![
CliArg {
name: "my-option".to_string(),
short: Some('m'),
long: Some("my-option".to_string()),
help: "Description of my option".to_string(),
takes_value: true,
}
]
}
fn handle_cli_args(&self, args: &[String]) {
// Handle CLI arguments passed to the plugin
}
fn perform_action(&self, action: &str, args: &[String]) -> Result(), String> {
match action {
"my-action" => {
// Perform custom action
Ok(())
}
_ => Err(format!("Unknown action: {}", action)),
}
}
}
impl EntryDecorator for MyPlugin {
fn decorate(&self, entry: &mut DecoratedEntry) {
// Add custom fields or modify entry
}
fn format_field(&self, entry: &DecoratedEntry, format: &str) -> OptionString> {
// Return formatted string for display
}
fn supported_formats(&self) -> Vec&'static str> {
vec!["default", "long", "tree"]
}
}
lla_plugin_interface::declare_plugin!(MyPlugin);
-
Build your plugin:
-
Install the plugin:
lla install --dir /path/to/my_lla_plugin
or
lla install --git git_repo>
The lla_plugin_interface
crate provides the following key components:
Plugin
trait: Core interface for plugin functionalityEntryDecorator
trait: Methods for decorating and formatting file entriesDecoratedEntry
struct: Represents a file entry with metadata and custom fieldsCliArg
struct: Defines command-line arguments for the plugin
# Long format, sorted by size, showing only .rs files
lla -ls size -f .rs
# Enable git status plugin
lla --enable-plugin git_status
# Enable multiple plugins
lla --enable-plugin git_status categorizer
# Disable git status plugin
lla --disable-plugin git_status
# Disable multiple plugins
lla --disable-plugin git_status categorizer
# Set keywords for the keyword search plugin using plugin action
lla plugin --name keyword_search --action set-keywords --args "TODO" "FIXME" "BUG"
# Show current keywords for the keyword search plugin
lla plugin --name keyword_search --action show-keywords
# Use the keyword search plugin with the set keywords
lla --enable-plugin keyword_search
Contributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features.
- Fork the repository
- Create your feature branch (
git checkout -b feature/new-feature
) - Commit your changes (
git commit -m 'Add some new-feature'
) - Push to the branch (
git push origin feature/new-feature
) - Open a Pull Request
This project is licensed under the MIT License – see the LICENSE file for details.
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.