Project

sergeant

0.0
No release in over 3 years
Sergeant (sgt) is an interactive terminal user interface (TUI) for navigating directories and managing files. Navigate with arrow keys, preview files, copy, move, and organize - all from your terminal.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 3.13
~> 1.81

Runtime

~> 1.4
 Project Readme

๐ŸŽ–๏ธ Sergeant (sgt)

Sergeant Logo

Interactive TUI Directory Navigator for Terminal - "Leave it to the Sarge!"

Sergeant is a interactive terminal user interface (TUI) for navigating directories and managing files. Instead of typing cd and file manipulation commands, just run sgt, use arrow keys and keyboard shortcuts to navigate, preview, copy, move, and organize your files. Simple, fast, and elegant.

โœจ Features

Navigation & Display

  • ๐Ÿ—‚๏ธ Visual Directory Navigation - See all directories and files at a glance
  • โŒจ๏ธ Keyboard Driven - Arrow keys, vim bindings (hjkl), and shortcuts
  • ๐ŸŽจ Color-Coded Display - Directories in cyan, files grayed out
  • ๐Ÿ“Š Smart Scrolling - Handles directories with hundreds of items
  • ๐Ÿ” Git Branch Display - Shows current git branch in header
  • ๐Ÿ‘ค Ownership Toggle - View file permissions and ownership (press 'o')
  • ๐Ÿ“‘ Bookmarks - Save and quickly navigate to favorite directories

File Operations

  • ๐Ÿ“‹ Copy/Cut/Paste - Mark files with spacebar, copy (c), cut (x), and paste (p)
  • โœ‚๏ธ Multi-file Selection - Mark multiple files/folders for batch operations
  • ๐Ÿ—‘๏ธ Delete with Confirmation - Safe deletion with confirmation dialog
  • โœ๏ธ Rename - Rename files and folders with pre-filled input
  • ๐Ÿ”„ Conflict Resolution - Smart handling of file conflicts (skip/overwrite/rename)
  • ๐Ÿ“„ File Preview - View markdown files with glow, code files with vim/nano

Search & Productivity

  • ๐Ÿ”Ž Fuzzy Search - Integrate with fzf for fast file finding
  • โ“ Help Modal - Press 'm' for comprehensive key mapping reference
  • ๐Ÿš€ Instant CD - Select and change directory in one smooth motion

๐Ÿ“‹ Requirements

  • Ruby 2.7 or higher (Ruby 3.x recommended)

System Dependencies

The curses gem (installed automatically) requires native libraries:

macOS:

# Usually works out of the box
# If you get errors, install Xcode Command Line Tools:
xcode-select --install

# Recommended: Use Homebrew Ruby instead of system Ruby
brew install ruby
# Add to ~/.zshrc: export PATH="/opt/homebrew/opt/ruby/bin:$PATH"

Linux (Debian/Ubuntu):

sudo apt-get install libncurses-dev ruby-dev

Linux (Fedora/RHEL):

sudo dnf install ncurses-devel ruby-devel

Optional Tools

  • glow - For beautiful markdown preview (brew install glow or go install github.com/charmbracelet/glow@latest)
  • fzf - For fuzzy file search (brew install fzf or sudo apt-get install fzf)

๐Ÿš€ Installation

Install from RubyGems (Coming Soon)

Once published to RubyGems:

gem install sergeant

Install from Source

# Clone the repository
git clone https://github.com/biscoitinho/Sergeant.git
cd Sergeant

# Build and install the gem locally
gem build sergeant.gemspec
gem install ./sergeant-1.0.0.gem

That's it! The sgt command will automatically be added to your PATH.

Development Installation

If you want to work on the gem:

# Clone and setup
git clone https://github.com/biscoitinho/Sergeant.git
cd Sergeant

# Install dependencies
bundle install

# Run directly without installing
bundle exec bin/sgt

๐ŸŽฎ Usage

Basic Navigation

# Start sergeant in current directory
sgt

# Navigate and select
# Arrow keys or j/k to move up/down
# Enter or l to enter directory
# h to go back
# q to quit and cd to selected directory

File Operations

Key Action
Space Mark/unmark item for operations
c Copy marked items
x Cut marked items
p Paste copied/cut items
d Delete marked items (with confirmation)
r Rename current item
u Unmark all items
v Preview file (markdown/code)

Other Commands

Key Action
โ†‘/k Move up
โ†“/j Move down
Enter/โ†’/l Open directory or preview file
โ†/h Go to parent directory
o Toggle ownership/permissions display
b Go to bookmark
/ Search files (requires fzf)
m Show help modal with all key mappings
q/ESC Quit and cd to current directory

โš™๏ธ Configuration

Create a ~/.sgtrc file to customize colors and bookmarks:

# Color theme (available: black, red, green, yellow, blue, magenta, cyan, white)
[colors]
directories=cyan
files=white
selected_bg=blue
selected_fg=black
header=yellow
path=green
git_branch=magenta

# Bookmarks
[bookmarks]
home=/home/user
projects=~/projects
documents=~/Documents

๐Ÿงช Development

Running Tests

# Install development dependencies
bundle install

# Run all tests
bundle exec rspec

# Run specific test file
bundle exec rspec spec/utils_spec.rb

# Run with documentation format
bundle exec rspec --format documentation

Code Quality

# Run rubocop linter
bundle exec rubocop

# Auto-correct issues
bundle exec rubocop -A

Project Structure

sergeant/
โ”œโ”€โ”€ bin/
โ”‚   โ””โ”€โ”€ sgt                   # Executable command
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ sergeant.rb           # Main application class
โ”‚   โ””โ”€โ”€ sergeant/
โ”‚       โ”œโ”€โ”€ version.rb        # Gem version
โ”‚       โ”œโ”€โ”€ config.rb         # Configuration and bookmark management
โ”‚       โ”œโ”€โ”€ utils.rb          # Utility functions (formatting, file detection)
โ”‚       โ”œโ”€โ”€ rendering.rb      # UI rendering and display logic
โ”‚       โ”œโ”€โ”€ modals.rb         # Modal modules loader
โ”‚       โ””โ”€โ”€ modals/           # Modal dialog modules
โ”‚           โ”œโ”€โ”€ navigation.rb       # Bookmark navigation
โ”‚           โ”œโ”€โ”€ dialogs.rb          # Info/error/confirmation dialogs
โ”‚           โ”œโ”€โ”€ file_operations.rb  # File preview, copy, paste, delete, rename
โ”‚           โ””โ”€โ”€ help.rb             # Help modal with key mappings
โ”œโ”€โ”€ spec/                     # RSpec test suite
โ”œโ”€โ”€ sergeant.gemspec          # Gem specification
โ”œโ”€โ”€ Gemfile                   # Bundler configuration
โ””โ”€โ”€ README.md                 # This file

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Be warn, that I reserve my personal judgement to new features as I'm very focused on not to bloat it with too many functionalities

๐Ÿ“ License

MIT License

๐Ÿ™ Acknowledgments

  • Built with Ruby and ncurses
  • Inspired by Omarchy linux and terminal file managers like ranger and nnn
  • Uses glow for markdown rendering
  • Integrates with fzf for fuzzy finding

"Leave it to the Sarge!" ๐ŸŽ–๏ธ