ruby-shell 3.4.4 → 3.4.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/bin/rsh +22 -2
  4. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 587406cf97c8f8aeba405779d229d073b0c8963b24c224edd1a24d72441411d5
4
- data.tar.gz: aa4ea0471988e2004e057c575684f6d2a3f2b3875872e49ee769f22045d52bd5
3
+ metadata.gz: 1a0c1e45454167bc454071a1419673d2ca195980970208c54b2745870709e024
4
+ data.tar.gz: 4981d0f400409d059e703df8d6daa9eab3be19e6a4e0da3f96de7533aac66c6c
5
5
  SHA512:
6
- metadata.gz: 8fc3e11246348f5eae8bec22ac1d62d990a5ab2727573202363a9c04d6f6e8448bb265fd776ae664004249ac9133baf12a78042da5045b8fe3589e8484414221
7
- data.tar.gz: a4305bfba19e86a643440a4d6727e71c3e5d74467fdb9ccf5070345f66a5792256276b299e04714e389d6801e5aadf0253b3da645203bb4135412f5ffa9ec9a2
6
+ metadata.gz: 6632764744a12eb79fda32cf92677e44e0ded8cab07e9b41cad11cfb911df0f678c63d9f8448390c8556fca89d11bb83a37864050f75c716c9589e05c88d4e67
7
+ data.tar.gz: fe1dee534ac7e91a7ad925ba6845acc49e9ca897763486973589d5f8997a6b78771ae1155f20ef8bf42d982a3fe4f37255a33a8a1499223cec77fa3b7319b935
data/README.md CHANGED
@@ -476,6 +476,27 @@ Also, a special variable for better LS_COLOR setup:
476
476
  ```
477
477
  Point `@lscolors` to a file that sets your LS_COLORS variable. Use [my extended LS_COLORS setup](https://github.com/isene/LS_COLORS) to make this really fancy.
478
478
 
479
+ ### Directory Colors in Prompt
480
+
481
+ **rsh is fully LS_COLORS compliant** - both tab completion and prompt paths use LS_COLORS for consistent theming.
482
+
483
+ You can override directory colors in the prompt using pattern matching (like RTFM's @topmatch):
484
+ ```ruby
485
+ @dir_colors = [
486
+ ["PassionFruit", 171], # Paths containing "PassionFruit" -> magenta
487
+ ["Dualog", 72], # Paths containing "Dualog" -> cyan
488
+ ["/G", 172], # Paths containing "/G" -> orange
489
+ ]
490
+ ```
491
+
492
+ How it works:
493
+ - Array of `[pattern, color]` pairs
494
+ - First matching pattern wins (uses Ruby's `include?` method)
495
+ - If no pattern matches, uses LS_COLORS 'di' value (your configured directory color)
496
+ - Pattern matching is simple substring matching: "/G" matches "/home/user/Main/G/..."
497
+
498
+ This lets you visually distinguish different project directories at a glance in your prompt.
499
+
479
500
  You can add any Ruby code to your .rshrc.
480
501
 
481
502
  # Enter the world of Ruby
data/bin/rsh CHANGED
@@ -8,7 +8,7 @@
8
8
  # Web_site: http://isene.com/
9
9
  # Github: https://github.com/isene/rsh
10
10
  # License: Public domain
11
- @version = "3.4.4" # Split .rshrc/.rshstate, performance improvements, symlink colors, auto-migration
11
+ @version = "3.4.5" # Dynamic directory colors in prompt via LS_COLORS integration
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -1262,6 +1262,18 @@ def get_file_color(filename) # Get color for a file based on LS_COLORS
1262
1262
  file_color = 7 if file_color == 0 # 0 means "reset to default" in LS_COLORS
1263
1263
  file_color
1264
1264
  end
1265
+ def get_dir_color(path) # Get color for directory path in prompt
1266
+ # Check pattern matches first (like RTFM's @topmatch)
1267
+ # Set @dir_colors in .rshrc as array of [pattern, color] pairs
1268
+ # Example: @dir_colors = [["PassionFruit", 171], ["Dualog", 72], ["/G", 172], ["", 33]]
1269
+ if @dir_colors && @dir_colors.is_a?(Array)
1270
+ match = @dir_colors.find { |pattern, _| pattern.empty? || path.include?(pattern) }
1271
+ return match.last if match
1272
+ end
1273
+
1274
+ # Fall back to LS_COLORS directory color
1275
+ @ls_colors['di'] || 33
1276
+ end
1265
1277
  def format_tab_item(item, show_metadata: false) # Format tab item with color and optional metadata
1266
1278
  color = get_file_color(item)
1267
1279
  formatted = item
@@ -1335,7 +1347,12 @@ def cmd_check(str) # Check if each element on the readline matches commands, nic
1335
1347
  # Color bookmarks (after commands and nicks)
1336
1348
  el.c(@c_bookmark)
1337
1349
  elsif File.exist?(clean_el)
1338
- el.c(@c_path)
1350
+ # Use directory color matching for directories, @c_path for files
1351
+ if File.directory?(clean_el)
1352
+ el.c(get_dir_color(File.expand_path(clean_el)))
1353
+ else
1354
+ el.c(@c_path)
1355
+ end
1339
1356
  elsif el[0] == "-"
1340
1357
  el.c(@c_switch)
1341
1358
  else
@@ -3211,6 +3228,8 @@ begin # Load .rshrc and populate @history
3211
3228
  exit
3212
3229
  end
3213
3230
  firstrun unless File.exist?(Dir.home+'/.rshrc') # Initial loading - to get history
3231
+ # Initialize @ls_colors with defaults so get_dir_color() works in .rshrc prompt
3232
+ @ls_colors = { 'di' => 33, 'ex' => 2, 'ln' => 14, 'fi' => 7 }
3214
3233
  load_rshrc_safe
3215
3234
  migrate_to_split_config # Migrate from old format if needed (v3.4.3+)
3216
3235
  # Load login shell files if rsh is running as login shell
@@ -3235,6 +3254,7 @@ begin # Load .rshrc and populate @history
3235
3254
  ENV["TERM"] = "rxvt-unicode-256color"
3236
3255
  ENV["PATH"] ? ENV["PATH"] += ":" : ENV["PATH"] = ""
3237
3256
  ENV["PATH"] += "/home/#{@user}/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
3257
+ # Load actual LS_COLORS from file (now that @lscolors is set from .rshrc)
3238
3258
  if @lscolors and File.exist?(@lscolors)
3239
3259
  ls = File.read(@lscolors)
3240
3260
  ls.sub!(/export.*/, '')
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.4
4
+ version: 3.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-25 00:00:00.000000000 Z
11
+ date: 2025-10-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
14
14
  history, syntax highlighting, theming, auto-cd, auto-opening files and more. UPDATE
15
- v3.4.0: COMPLETION LEARNING - Shell learns which TAB completions you use most and
16
- intelligently ranks them higher. Context-aware learning per command. :completion_stats
17
- shows patterns. Persistent across sessions. Plus all v3.3 features: quote-less syntax,
18
- parametrized nicks, Ctrl-G editing, validation rules, shell scripts!'
15
+ v3.4.5: FULL LS_COLORS COMPLIANCE - Prompt and command line now use LS_COLORS with
16
+ pattern-based directory coloring. Configure @dir_colors like RTFM''s @topmatch for
17
+ visual project distinction. Plus v3.4.0: Completion learning, context-aware ranking,
18
+ persistent patterns across sessions!'
19
19
  email: g@isene.com
20
20
  executables:
21
21
  - rsh