rtfm-filemanager 6.0.3 → 6.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rtfm +50 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: face8238835b1e91a466f48f1b55e18dd98f59f5ff6044817b61005f0f47cc43
4
- data.tar.gz: 18ec77b1f5126ca3b5b77bba61b869c18a122bc45823df49a7e0729299cca312
3
+ metadata.gz: 1e57bcca8413887a30c4bb05ba3d370e1485d223e88d7b6aeea2c1fb6008f85f
4
+ data.tar.gz: d067fd93312f608a7e5f4ad05135dcb023660172e0209431b83637698946b9b1
5
5
  SHA512:
6
- metadata.gz: 5a21983a89b862f30134fc45c3be8c1940b6bf23d5cc0aa221401cead34256f706baf5281c192574338ef782c31950ce659292a4538963e351ea0baf4370f8f3
7
- data.tar.gz: 38aff0e9c84745a5616ef48138f7727cf9bd9fc172235e90ce921307cbeab2563b847e76572f9f1a1da89a70ff7200939a3f0fd2c089f586090dc638c39edb13
6
+ metadata.gz: f793a2db1076bdf286356b746444eb88afd6f88e25cf58b15ebbe0f20bef404fa0153718c9dc0b9200ffaa2d318829b57bffff44e7c1518416f030b5eb5cd8e2
7
+ data.tar.gz: 2e7d0e4a7bee42b0821ed29d6534366cad37d19029abd745e2060a07993b5c33d738a85cfb1505fd61e15f0ca9c48524f5be4e169384b012ae3b319145602233
data/bin/rtfm CHANGED
@@ -18,7 +18,7 @@
18
18
  # get a great understanding of the code itself by simply sending
19
19
  # or pasting this whole file into you favorite AI for coding with
20
20
  # a prompt like this: "Help me understand every part of this code".
21
- @version = '6.0.3' # Fixed undefined past_action variable in delete_items method
21
+ @version = '6.0.5' # Fixed symlink following and command bar cd functionality
22
22
 
23
23
  # SAVE & STORE TERMINAL {{{1
24
24
  ORIG_STTY = `stty -g`.chomp
@@ -853,7 +853,7 @@ end
853
853
  # Compile into an array of [Regexp, template] for fast lookup
854
854
  PREVIEW_HANDLERS = preview_specs.map do |exts_str, tmpl|
855
855
  exts = exts_str.split(',').map(&:strip).map { |ext| Regexp.escape(ext) }.join('|')
856
- [/\.#{exts}$/i, tmpl]
856
+ [/\.(#{exts})$/i, tmpl]
857
857
  end
858
858
 
859
859
  # KEY DISPATCH TABLE & HANDLERS {{{1
@@ -1406,7 +1406,21 @@ def follow_symlink # {{{3
1406
1406
  @symlink_history.add(resolved_path)
1407
1407
  target = File.readlink(@selected)
1408
1408
  target = File.expand_path(target, File.dirname(@selected)) unless target.start_with?('/')
1409
- Dir.chdir(target)
1409
+
1410
+ # Check if target is a directory or file
1411
+ if File.directory?(target)
1412
+ Dir.chdir(target)
1413
+ elsif File.file?(target)
1414
+ # If it's a file, change to the directory containing the file
1415
+ target_dir = File.dirname(target)
1416
+ Dir.chdir(target_dir)
1417
+ # Select the target file in the new directory
1418
+ @selected = target
1419
+ else
1420
+ @pB.say("Error: Symlink target does not exist or is not accessible".fg(196))
1421
+ @symlink_history&.clear
1422
+ return
1423
+ end
1410
1424
 
1411
1425
  # Clear history after successful navigation
1412
1426
  @symlink_history.clear
@@ -3865,6 +3879,24 @@ def command_mode # {{{3
3865
3879
  sel = Shellwords.escape(@selected.to_s)
3866
3880
  tg = @tagged.map { |p| Shellwords.escape(p) }.join(' ')
3867
3881
  cmd = raw.gsub('@s', sel).gsub('@t', tg)
3882
+
3883
+ # Handle cd commands specially
3884
+ if cmd.match(/^\s*cd\s*(.*)$/)
3885
+ target = $1.strip
3886
+ target = ENV['HOME'] if target.empty? # Default to home directory
3887
+ target = File.expand_path(target)
3888
+
3889
+ if File.directory?(target)
3890
+ @directory[Dir.pwd] = @index; mark_latest
3891
+ Dir.chdir(target)
3892
+ @pB.update = @pR.update = true
3893
+ refresh
3894
+ return
3895
+ else
3896
+ @pB.say("cd: #{target}: No such directory".fg(196))
3897
+ return
3898
+ end
3899
+ end
3868
3900
  # Determine program name
3869
3901
  prog = Shellwords.split(cmd).first
3870
3902
  prog = File.basename(prog) if prog
@@ -5022,13 +5054,16 @@ def showcontent # SHOW CONTENTS IN THE RIGHT WINDOW {{{2
5022
5054
  temp.write(preview_content)
5023
5055
  temp.close
5024
5056
 
5025
- begin
5026
- showcommand("#{@bat} -n --color=always #{Shellwords.escape(temp.path)}")
5027
- rescue
5057
+ # Try bat with robust fallback
5058
+ bat_cmd = "#{@bat} -n --color=always #{Shellwords.escape(temp.path)}"
5059
+ bat_output = command(bat_cmd, timeout: 10)
5060
+ if bat_output.empty?
5061
+ # Bat failed or returned empty - show plain text
5028
5062
  @pR.say(preview_content)
5029
- ensure
5030
- temp.unlink
5063
+ else
5064
+ @pR.say(bat_output)
5031
5065
  end
5066
+ temp.unlink
5032
5067
  else
5033
5068
  @pR.say(preview_content)
5034
5069
  end
@@ -5042,10 +5077,14 @@ def showcontent # SHOW CONTENTS IN THE RIGHT WINDOW {{{2
5042
5077
  text = File.read(@selected).force_encoding('UTF-8') rescue ''
5043
5078
  if text.valid_encoding?
5044
5079
  if @batuse
5045
- begin
5046
- showcommand("#{@bat} -n --color=always #{Shellwords.escape(@selected)}")
5047
- rescue
5080
+ # Try bat first, with robust fallback
5081
+ bat_cmd = "#{@bat} -n --color=always #{Shellwords.escape(@selected)}"
5082
+ bat_output = command(bat_cmd, timeout: 10)
5083
+ if bat_output.empty?
5084
+ # Bat failed or returned empty - try plain cat
5048
5085
  showcommand("cat #{Shellwords.escape(@selected)}")
5086
+ else
5087
+ @pR.say(bat_output)
5049
5088
  end
5050
5089
  else
5051
5090
  showcommand("cat #{Shellwords.escape(@selected)}")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtfm-filemanager
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.3
4
+ version: 6.0.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-07-04 00:00:00.000000000 Z
11
+ date: 2025-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rcurses