sergeant 1.0.1 → 1.0.2
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 +4 -4
- data/README.md +33 -0
- data/lib/sergeant/modals/file_operations.rb +12 -9
- data/lib/sergeant/version.rb +1 -1
- data/lib/sergeant.rb +29 -20
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f8e44aa17efd4cddd56d88d910edc0082e94488cd3d25cf6def3b832a579c3d
|
|
4
|
+
data.tar.gz: c66899a4748192ded5481c0497a81ebb81edad956a932d6253beab34ab834a67
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1590f36daa589471edc9f65f150b24b9764ef192b77d46cc51ffc1884e01dafa2fd9a4832a5fef635dfef8bca12f3d16f49b305a295a4fd8e6159e50529d9127
|
|
7
|
+
data.tar.gz: 8ee3a3f6eacd45f3a91c42b7a96e94ccc0961c12cbd3b363ee8a92553efe4db4db73be8499d5304d54702b82333c50fa29b27ad0f87a6f2e141a0a9ca4dad3f2
|
data/README.md
CHANGED
|
@@ -90,6 +90,39 @@ gem install ./sergeant-1.0.0.gem
|
|
|
90
90
|
|
|
91
91
|
That's it! The `sgt` command will automatically be added to your PATH.
|
|
92
92
|
|
|
93
|
+
### Troubleshooting Installation
|
|
94
|
+
|
|
95
|
+
**If sgt doesn't display anything (shows blank screen):**
|
|
96
|
+
|
|
97
|
+
This can happen on Arch Linux or other systems using Ruby version managers (mise, rbenv, asdf).
|
|
98
|
+
|
|
99
|
+
**Recommended fix - Add an alias (simplest):**
|
|
100
|
+
```bash
|
|
101
|
+
# Add to your ~/.bashrc or ~/.zshrc:
|
|
102
|
+
echo 'alias sgt='"'"'ruby "$(which sgt)"'"'"'' >> ~/.bashrc
|
|
103
|
+
|
|
104
|
+
# Reload your shell:
|
|
105
|
+
source ~/.bashrc # or: source ~/.zshrc
|
|
106
|
+
|
|
107
|
+
# Now sgt works!
|
|
108
|
+
sgt
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Alternative - Quick test:**
|
|
112
|
+
```bash
|
|
113
|
+
# Run with explicit ruby (temporary fix)
|
|
114
|
+
ruby $(which sgt)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Alternative - Automated fix script:**
|
|
118
|
+
```bash
|
|
119
|
+
# Creates a wrapper script (requires cloning repo)
|
|
120
|
+
cd Sergeant
|
|
121
|
+
bash arch_fix.sh
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**For detailed troubleshooting**, see [INSTALL_TROUBLESHOOTING.md](./INSTALL_TROUBLESHOOTING.md)
|
|
125
|
+
|
|
93
126
|
### Development Installation
|
|
94
127
|
|
|
95
128
|
If you want to work on the gem:
|
|
@@ -49,12 +49,13 @@ module Sergeant
|
|
|
49
49
|
|
|
50
50
|
# Restore curses screen
|
|
51
51
|
init_screen
|
|
52
|
-
|
|
52
|
+
if has_colors?
|
|
53
|
+
start_color
|
|
54
|
+
apply_color_theme
|
|
55
|
+
end
|
|
53
56
|
curs_set(0)
|
|
54
57
|
noecho
|
|
55
58
|
stdscr.keypad(true)
|
|
56
|
-
apply_color_theme
|
|
57
|
-
refresh # Ensure display updates on all platforms
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
def preview_file
|
|
@@ -103,12 +104,13 @@ module Sergeant
|
|
|
103
104
|
|
|
104
105
|
# Restore curses screen
|
|
105
106
|
init_screen
|
|
106
|
-
|
|
107
|
+
if has_colors?
|
|
108
|
+
start_color
|
|
109
|
+
apply_color_theme
|
|
110
|
+
end
|
|
107
111
|
curs_set(0)
|
|
108
112
|
noecho
|
|
109
113
|
stdscr.keypad(true)
|
|
110
|
-
apply_color_theme
|
|
111
|
-
refresh # Ensure display updates on all platforms
|
|
112
114
|
end
|
|
113
115
|
|
|
114
116
|
def paste_with_modal
|
|
@@ -638,12 +640,13 @@ module Sergeant
|
|
|
638
640
|
|
|
639
641
|
# Restore curses
|
|
640
642
|
init_screen
|
|
641
|
-
|
|
643
|
+
if has_colors?
|
|
644
|
+
start_color
|
|
645
|
+
apply_color_theme
|
|
646
|
+
end
|
|
642
647
|
curs_set(0)
|
|
643
648
|
noecho
|
|
644
649
|
stdscr.keypad(true)
|
|
645
|
-
apply_color_theme
|
|
646
|
-
refresh # Ensure display updates on all platforms
|
|
647
650
|
|
|
648
651
|
# Force refresh to show any changes from the command
|
|
649
652
|
force_refresh
|
data/lib/sergeant/version.rb
CHANGED
data/lib/sergeant.rb
CHANGED
|
@@ -31,23 +31,28 @@ class SergeantApp
|
|
|
31
31
|
@marked_items = []
|
|
32
32
|
@copied_items = []
|
|
33
33
|
@cut_mode = false
|
|
34
|
+
@last_refreshed_dir = nil
|
|
35
|
+
@items = []
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
def run
|
|
37
39
|
init_screen
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
# Only initialize colors if terminal supports them
|
|
42
|
+
if has_colors?
|
|
43
|
+
start_color
|
|
44
|
+
apply_color_theme
|
|
45
|
+
end
|
|
46
|
+
|
|
39
47
|
curs_set(0)
|
|
40
48
|
noecho
|
|
41
49
|
stdscr.keypad(true)
|
|
42
50
|
|
|
43
|
-
apply_color_theme
|
|
44
|
-
|
|
45
51
|
begin
|
|
46
|
-
needs_refresh = true
|
|
47
52
|
loop do
|
|
48
|
-
|
|
53
|
+
# Only refresh items when directory changes, not on every keystroke
|
|
54
|
+
refresh_items_if_needed
|
|
49
55
|
draw_screen
|
|
50
|
-
needs_refresh = false
|
|
51
56
|
|
|
52
57
|
key = getch
|
|
53
58
|
case key
|
|
@@ -61,22 +66,17 @@ class SergeantApp
|
|
|
61
66
|
@current_dir = item[:path]
|
|
62
67
|
@selected_index = 0
|
|
63
68
|
@scroll_offset = 0
|
|
64
|
-
needs_refresh = true
|
|
65
69
|
elsif item && item[:type] == :file
|
|
66
70
|
preview_file
|
|
67
|
-
needs_refresh = true
|
|
68
71
|
end
|
|
69
72
|
when 'b'
|
|
70
73
|
goto_bookmark
|
|
71
|
-
needs_refresh = true
|
|
72
74
|
when 'o'
|
|
73
75
|
@show_ownership = !@show_ownership
|
|
74
76
|
when 'e'
|
|
75
77
|
edit_file
|
|
76
|
-
needs_refresh = true
|
|
77
78
|
when 'v'
|
|
78
79
|
preview_file
|
|
79
|
-
needs_refresh = true
|
|
80
80
|
when 32, ' '
|
|
81
81
|
toggle_mark
|
|
82
82
|
when 'c'
|
|
@@ -85,26 +85,20 @@ class SergeantApp
|
|
|
85
85
|
cut_marked_items
|
|
86
86
|
when 'd'
|
|
87
87
|
delete_marked_items
|
|
88
|
-
needs_refresh = true
|
|
89
88
|
when 'r'
|
|
90
89
|
rename_item
|
|
91
|
-
needs_refresh = true
|
|
92
90
|
when 'p'
|
|
93
91
|
paste_items
|
|
94
|
-
needs_refresh = true
|
|
95
92
|
when 'u'
|
|
96
93
|
unmark_all
|
|
97
94
|
when 'm'
|
|
98
95
|
show_help_modal
|
|
99
96
|
when 'n'
|
|
100
97
|
create_new_with_modal
|
|
101
|
-
needs_refresh = true
|
|
102
98
|
when ':'
|
|
103
99
|
execute_terminal_command
|
|
104
|
-
needs_refresh = true
|
|
105
100
|
when '/'
|
|
106
101
|
search_files
|
|
107
|
-
needs_refresh = true
|
|
108
102
|
when 'q', 27
|
|
109
103
|
close_screen
|
|
110
104
|
puts @current_dir
|
|
@@ -115,7 +109,6 @@ class SergeantApp
|
|
|
115
109
|
@current_dir = parent
|
|
116
110
|
@selected_index = 0
|
|
117
111
|
@scroll_offset = 0
|
|
118
|
-
needs_refresh = true
|
|
119
112
|
end
|
|
120
113
|
end
|
|
121
114
|
end
|
|
@@ -179,11 +172,13 @@ class SergeantApp
|
|
|
179
172
|
end
|
|
180
173
|
|
|
181
174
|
init_screen
|
|
182
|
-
|
|
175
|
+
if has_colors?
|
|
176
|
+
start_color
|
|
177
|
+
apply_color_theme
|
|
178
|
+
end
|
|
183
179
|
curs_set(0)
|
|
184
180
|
noecho
|
|
185
181
|
stdscr.keypad(true)
|
|
186
|
-
apply_color_theme
|
|
187
182
|
|
|
188
183
|
return unless selected && !selected.empty?
|
|
189
184
|
|
|
@@ -196,6 +191,20 @@ class SergeantApp
|
|
|
196
191
|
@scroll_offset = 0
|
|
197
192
|
end
|
|
198
193
|
|
|
194
|
+
def refresh_items_if_needed
|
|
195
|
+
# Only refresh if directory has changed, or if showing ownership toggle changed
|
|
196
|
+
# This prevents expensive file system operations on every keystroke
|
|
197
|
+
if @current_dir != @last_refreshed_dir
|
|
198
|
+
refresh_items
|
|
199
|
+
@last_refreshed_dir = @current_dir
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def force_refresh
|
|
204
|
+
# Force a refresh even if directory hasn't changed (e.g., after file operations)
|
|
205
|
+
@last_refreshed_dir = nil
|
|
206
|
+
end
|
|
207
|
+
|
|
199
208
|
def refresh_items
|
|
200
209
|
entries = Dir.entries(@current_dir).reject { |e| e == '.' }
|
|
201
210
|
|