sergeant 1.0.3 → 1.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 41b7c3b966daedbb73dc65a9ceb67bb5653791757713bc33dd838f3327d9c33b
4
- data.tar.gz: 636ed748a5e8efbe0291ccacb65031c814524e85e731ce076c9918c8adcfddc0
3
+ metadata.gz: ac9c7c93fc3b942684b0f038cf0fa8658cc17c2a1fdc732a9bfef538bc4afa78
4
+ data.tar.gz: f4c839577ff9a2c23560e22332adf2641c2614118cc017b5e83cb7a0c3219878
5
5
  SHA512:
6
- metadata.gz: d7e9b24e7f865efadec5dfe8729945bbf4c24bfa49df8c175e85d5de45c63457aba733fe09156950293e1ef3af4addd3831dd4e5a32f353e507b09667749eb23
7
- data.tar.gz: 2b24694b491e148932545f6a727ca966a4803c489ca9d623098cd5e36ecc53cbcaf5761cf5fb1c6e259390555f6341551a1d55a1d765069a582275fc8d4c811a
6
+ metadata.gz: 24182721fbd0c5edb7900440b452a29ad2f7d98092e57c9701bad1bd19872faa38fa9d60985985785abb26734e5772604e4a90fa9862dab85d1646b880b98a45
7
+ data.tar.gz: 0e7d245c24cca22da30aba6c5fffd988f66ec82b93e34a83e0e543bf48657c1f1ada2985003e9157afc418b758e974ed86e400faf948570c4d5570a29aae65f4
data/CHANGELOG.md CHANGED
@@ -5,7 +5,34 @@ All notable changes to Sergeant will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [1.0.3] - 2024-12-26
8
+ ## [1.0.5] - 2025-01-15
9
+
10
+ ### Added
11
+ - **Command-line interface improvements**
12
+ - Added `--help` / `-h` flag to show usage and features
13
+ - Added `--version` / `-v` flag to show version number
14
+ - Support starting in specific directory: `sgt ~/Documents`
15
+ - Added `-b` / `--bookmark [name]` to start at a saved bookmark location
16
+ - Added `--list-bookmarks` to display all saved bookmarks with status
17
+ - Added `--pwd` flag to print final directory on exit for shell integration
18
+ - Added `--debug` flag to show environment and configuration details
19
+ - Added `--no-color` flag for terminals without color support
20
+ - Post-install message with quick start guide and tips
21
+ - Shell integration examples for quick directory jumping
22
+
23
+ ## [1.0.4] - 2025-12-27
24
+
25
+ ### Fixed
26
+ - **Windows compatibility improvements**
27
+ - Use ASCII icons ([D], [F], *, >) on Windows for better terminal compatibility (PR #15)
28
+ - Windows terminals often don't render emoji properly - now uses ASCII fallback
29
+ - Add notepad fallback for file preview and edit on Windows (PR #16)
30
+ - POSIX tools (vim, nano, less) replaced with notepad when not available
31
+
32
+ ### Changed
33
+ - Reduced gem package size from 4.8MB to ~115KB by excluding media files and .DS_Store
34
+
35
+ ## [1.0.3] - 2025-12-26
9
36
 
10
37
  ### Added
11
38
  - **Total size display for marked items**
@@ -34,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
34
61
  - Track ownership toggle changes to refresh only when needed
35
62
  - **Added comprehensive test coverage** for performance optimizations (14 test cases)
36
63
 
37
- ## [1.0.2] - 2024-12-26
64
+ ## [1.0.2] - 2025-12-26
38
65
 
39
66
  ### Fixed
40
67
  - **Display issue on Arch Linux**: Added terminal color support checking
@@ -55,7 +82,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
55
82
  - Added error recovery for curses screen initialization failures
56
83
  - Better compatibility with different ncurses implementations
57
84
 
58
- ## [1.0.1] - 2024-12-24
85
+ ## [1.0.1] - 2025-12-24
59
86
 
60
87
  ### Fixed
61
88
  - **Major performance improvement**: Fixed severe input lag with large directories
@@ -66,7 +93,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66
93
  - Shows load path and helpful reinstall instructions if gem fails to load
67
94
  - Displays full error details instead of silently failing
68
95
 
69
- ## [1.0.0] - 2024-12-23
96
+ ## [1.0.0] - 2025-12-23
70
97
 
71
98
  ### Added
72
99
  - **Interactive TUI navigation** - Navigate directories with arrow keys or vim bindings (hjkl)
data/README.md CHANGED
@@ -73,7 +73,7 @@ sudo dnf install ncurses-devel ruby-devel
73
73
 
74
74
  ## šŸš€ Installation
75
75
 
76
- ### Install from RubyGems (Coming Soon)
76
+ ### Install from RubyGems
77
77
 
78
78
  Once published to RubyGems:
79
79
 
@@ -142,6 +142,12 @@ bundle exec bin/sgt
142
142
  # Start sergeant in current directory
143
143
  sgt
144
144
 
145
+ # Start in specific directory
146
+ sgt ~/Documents
147
+
148
+ # Start at a bookmark
149
+ sgt -b projects
150
+
145
151
  # Navigate and select
146
152
  # Arrow keys or j/k to move up/down
147
153
  # Enter or l to enter directory
@@ -149,6 +155,59 @@ sgt
149
155
  # q to quit and cd to selected directory
150
156
  ```
151
157
 
158
+ ### Command-Line Options
159
+
160
+ ```bash
161
+ # View help and all options
162
+ sgt --help
163
+
164
+ # Show version
165
+ sgt --version
166
+
167
+ # List all bookmarks
168
+ sgt --list-bookmarks
169
+
170
+ # Start at bookmark location
171
+ sgt -b [bookmark_name]
172
+
173
+ # Debug mode (show environment info)
174
+ sgt --debug
175
+
176
+ # Disable colors
177
+ sgt --no-color
178
+ ```
179
+
180
+ ### Shell Integration (cd to final directory)
181
+
182
+ The `--pwd` flag enables powerful shell integration, allowing you to navigate visually in sergeant and have your shell automatically cd to the final location:
183
+
184
+ ```bash
185
+ # Quick navigation function
186
+ # Add this to your ~/.bashrc or ~/.zshrc:
187
+ s() {
188
+ local dir=$(sgt --pwd "$@")
189
+ [[ -n "$dir" ]] && cd "$dir"
190
+ }
191
+
192
+ # Usage examples:
193
+ s # Navigate from current dir, cd to final location
194
+ s ~/projects # Start in projects, cd to where you end up
195
+ s -b work # Start at work bookmark, cd to final location
196
+
197
+ # Alternative one-liner (no function needed):
198
+ cd $(sgt --pwd ~/projects)
199
+
200
+ # Jump to deeply nested directory visually:
201
+ cd $(sgt --pwd /usr/local)
202
+ ```
203
+
204
+ **How it works:**
205
+ 1. Start sergeant with `--pwd` flag
206
+ 2. Navigate to your desired directory using arrow keys
207
+ 3. Press `q` to quit
208
+ 4. Sergeant outputs the final directory path
209
+ 5. Shell captures it with `$()` and cd's there
210
+
152
211
  ### File Operations
153
212
 
154
213
  | Key | Action |
data/bin/sgt CHANGED
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  # Sergeant (sgt) - Interactive TUI directory navigator
5
- # Version: 1.0.0
6
5
 
7
6
  begin
8
7
  require 'sergeant'
@@ -13,11 +12,195 @@ rescue LoadError => e
13
12
  exit 1
14
13
  end
15
14
 
15
+ def show_help
16
+ puts <<~HELP
17
+ Sergeant (sgt) v#{Sergeant::VERSION} - Interactive TUI Directory Navigator
18
+
19
+ USAGE:
20
+ sgt [OPTIONS] [DIRECTORY]
21
+
22
+ OPTIONS:
23
+ -h, --help Show this help message
24
+ -v, --version Show version number
25
+ -b, --bookmark NAME Start at bookmark location
26
+ --list-bookmarks List all saved bookmarks
27
+ --pwd Print final directory on exit (for shell integration)
28
+ --debug Show debug information and environment details
29
+ --no-color Disable colors (for terminals without color support)
30
+
31
+ ARGUMENTS:
32
+ DIRECTORY Start in specified directory (default: current directory)
33
+
34
+ EXAMPLES:
35
+ sgt Start in current directory
36
+ sgt ~/Documents Start in Documents folder
37
+ sgt -b projects Start at 'projects' bookmark
38
+ sgt --list-bookmarks Show all bookmarks
39
+ cd $(sgt --pwd) Navigate and cd to final directory
40
+ sgt --debug Show debug info before starting
41
+ sgt --help Show this help
42
+
43
+ SHELL INTEGRATION:
44
+ Add this to your ~/.bashrc or ~/.zshrc for quick directory jumping:
45
+
46
+ s() {
47
+ local dir=$(sgt --pwd "$@")
48
+ [[ -n "$dir" ]] && cd "$dir"
49
+ }
50
+
51
+ Then use: s ~/projects
52
+
53
+ FEATURES:
54
+ • Navigate with arrow keys or vim bindings (hjkl)
55
+ • Mark files with Space, copy (c), cut (x), paste (p)
56
+ • Quick filter (f), fuzzy search (/), file preview (v)
57
+ • Archive peek for .zip, .tar.gz, and more
58
+ • Press 'm' in-app for complete key mappings
59
+
60
+ For more information, visit: https://github.com/biscoitinho/Sergeant
61
+ HELP
62
+ exit 0
63
+ end
64
+
65
+ def show_version
66
+ puts "Sergeant (sgt) version #{Sergeant::VERSION}"
67
+ exit 0
68
+ end
69
+
70
+ def show_debug_info
71
+ puts "Sergeant Debug Information"
72
+ puts "=" * 50
73
+ puts "Version: #{Sergeant::VERSION}"
74
+ puts "Ruby Version: #{RUBY_VERSION}"
75
+ puts "Ruby Platform: #{RUBY_PLATFORM}"
76
+ puts "Current Directory: #{Dir.pwd}"
77
+ puts "Home Directory: #{ENV['HOME']}"
78
+ puts "TERM: #{ENV['TERM'] || 'not set'}"
79
+ puts "COLORTERM: #{ENV['COLORTERM'] || 'not set'}"
80
+ puts "EDITOR: #{ENV['EDITOR'] || 'not set'}"
81
+ puts "VISUAL: #{ENV['VISUAL'] || 'not set'}"
82
+ puts "PATH: #{ENV['PATH']}"
83
+ puts "\nLoad Path:"
84
+ $LOAD_PATH.each { |path| puts " #{path}" }
85
+ puts "\nConfig File: #{File.expand_path('~/.sgtrc')}"
86
+ puts "Config Exists: #{File.exist?(File.expand_path('~/.sgtrc'))}"
87
+ puts "=" * 50
88
+ puts "\nPress Enter to continue or Ctrl+C to exit..."
89
+ gets
90
+ end
91
+
92
+ def list_bookmarks
93
+ require_relative '../lib/sergeant/config'
94
+ bookmarks = Sergeant::Config.load_bookmarks
95
+
96
+ if bookmarks.empty?
97
+ puts "No bookmarks found."
98
+ puts "Add bookmarks to ~/.sgtrc under [bookmarks] section:"
99
+ puts "\n[bookmarks]"
100
+ puts "home=/home/user"
101
+ puts "projects=~/projects"
102
+ exit 0
103
+ end
104
+
105
+ puts "Saved Bookmarks:"
106
+ puts "=" * 50
107
+ bookmarks.each do |name, path|
108
+ expanded = File.expand_path(path)
109
+ exists = File.directory?(expanded) ? "āœ“" : "āœ—"
110
+ puts " #{exists} #{name.ljust(15)} → #{path}"
111
+ end
112
+ puts "=" * 50
113
+ puts "\nUsage: sgt -b [bookmark_name]"
114
+ exit 0
115
+ end
116
+
117
+ def get_bookmark_path(bookmark_name)
118
+ require_relative '../lib/sergeant/config'
119
+ bookmarks = Sergeant::Config.load_bookmarks
120
+
121
+ unless bookmarks.key?(bookmark_name)
122
+ warn "Error: Bookmark '#{bookmark_name}' not found"
123
+ warn "Available bookmarks: #{bookmarks.keys.join(', ')}"
124
+ warn "Use 'sgt --list-bookmarks' to see all bookmarks"
125
+ exit 1
126
+ end
127
+
128
+ path = File.expand_path(bookmarks[bookmark_name])
129
+ unless File.directory?(path)
130
+ warn "Error: Bookmark path '#{path}' does not exist"
131
+ exit 1
132
+ end
133
+
134
+ path
135
+ end
136
+
137
+ # Process arguments
138
+ start_dir = nil
139
+ no_color = false
140
+ show_debug = false
141
+ pwd_mode = false
142
+ bookmark_name = nil
143
+
144
+ i = 0
145
+ while i < ARGV.length
146
+ arg = ARGV[i]
147
+ case arg
148
+ when '-h', '--help'
149
+ show_help
150
+ when '-v', '--version'
151
+ show_version
152
+ when '--debug'
153
+ show_debug = true
154
+ when '--pwd'
155
+ pwd_mode = true
156
+ when '--list-bookmarks'
157
+ list_bookmarks
158
+ when '-b', '--bookmark'
159
+ i += 1
160
+ if i >= ARGV.length
161
+ warn "Error: --bookmark requires a bookmark name"
162
+ warn "Use 'sgt --list-bookmarks' to see available bookmarks"
163
+ exit 1
164
+ end
165
+ bookmark_name = ARGV[i]
166
+ when '--no-color'
167
+ no_color = true
168
+ when /^-/
169
+ warn "Unknown option: #{arg}"
170
+ warn "Try 'sgt --help' for more information."
171
+ exit 1
172
+ else
173
+ start_dir = arg
174
+ end
175
+ i += 1
176
+ end
177
+
178
+ # Show debug info if requested
179
+ show_debug_info if show_debug
180
+
181
+ # Handle bookmark
182
+ start_dir = get_bookmark_path(bookmark_name) if bookmark_name
183
+
184
+ # Validate and expand directory path
185
+ if start_dir
186
+ start_dir = File.expand_path(start_dir)
187
+ unless File.directory?(start_dir)
188
+ warn "Error: '#{start_dir}' is not a valid directory"
189
+ exit 1
190
+ end
191
+ end
192
+
16
193
  # Run the navigator
17
194
  begin
18
- SergeantApp.new.run
195
+ SergeantApp.new(start_dir: start_dir, no_color: no_color, pwd_mode: pwd_mode).run
19
196
  rescue StandardError => e
20
- warn "\nSergeant error: #{e.message}"
21
- warn e.backtrace.join("\n")
22
- exit 1
197
+ # In pwd mode, don't show error details, just exit silently with current dir
198
+ if pwd_mode
199
+ puts Dir.pwd
200
+ exit 1
201
+ else
202
+ warn "\nSergeant error: #{e.message}"
203
+ warn e.backtrace.join("\n")
204
+ exit 1
205
+ end
23
206
  end
@@ -23,6 +23,9 @@ module Sergeant
23
23
  if editor
24
24
  # Use user's preferred editor
25
25
  system("#{editor} \"#{file_path}\"")
26
+ elsif Gem.win_platform?
27
+ # Windows: use notepad (always available)
28
+ system("notepad \"#{file_path}\"")
26
29
  elsif nvim_available?
27
30
  # Second fallback: nvim (modern vim)
28
31
  system("nvim \"#{file_path}\"")
@@ -83,8 +86,11 @@ module Sergeant
83
86
  close_screen
84
87
 
85
88
  begin
89
+ if Gem.win_platform?
90
+ # Windows: use notepad for preview (simpler and always works)
91
+ system("notepad \"#{file_path}\"")
86
92
  # Use glow for markdown files if available, otherwise fall back to less
87
- if file_ext == '.md' && glow_available?
93
+ elsif file_ext == '.md' && glow_available?
88
94
  system("glow -p \"#{file_path}\"")
89
95
  elsif file_ext == '.md'
90
96
  system("less -R -F -X \"#{file_path}\"")
@@ -4,6 +4,13 @@
4
4
 
5
5
  module Sergeant
6
6
  module Rendering
7
+ # Use ASCII icons on Windows for better terminal compatibility
8
+ WINDOWS = Gem.win_platform?
9
+ ICON_DIR = WINDOWS ? '[D] ' : 'šŸ“ '
10
+ ICON_FILE = WINDOWS ? '[F] ' : 'šŸ“„ '
11
+ ICON_MARK = WINDOWS ? '* ' : 'āœ“ '
12
+ ICON_SELECT = WINDOWS ? '> ' : 'ā–¶ '
13
+
7
14
  def draw_screen
8
15
  clear
9
16
 
@@ -127,13 +134,13 @@ module Sergeant
127
134
  end
128
135
 
129
136
  def draw_item(item, max_x, is_selected)
130
- icon = item[:type] == :directory ? 'šŸ“ ' : 'šŸ“„ '
137
+ icon = item[:type] == :directory ? ICON_DIR : ICON_FILE
131
138
 
132
139
  # Check if item is marked
133
140
  is_marked = @marked_items.include?(item[:path])
134
- mark_indicator = is_marked ? 'āœ“ ' : ' '
141
+ mark_indicator = is_marked ? ICON_MARK : ' '
135
142
 
136
- prefix = is_selected ? 'ā–¶ ' : ' '
143
+ prefix = is_selected ? ICON_SELECT : ' '
137
144
 
138
145
  size_str = format_size(item[:size])
139
146
  date_str = format_date(item[:mtime])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sergeant
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.5'
5
5
  end
data/lib/sergeant.rb CHANGED
@@ -21,12 +21,14 @@ class SergeantApp
21
21
  include Sergeant::Modals
22
22
  include Sergeant::Rendering
23
23
 
24
- def initialize
25
- @current_dir = Dir.pwd
24
+ def initialize(start_dir: nil, no_color: false, pwd_mode: false)
25
+ @current_dir = start_dir || Dir.pwd
26
26
  @selected_index = 0
27
27
  @scroll_offset = 0
28
28
  @show_ownership = false
29
29
  @last_show_ownership = false
30
+ @no_color = no_color
31
+ @pwd_mode = pwd_mode
30
32
  @config = Sergeant::Config.load_config
31
33
  @bookmarks = Sergeant::Config.load_bookmarks
32
34
  @marked_items = []
@@ -41,8 +43,8 @@ class SergeantApp
41
43
  def run
42
44
  init_screen
43
45
 
44
- # Only initialize colors if terminal supports them
45
- if has_colors?
46
+ # Only initialize colors if terminal supports them and not disabled
47
+ if !@no_color && has_colors?
46
48
  start_color
47
49
  apply_color_theme
48
50
  end
data/sergeant.gemspec CHANGED
@@ -24,6 +24,8 @@ Gem::Specification.new do |spec|
24
24
  `git ls-files -z`.split("\x0").reject do |f|
25
25
  f.match(%r{\A(?:test|spec|features)/}) ||
26
26
  f.match(%r{\A\.}) ||
27
+ f.match(%r{\.DS_Store$}) ||
28
+ f.match(%r{\.(gif|png|jpg|jpeg|mp4|webm)$}) || # Exclude media files
27
29
  f == 'build.rb' ||
28
30
  f == 'install.sh' ||
29
31
  f == 'sgt.rb'
@@ -34,6 +36,25 @@ Gem::Specification.new do |spec|
34
36
  spec.executables = ['sgt']
35
37
  spec.require_paths = ['lib']
36
38
 
39
+ # Post-install message
40
+ spec.post_install_message = <<~MSG
41
+ ╔═══════════════════════════════════════════════════════════════╗
42
+ ā•‘ Sergeant (sgt) installed successfully! šŸŽ–ļø ā•‘
43
+ ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•
44
+
45
+ Get started:
46
+ sgt # Start in current directory
47
+ sgt ~/Documents # Start in specific directory
48
+ sgt --help # View all options
49
+
50
+ Quick tips:
51
+ • Use arrow keys or vim bindings (hjkl) to navigate
52
+ • Press 'm' for help modal with all key mappings
53
+ • Press 'f' to filter, 'v' to preview, Space to mark files
54
+
55
+ For documentation: https://github.com/biscoitinho/Sergeant
56
+ MSG
57
+
37
58
  # Runtime dependencies
38
59
  spec.add_dependency 'curses', '~> 1.4'
39
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sergeant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mateusz Grotha
@@ -66,13 +66,9 @@ files:
66
66
  - LICENSE
67
67
  - README.md
68
68
  - bin/sgt
69
- - highlight.gif
70
- - lib/.DS_Store
71
69
  - lib/sergeant.rb
72
- - lib/sergeant/.DS_Store
73
70
  - lib/sergeant/config.rb
74
71
  - lib/sergeant/modals.rb
75
- - lib/sergeant/modals/.DS_Store
76
72
  - lib/sergeant/modals/dialogs.rb
77
73
  - lib/sergeant/modals/file_operations.rb
78
74
  - lib/sergeant/modals/help.rb
@@ -89,6 +85,13 @@ metadata:
89
85
  homepage_uri: https://github.com/biscoitinho/Sergeant
90
86
  source_code_uri: https://github.com/biscoitinho/Sergeant
91
87
  changelog_uri: https://github.com/biscoitinho/Sergeant/blob/main/CHANGELOG.md
88
+ post_install_message: "╔═══════════════════════════════════════════════════════════════╗\nā•‘
89
+ \ Sergeant (sgt) installed successfully! \U0001F396ļø ā•‘\nā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•\n\nGet
90
+ started:\n sgt # Start in current directory\n sgt ~/Documents #
91
+ Start in specific directory\n sgt --help # View all options\n\nQuick tips:\n
92
+ \ • Use arrow keys or vim bindings (hjkl) to navigate\n • Press 'm' for help modal
93
+ with all key mappings\n • Press 'f' to filter, 'v' to preview, Space to mark files\n\nFor
94
+ documentation: https://github.com/biscoitinho/Sergeant\n"
92
95
  rdoc_options: []
93
96
  require_paths:
94
97
  - lib
data/highlight.gif DELETED
Binary file
data/lib/.DS_Store DELETED
Binary file
Binary file
Binary file