๐๏ธ Sergeant (sgt)
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-devLinux (Fedora/RHEL):
sudo dnf install ncurses-devel ruby-develOptional Tools
-
glow - For beautiful markdown preview (
brew install gloworgo install github.com/charmbracelet/glow@latest) -
fzf - For fuzzy file search (
brew install fzforsudo apt-get install fzf)
๐ Installation
Install from RubyGems (Coming Soon)
Once published to RubyGems:
gem install sergeantInstall 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.gemThat'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 directoryFile 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 documentationCode Quality
# Run rubocop linter
bundle exec rubocop
# Auto-correct issues
bundle exec rubocop -AProject 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!" ๐๏ธ