package

github.com/harishtpj/hsh

master / published Jul 14, 2025 / repository

A simple portable shell

hsh

A simple, portable shell written in Crystal with cross-platform compatibility for Linux and Windows.

Features

  • ๐Ÿš€ Cross-platform support: Works on both Linux and Windows
  • ๐Ÿ“ Path completion: Intelligent path completion for enhanced productivity
  • ๐Ÿ”ง Built-in commands: Supports essential commands like ls and more
  • ๐Ÿ’Ž Crystal-powered: Built with Crystal for performance and reliability
  • ๐ŸŽฏ Minimal compatibility: Designed to work seamlessly across different operating systems

Installation

Prerequisites

  • Crystal language (>= 1.16.3)

Building from Source

git clone https://github.com/harishtpj/hsh.git
cd hsh
shards install
crystal build src/hsh.cr

Running

./hsh

Usage

Once you start hsh, you'll be presented with an interactive shell prompt. The shell supports:

Built-in Commands

  • ls - List directory contents
  • Standard shell navigation and file operations
  • Cross-platform path handling

Path Completion

Press Tab to auto-complete file and directory paths. The completion system works intelligently across both Linux and Windows path formats.

Example Session

hsh> ls
[directory contents]

hsh> cd /path/to/directory
hsh> ls *.cr
[Crystal files]

Development

Project Structure

src/
โ”œโ”€โ”€ hsh.cr              # Main entry point
โ”œโ”€โ”€ hsh/
โ”‚   โ”œโ”€โ”€ builtins/       # Built-in commands
โ”‚   โ”‚   โ””โ”€โ”€ ls.cr       # ls command implementation
โ”‚   โ”œโ”€โ”€ errors.cr       # Error handling
โ”‚   โ”œโ”€โ”€ executor.cr     # Command execution
โ”‚   โ”œโ”€โ”€ helpers.cr      # Utility functions
โ”‚   โ”œโ”€โ”€ repl.cr         # Read-Eval-Print Loop
โ”‚   โ””โ”€โ”€ version.cr      # Version information
โ””โ”€โ”€ spec/               # Test files

Dependencies

  • shellwords - Shell word parsing
  • reply - REPL functionality
  • phreak - Additional shell utilities

Running Tests

crystal spec

Development Setup

  1. Install dependencies:

    shards install
  2. Run in development mode:

    crystal run src/hsh.cr
  3. Build for production:

    crystal build --release src/hsh.cr

Roadmap

Current Features (v0.1.0)

  • โœ… Basic shell functionality
  • โœ… Path completion
  • โœ… Cross-platform compatibility (Linux/Windows)
  • โœ… Built-in ls command

Planned Features

  • ๐Ÿ”„ Enhanced built-in commands: cat, cd, mkdir, rm, cp, mv
  • ๐Ÿ”„ Improved path completion: Better fuzzy matching and context awareness
  • ๐Ÿ”„ User-friendly features:
    • Command history
    • Syntax highlighting
    • Better error messages
    • Configuration file support
  • ๐Ÿ”„ Advanced features:
    • Job control
    • Environment variable management
    • Script execution
    • Pipe and redirection support

Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

How to Contribute

  1. Fork it (https://github.com/harishtpj/hsh/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Areas for Contribution

  • Adding new built-in commands
  • Improving path completion algorithms
  • Enhancing cross-platform compatibility
  • Writing tests and documentation
  • Performance optimizations

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributors

API

  • Hsh

    Metainfo and other global configs