sergeant 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80f83fe4916418417a546134baeff0c43e0daf5e383b39cdd49c77bdea88e3a3
4
+ data.tar.gz: 6105effe9798842cf02bdb5b56e32b1b58e5838da3c66004b24da31365982758
5
+ SHA512:
6
+ metadata.gz: a90c6c72ab39338aa0d27a603051a2fea99b97b9f9c0764f2cc3f59bde980c3310b0aa97015028543453e03b11d4fff62f162fc2ae716fa991a91090628bb680
7
+ data.tar.gz: 845f119f78cfb9d08d4afa1abd6816195b630a16e2276cc59a7caab318a34e7fa15cb1984e6aa9a82c5f43e758894238740ba99a8490a8d676c9577b0560e78f
data/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ All notable changes to Sergeant will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2024-12-23
9
+
10
+ ### Added
11
+ - **Interactive TUI navigation** - Navigate directories with arrow keys or vim bindings (hjkl)
12
+ - **File operations**
13
+ - Mark/unmark files with Space
14
+ - Copy (c), cut (x), paste (p) with smart conflict resolution
15
+ - Delete with confirmation (d)
16
+ - Rename files/directories (r)
17
+ - Create new files/directories (n)
18
+ - **File viewing and editing**
19
+ - Edit files with $EDITOR support (e) - respects POSIX conventions
20
+ - Preview files read-only (v) - markdown with glow, code with nvim/vim
21
+ - Fallback chain: $EDITOR → nano → nvim → vim → vi
22
+ - **Terminal integration**
23
+ - Execute shell commands without leaving sgt (:)
24
+ - Commands run in current directory context
25
+ - **Search and navigation**
26
+ - Fuzzy file search with fzf integration (/)
27
+ - Bookmarks system (b)
28
+ - Git branch display in header
29
+ - Parent directory navigation (h/←)
30
+ - **UI features**
31
+ - Color-coded display (directories, files, selected items)
32
+ - Adaptive interface for narrow terminals and tiling window managers
33
+ - Smart scrolling for large directories
34
+ - Ownership/permissions toggle (o)
35
+ - Help modal with all key mappings (m)
36
+ - Status indicators for marked/copied items
37
+ - **Configuration**
38
+ - Customizable colors via ~/.sgtrc
39
+ - Bookmark management in config file
40
+ - Theme support
41
+
42
+ ### Technical
43
+ - Built as Ruby gem for easy installation
44
+ - POSIX-compliant, respects environment variables ($EDITOR, $VISUAL)
45
+ - Ncurses-based TUI
46
+ - Comprehensive test suite with RSpec
47
+ - No GUI dependencies - works in pure terminal
48
+
49
+ [1.0.0]: https://github.com/biscoitinho/Sergeant/releases/tag/v1.0.0
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ ruby '>= 2.7.0'
6
+
7
+ # Terminal UI library
8
+ gem 'curses', '~> 1.4'
9
+
10
+ group :development do
11
+ # Code linting and style checking
12
+ gem 'rubocop', '~> 1.81', require: false
13
+ end
14
+
15
+ group :test do
16
+ # Testing framework
17
+ gem 'rspec', '~> 3.13'
18
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Mateusz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # 🎖️ Sergeant (sgt)
2
+
3
+ ![Sergeant Logo](./logo.svg)
4
+
5
+ **Interactive TUI Directory Navigator for Terminal - "Leave it to the Sarge!"**
6
+
7
+ Sergeant is a interactive terminal user interface (TUI) for navigating directories and managing files.
8
+ Instead of typing `cd` and file manipulation commands, just run `sgt`,
9
+ use arrow keys and keyboard shortcuts to navigate, preview, copy, move, and organize your files.
10
+ Simple, fast, and elegant.
11
+
12
+ ## ✨ Features
13
+
14
+ ### Navigation & Display
15
+ - 🗂️ **Visual Directory Navigation** - See all directories and files at a glance
16
+ - ⌨️ **Keyboard Driven** - Arrow keys, vim bindings (hjkl), and shortcuts
17
+ - 🎨 **Color-Coded Display** - Directories in cyan, files grayed out
18
+ - 📊 **Smart Scrolling** - Handles directories with hundreds of items
19
+ - 🔍 **Git Branch Display** - Shows current git branch in header
20
+ - 👤 **Ownership Toggle** - View file permissions and ownership (press 'o')
21
+ - 📑 **Bookmarks** - Save and quickly navigate to favorite directories
22
+
23
+ ### File Operations
24
+ - 📋 **Copy/Cut/Paste** - Mark files with spacebar, copy (c), cut (x), and paste (p)
25
+ - ✂️ **Multi-file Selection** - Mark multiple files/folders for batch operations
26
+ - 🗑️ **Delete with Confirmation** - Safe deletion with confirmation dialog
27
+ - ✏️ **Rename** - Rename files and folders with pre-filled input
28
+ - 🔄 **Conflict Resolution** - Smart handling of file conflicts (skip/overwrite/rename)
29
+ - 📄 **File Preview** - View markdown files with glow, code files with vim/nano
30
+
31
+ ### Search & Productivity
32
+ - 🔎 **Fuzzy Search** - Integrate with fzf for fast file finding
33
+ - ❓ **Help Modal** - Press 'm' for comprehensive key mapping reference
34
+ - 🚀 **Instant CD** - Select and change directory in one smooth motion
35
+
36
+ ## 📋 Requirements
37
+
38
+ - **Ruby** 2.7 or higher (Ruby 3.x recommended)
39
+
40
+ ### System Dependencies
41
+
42
+ The `curses` gem (installed automatically) requires native libraries:
43
+
44
+ **macOS:**
45
+ ```bash
46
+ # Usually works out of the box
47
+ # If you get errors, install Xcode Command Line Tools:
48
+ xcode-select --install
49
+
50
+ # Recommended: Use Homebrew Ruby instead of system Ruby
51
+ brew install ruby
52
+ # Add to ~/.zshrc: export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
53
+ ```
54
+
55
+ **Linux (Debian/Ubuntu):**
56
+ ```bash
57
+ sudo apt-get install libncurses-dev ruby-dev
58
+ ```
59
+
60
+ **Linux (Fedora/RHEL):**
61
+ ```bash
62
+ sudo dnf install ncurses-devel ruby-devel
63
+ ```
64
+
65
+ ### Optional Tools
66
+ - **glow** - For beautiful markdown preview (`brew install glow` or `go install github.com/charmbracelet/glow@latest`)
67
+ - **fzf** - For fuzzy file search (`brew install fzf` or `sudo apt-get install fzf`)
68
+
69
+ ## 🚀 Installation
70
+
71
+ ### Install from RubyGems (Coming Soon)
72
+
73
+ Once published to RubyGems:
74
+
75
+ ```bash
76
+ gem install sergeant
77
+ ```
78
+
79
+ ### Install from Source
80
+
81
+ ```bash
82
+ # Clone the repository
83
+ git clone https://github.com/biscoitinho/Sergeant.git
84
+ cd Sergeant
85
+
86
+ # Build and install the gem locally
87
+ gem build sergeant.gemspec
88
+ gem install ./sergeant-1.0.0.gem
89
+ ```
90
+
91
+ That's it! The `sgt` command will automatically be added to your PATH.
92
+
93
+ ### Development Installation
94
+
95
+ If you want to work on the gem:
96
+
97
+ ```bash
98
+ # Clone and setup
99
+ git clone https://github.com/biscoitinho/Sergeant.git
100
+ cd Sergeant
101
+
102
+ # Install dependencies
103
+ bundle install
104
+
105
+ # Run directly without installing
106
+ bundle exec bin/sgt
107
+ ```
108
+
109
+ ## 🎮 Usage
110
+
111
+ ### Basic Navigation
112
+
113
+ ```bash
114
+ # Start sergeant in current directory
115
+ sgt
116
+
117
+ # Navigate and select
118
+ # Arrow keys or j/k to move up/down
119
+ # Enter or l to enter directory
120
+ # h to go back
121
+ # q to quit and cd to selected directory
122
+ ```
123
+
124
+ ### File Operations
125
+
126
+ | Key | Action |
127
+ |-----|--------|
128
+ | `Space` | Mark/unmark item for operations |
129
+ | `c` | Copy marked items |
130
+ | `x` | Cut marked items |
131
+ | `p` | Paste copied/cut items |
132
+ | `d` | Delete marked items (with confirmation) |
133
+ | `r` | Rename current item |
134
+ | `u` | Unmark all items |
135
+ | `v` | Preview file (markdown/code) |
136
+
137
+ ### Other Commands
138
+
139
+ | Key | Action |
140
+ |-----|--------|
141
+ | `↑/k` | Move up |
142
+ | `↓/j` | Move down |
143
+ | `Enter/→/l` | Open directory or preview file |
144
+ | `←/h` | Go to parent directory |
145
+ | `o` | Toggle ownership/permissions display |
146
+ | `b` | Go to bookmark |
147
+ | `/` | Search files (requires fzf) |
148
+ | `m` | Show help modal with all key mappings |
149
+ | `q/ESC` | Quit and cd to current directory |
150
+
151
+ ## ⚙️ Configuration
152
+
153
+ Create a `~/.sgtrc` file to customize colors and bookmarks:
154
+
155
+ ```ini
156
+ # Color theme (available: black, red, green, yellow, blue, magenta, cyan, white)
157
+ [colors]
158
+ directories=cyan
159
+ files=white
160
+ selected_bg=blue
161
+ selected_fg=black
162
+ header=yellow
163
+ path=green
164
+ git_branch=magenta
165
+
166
+ # Bookmarks
167
+ [bookmarks]
168
+ home=/home/user
169
+ projects=~/projects
170
+ documents=~/Documents
171
+ ```
172
+
173
+ ## 🧪 Development
174
+
175
+ ### Running Tests
176
+
177
+ ```bash
178
+ # Install development dependencies
179
+ bundle install
180
+
181
+ # Run all tests
182
+ bundle exec rspec
183
+
184
+ # Run specific test file
185
+ bundle exec rspec spec/utils_spec.rb
186
+
187
+ # Run with documentation format
188
+ bundle exec rspec --format documentation
189
+ ```
190
+
191
+ ### Code Quality
192
+
193
+ ```bash
194
+ # Run rubocop linter
195
+ bundle exec rubocop
196
+
197
+ # Auto-correct issues
198
+ bundle exec rubocop -A
199
+ ```
200
+
201
+ ### Project Structure
202
+
203
+ ```
204
+ sergeant/
205
+ ├── bin/
206
+ │ └── sgt # Executable command
207
+ ├── lib/
208
+ │ ├── sergeant.rb # Main application class
209
+ │ └── sergeant/
210
+ │ ├── version.rb # Gem version
211
+ │ ├── config.rb # Configuration and bookmark management
212
+ │ ├── utils.rb # Utility functions (formatting, file detection)
213
+ │ ├── rendering.rb # UI rendering and display logic
214
+ │ ├── modals.rb # Modal modules loader
215
+ │ └── modals/ # Modal dialog modules
216
+ │ ├── navigation.rb # Bookmark navigation
217
+ │ ├── dialogs.rb # Info/error/confirmation dialogs
218
+ │ ├── file_operations.rb # File preview, copy, paste, delete, rename
219
+ │ └── help.rb # Help modal with key mappings
220
+ ├── spec/ # RSpec test suite
221
+ ├── sergeant.gemspec # Gem specification
222
+ ├── Gemfile # Bundler configuration
223
+ └── README.md # This file
224
+ ```
225
+
226
+ ## 🤝 Contributing
227
+
228
+ Contributions are welcome! Please feel free to submit a Pull Request.
229
+ Be warn, that I reserve my personal judgement to new features
230
+ as I'm very focused on not to bloat it with too many functionalities
231
+
232
+ ## 📝 License
233
+
234
+ MIT License
235
+
236
+ ## 🙏 Acknowledgments
237
+
238
+ - Built with Ruby and ncurses
239
+ - Inspired by [Omarchy linux](https://omarchy.org) and terminal file managers like ranger and nnn
240
+ - Uses [glow](https://github.com/charmbracelet/glow) for markdown rendering
241
+ - Integrates with [fzf](https://github.com/junegunn/fzf) for fuzzy finding
242
+
243
+ ---
244
+
245
+ **"Leave it to the Sarge!"** 🎖️
data/bin/sgt ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Sergeant (sgt) - Interactive TUI directory navigator
5
+ # Version: 1.0.0
6
+
7
+ # Add lib directory to load path for development
8
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
9
+
10
+ require 'sergeant'
11
+
12
+ # Run the navigator
13
+ SergeantApp.new.run
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Configuration and bookmark management
4
+
5
+ module Sergeant
6
+ module Config
7
+ COLOR_MAP = {
8
+ 'black' => Curses::COLOR_BLACK,
9
+ 'red' => Curses::COLOR_RED,
10
+ 'green' => Curses::COLOR_GREEN,
11
+ 'yellow' => Curses::COLOR_YELLOW,
12
+ 'blue' => Curses::COLOR_BLUE,
13
+ 'magenta' => Curses::COLOR_MAGENTA,
14
+ 'cyan' => Curses::COLOR_CYAN,
15
+ 'white' => Curses::COLOR_WHITE
16
+ }.freeze
17
+
18
+ DEFAULT_CONFIG = {
19
+ 'directories' => 'cyan',
20
+ 'files' => 'white',
21
+ 'selected_bg' => 'cyan',
22
+ 'selected_fg' => 'black',
23
+ 'header' => 'yellow',
24
+ 'path' => 'green',
25
+ 'git_branch' => 'magenta'
26
+ }.freeze
27
+
28
+ MINIMAL_CONFIG_TEMPLATE = <<~CONFIG.freeze
29
+ # Sergeant Configuration File
30
+ # Color theme (available: black, red, green, yellow, blue, magenta, cyan, white)
31
+ directories=cyan
32
+ files=white
33
+ selected_bg=cyan
34
+ selected_fg=black
35
+ header=yellow
36
+ path=green
37
+ git_branch=magenta
38
+
39
+ # Bookmarks
40
+ [bookmarks]
41
+ # Add your bookmarks here
42
+ # Example:
43
+ # home=#{Dir.home}
44
+ # projects=~/projects
45
+ CONFIG
46
+
47
+ def self.load_config
48
+ config_file = File.join(Dir.home, '.sgtrc')
49
+ ensure_config_exists(config_file)
50
+
51
+ config = DEFAULT_CONFIG.dup
52
+
53
+ return config unless File.exist?(config_file)
54
+
55
+ File.readlines(config_file).each do |line|
56
+ line = line.strip
57
+ next if line.empty? || line.start_with?('#')
58
+ next if line.include?('=') && line.split('=')[0].strip.start_with?('[bookmark')
59
+
60
+ key, value = line.split('=', 2)
61
+ next unless key && value
62
+
63
+ config[key.strip] = value.strip
64
+ end
65
+
66
+ config
67
+ rescue StandardError
68
+ DEFAULT_CONFIG.dup
69
+ end
70
+
71
+ def self.load_bookmarks
72
+ config_file = File.join(Dir.home, '.sgtrc')
73
+ bookmarks = {}
74
+
75
+ return bookmarks unless File.exist?(config_file)
76
+
77
+ in_bookmark_section = false
78
+
79
+ File.readlines(config_file).each do |line|
80
+ line = line.strip
81
+
82
+ if line.downcase.include?('[bookmarks]')
83
+ in_bookmark_section = true
84
+ next
85
+ end
86
+
87
+ if line.start_with?('[') && line.end_with?(']')
88
+ in_bookmark_section = false
89
+ next
90
+ end
91
+
92
+ next if line.empty? || line.start_with?('#')
93
+
94
+ next unless in_bookmark_section && line.include?('=')
95
+
96
+ key, value = line.split('=', 2)
97
+ next unless key && value
98
+
99
+ key = key.strip
100
+ value = value.strip.gsub('~', Dir.home)
101
+
102
+ bookmarks[key] = File.expand_path(value) if value.start_with?('/') || value.start_with?('~') || value.include?('/')
103
+ end
104
+
105
+ bookmarks
106
+ rescue StandardError
107
+ {}
108
+ end
109
+
110
+ def self.ensure_config_exists(config_file)
111
+ return if File.exist?(config_file)
112
+
113
+ File.write(config_file, MINIMAL_CONFIG_TEMPLATE)
114
+ end
115
+
116
+ def self.get_color(name)
117
+ COLOR_MAP[name.downcase] || Curses::COLOR_WHITE
118
+ end
119
+ end
120
+ end
Binary file