filecon 0.7.1 → 0.7.3

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: 39b5d282890f2a71e7d928cd772e5e4d1c539bee82f49bd20a078f2fdb3c42d6
4
- data.tar.gz: 654d4cecbf3fadccd929459f6488ff7795006db209d63da38b7e7387a30c312c
3
+ metadata.gz: d1df26a13e05bbbd9358e84639c2c0b00084ba9886a0d6e625ff70f215e02d05
4
+ data.tar.gz: bde313532c0862fbd2374d7e1c58be32d1a3c08eb04679220af34725436a5ab6
5
5
  SHA512:
6
- metadata.gz: 88defb4160b8ff0d433f9de6d01a27c631f8514ac54307bf159bccc64f9506abc179e97fe66dd82a94b46d9d288654a13bd8dac28241a54912b5d403c57c43ea
7
- data.tar.gz: 3f601ebdf45b5015199ee27d9e809d31bee82cbad121d8787562af3d9c74b56a337f6cc6157994a12f0908121bf84f741ddff90afd09e7e6304f0b673e787ab6
6
+ metadata.gz: 59cb001046d5108727fce82ad16e7786b1eb78763bd0861153bd32d3075c674bca8cf3de2ff40ae082a411b5860547f704f3964bd93cd93e38e3729f81ffdd8e
7
+ data.tar.gz: 2657815430c1b069a49e7465d5510bb7e8ccb9595abcab68e66c9a805271f49e489d3ca46b790aac5102aa2819eb96f4bc3a2ff90c7a287eef84a47b40e2f0df
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## [vx.y.z] — __DATE__
4
4
 
5
+ ## [v0.7.3] — 2026-10-30
6
+
7
+ ### Changed
8
+ - All command prompts (`x` execute, the alt-edits, and `%str`) call `Typr.read_line` directly and keep their completions without any `prefixes:` config — the keys fall back to the legacy `|+=!` set
9
+ - `%str` prompting gains TAB completion against the shell, Up/Down command history, and `:shell` highlighting; the partial command loads as editable text and the accepted line replaces it instead of being appended to
10
+ - Configuration stopped layering: the bundled `config.yaml` is the base and `~/.config/filecon/config.yaml` is merged over it (nested maps merge key by key, nulls replace) — the `/etc` cascade and the standalone merge helpers (`layer`, `load_config`) are gone, replaced by one hash merge in the launcher
11
+
12
+ ## [v0.7.2] — 2026-10-19
13
+
14
+ ### Fixed
15
+ - Recurse (and listing in general) survives filenames with invalid byte sequences — path splitting now works on byte copies and the hidden-file check on scrubbed copies, so a single latin-1 relic no longer kills the whole walk with `invalid byte sequence in UTF-8`; startup history parsing got the same one-word hardening instead of silently discarding all history
16
+ - Same-filesystem `move` renames instead of re-copying — `transfer` tries `File.rename` first (instant, `mv`-style, and it moves symlinks as links), falling back to the rsync copy only across filesystems
17
+ - The `|`-command branch no longer crashes when the command cannot launch (`run` reports the launch failure as its return value, which `dispatch` then tried to read like a stream)
18
+ - The listing refreshes right after a transfer completes, with no keypress: the viewed directory (including a destination reached via the `%dir` pick) is rescanned, the trailing repaint-and-wait steps are gone, and the status line keeps only the tally instead of an echoed command line
19
+
5
20
  ## [v0.7.1] — 2026-10-13
6
21
 
7
22
  ### Fixed
data/README.md CHANGED
@@ -87,14 +87,13 @@ Command and history popups open in `/` narrow mode. Type a few characters to **n
87
87
 
88
88
  ### Configuration
89
89
 
90
- Config is layered, lowest to highest precedence: the bundled defaults,
91
- `/etc/filecon/config.yaml` (system-wide, read if present, never written),
92
- then `~/.config/filecon/config.yaml` (yours). On first run the user file is
90
+ Config loads in two layers: the bundled `config.yaml` as the base and
91
+ `~/.config/filecon/config.yaml` merged on top — nested mappings merge key by
92
+ key, explicit nulls replace an inherited value. On first run the user file is
93
93
  created from the bundled config with every setting commented out except a
94
94
  live + prefix with your detected terminal — a documented template that
95
- overrides nothing else until edited, so new defaults
96
- flow through on upgrade. Set only what you change; an explicit empty value
97
- deletes an inherited key. It includes:
95
+ overrides nothing else until edited. Delete the file to reseed the template
96
+ on the next launch. It includes:
98
97
 
99
98
  - Color settings (named colors, 8-bit palette, RGB triplets, base-palette overrides) — including the `colors.commands` pair used by the command picker and status line
100
99
  - The `e[x]ecute` prompt always tints with the `:shell` scheme (first word red, `--options` blue); the `=` output viewer uses `:generic`
@@ -111,7 +110,7 @@ State and history files live under `~/.local/share/filecon/`.
111
110
  - `=` — display output in the text viewer
112
111
  - `!` — evaluate as Ruby code
113
112
 
114
- **Substitution variables:** `%name` (file path), `%dir` (directory picker), `%file` (file picker), `%cmd` (PATH executable picker), `%str` (text input)
113
+ **Substitution variables:** `%name` (file path), `%dir` (directory picker), `%file` (file picker), `%cmd` (PATH executable picker), `%str` (text input; TAB completes against the shell, Up/Down recalls command history)
115
114
 
116
115
  See `filecon(1)` for the full manual.
117
116
 
data/bin/filecon CHANGED
@@ -22,11 +22,17 @@ begin
22
22
 
23
23
  [dh_path, ch_path].each { |f| FileUtils.touch f }
24
24
 
25
- parse = ->(p) { File.readlines(p).map { |l| s = l.chomp.split(",", 2); [s[0].to_i, s[1]] } rescue [] }
25
+ parse = ->(p) { File.readlines(p).map { |l| s = l.chomp.scrub.split(",", 2); [s[0].to_i, s[1]] } rescue [] }
26
26
 
27
- config = Filecon.load_config(bundled_path, "/etc/filecon/config.yaml", config_path)
27
+ deep = ->(a, b) { b.each { |k, v|
28
+ v.nil? ? a.delete(k) : (Hash === v && Hash === a[k] ? a[k] = deep[a[k], v] : a[k] = v) } ; a }
29
+ config = deep[
30
+ YAML.safe_load(File.read(bundled_path), permitted_classes: [Symbol]) || {},
31
+ File.exist?(config_path) ?
32
+ YAML.safe_load(File.read(config_path), permitted_classes: [Symbol]) || {} : {}]
33
+ colors = config["colors"] ||= {}
28
34
 
29
- Typr.init config["colors"]["default"]
35
+ Typr.init colors["default"]
30
36
  Typr.clear
31
37
 
32
38
  app = Filecon::App.new( right: -1, bottom: -1,
@@ -35,13 +41,13 @@ begin
35
41
  path: { config: config_path, state: state_dir, dir_history: dh_path,
36
42
  cmd_history: ch_path },
37
43
  directory: ARGV.first || ?., keymap: { cmd_history: ?c, dir_history: ?d, recurse: ?R, open_current: ?` },
38
- colors: config["colors"] || {},
39
- views: config["views"] || {},
40
- commands: config["commands"] || {},
44
+ colors: colors,
45
+ views: config["views"],
46
+ commands: config["commands"],
41
47
  prefixes: config["prefixes"],
42
48
  bindings: config["bindings"],
43
- max_history: config["max_history"] || 100,
44
- top_history: config["top_history"] || 10,
49
+ max_history: config["max_history"],
50
+ top_history: config["top_history"],
45
51
  filter_dirs: config["filter_dirs"] )
46
52
  Typr.on_resize { app.show }
47
53
  app.import_shell_history
data/config.yaml CHANGED
@@ -181,7 +181,7 @@ commands:
181
181
  run_terminal: "+%name %str"
182
182
 
183
183
  printable:
184
- edit: "+micro %name"
184
+ edit: "+nano %name"
185
185
  view: "=cat %name"
186
186
  count: "|wc -l %name | cut -wf1"
187
187
  search: "=grep -n %str %name"
@@ -249,7 +249,7 @@ commands:
249
249
 
250
250
  markdown:
251
251
  view: "=glow %name"
252
- edit: "+micro %name"
252
+ edit: "+nano %name"
253
253
 
254
254
  json:
255
255
  view: "=cat %name | jq ."
@@ -291,6 +291,9 @@ commands:
291
291
  "font-otf":
292
292
  view: "=fc-query %name | head -20"
293
293
 
294
+ "x-empty":
295
+ edit: "+nano %name"
296
+ view: "=cat %name"
294
297
 
295
298
  # =============================================================================
296
299
  # VIEWS
data/filecon.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH FILECON 1 "2026-10-13" "filecon 0.7.1" "User Commands"
1
+ .TH FILECON 1 "2026-10-30" "filecon 0.7.3" "User Commands"
2
2
  .SH NAME
3
3
  filecon \- a file and command manager that lives between terminal and shell
4
4
  .SH SYNOPSIS
@@ -93,23 +93,18 @@ first, then the remaining entries in most-recent order. The
93
93
  setting in config.yaml (default 10) controls how many frequent entries lead
94
94
  the list.
95
95
  .SH CONFIGURATION
96
- Configuration is layered, lowest to highest precedence: the bundled
96
+ Configuration loads in two layers: the bundled
97
97
  .B config.yaml
98
- in the installation directory,
99
- .B /etc/filecon/config.yaml
100
- (system-wide, read if present, never written),
101
- then the user file below.
98
+ in the installation directory is the base, and the user file below is
99
+ merged on top — nested mappings merge key by key, an explicit null
100
+ replaces an inherited value.
102
101
  On first run a documented template is written to
103
102
  .BR ~/.config/filecon/config.yaml :
104
103
  the bundled defaults with every setting commented out except a live +
105
104
  prefix with your detected terminal, overriding nothing else until edited.
106
- Set only what you change; an explicit empty
107
- value deletes an inherited key.
105
+ Delete the file to reseed the template on the next launch.
108
106
  .SS Config File Locations
109
107
  .TP
110
- .B /etc/filecon/config.yaml
111
- System-wide overrides (optional)
112
- .TP
113
108
  .B ~/.config/filecon/config.yaml
114
109
  Main configuration (colors, commands, views)
115
110
  .TP
@@ -1,3 +1,3 @@
1
1
  module Filecon
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.3"
3
3
  end
data/lib/filecon.rb CHANGED
@@ -14,31 +14,6 @@ require_relative "filecon/version"
14
14
 
15
15
  module Filecon
16
16
 
17
- # Layered configuration: bundled defaults < system (/etc) < user (~/.config).
18
- # Merges +over+ into +base+: hashes recurse, scalars and arrays replace, an
19
- # explicit null deletes an inherited key, absent keys fall through.
20
- def self.layer base, over
21
- over.each do |k, v|
22
- if v.nil? and base.key?(k) then base.delete(k)
23
- elsif v.is_a?(Hash) and base[k].is_a?(Hash) then layer(base[k], v)
24
- else base[k] = v end
25
- end
26
- base
27
- end
28
-
29
- # Load and merge configuration layers in order; missing files are skipped.
30
- # Every present layer must parse to a mapping; anything else raises naming
31
- # the file, so a broken layer fails loud instead of failing deep in the
32
- # merge or silently booting defaults.
33
- def self.load_config *paths
34
- paths.filter_map { |p|
35
- next unless p and File.exist?(p)
36
- cfg = YAML.safe_load(File.read(p), permitted_classes: [Symbol])
37
- raise "#{p} must contain a YAML mapping, got #{cfg.class}" unless cfg.nil? or cfg.is_a?(Hash)
38
- cfg
39
- }.reduce({}) { |merged, cfg| layer(merged, cfg || {}) }
40
- end
41
-
42
17
  # Documented template: every setting commented out, docs kept — except one
43
18
  # live + prefix with the detected terminal, so windowed commands work out
44
19
  # of the box. Parses to just that override until edited. -e flags ride on
@@ -62,7 +37,7 @@ class Filecon::App < Typr::Browser
62
37
  def directory
63
38
  @directory.is_a?(Array) ? @directory.inject { |a, b|
64
39
  common = []
65
- a.split("/").zip(b.split("/")).each { |x, y|
40
+ a.b.split("/").zip(b.b.split("/")).each { |x, y|
66
41
  break if x != y
67
42
  common << x
68
43
  }
@@ -78,7 +53,7 @@ class Filecon::App < Typr::Browser
78
53
  Dir.exist?(d) && File.readable?(d) && File.executable?(d) ? d : nil }
79
54
  prefix = dirs.inject { |a, b|
80
55
  common = []
81
- a.split("/").zip(b.split("/")).each { |x, y|
56
+ a.b.split("/").zip(b.b.split("/")).each { |x, y|
82
57
  break if x != y
83
58
  common << x
84
59
  }
@@ -103,10 +78,16 @@ class Filecon::App < Typr::Browser
103
78
  end
104
79
  end
105
80
 
81
+ # Command-start characters for the line prompts: the configured +prefixes:
82
+ # keys, or the legacy +|+=!-+ default when none are configured.
83
+
84
+ def prefixes; @prefixes&.keys&.join || "|+=!" end
85
+
106
86
  def execute
107
- cmd = @user.cli("> ", redraw: method(:show),
108
- history: @cmd_history.map { |_, cmd| cmd },
109
- prefixes: @prefixes&.keys&.join, regex: :shell)
87
+ cmd = Typr.read_line(color_code(@user.colors[:default]) + "> " +
88
+ color_code(@user.colors[:answer]), left: @user.left, top: @user.top,
89
+ redraw: method(:show), history: @cmd_history.map { |_, cmd| cmd },
90
+ prefixes: prefixes, regex: :shell)
110
91
  return unless cmd
111
92
  dispatch cmd
112
93
  end
@@ -187,8 +168,10 @@ class Filecon::App < Typr::Browser
187
168
  cmd = build pair.last, id, pair.first
188
169
  return unless cmd
189
170
  if alt
190
- edited = @user.cli("> ", initial: cmd, redraw: method(:show),
191
- prefixes: @prefixes&.keys&.join)
171
+ edited = Typr.read_line(color_code(@user.colors[:default]) + "> " +
172
+ color_code(@user.colors[:answer]), left: @user.left, top: @user.top,
173
+ initial: cmd, redraw: method(:show),
174
+ regex: @user.colors[:regex], prefixes: prefixes)
192
175
  return unless edited
193
176
  cmd = build(edited, id, pair.first)
194
177
  return unless cmd
@@ -260,6 +243,8 @@ class Filecon::App < Typr::Browser
260
243
  if File.directory?( src ) and !File.symlink?( src )
261
244
  FileUtils.mkdir_p( dst )
262
245
  done += 1
246
+ elsif op == :move and ( File.rename(src, dst) rescue false )
247
+ done += 1
263
248
  else
264
249
  if @has_rsync.nil?
265
250
  begin
@@ -323,9 +308,8 @@ class Filecon::App < Typr::Browser
323
308
  colors: { default: @colors[:error], border: @colors[:border] },
324
309
  alternate: false).pick(:none)
325
310
  end
326
- show
327
- Typr.read_key
328
- tally
311
+ @user.show tally
312
+ nil
329
313
  end
330
314
 
331
315
  def resolve_conflict src, dst
@@ -375,10 +359,14 @@ class Filecon::App < Typr::Browser
375
359
  esc = cmd[0] == ?! ? /[\\"$#]/ : /[\\"$`]/
376
360
  cmd += ?" + result.gsub(esc){ |m| "\\#{m}" } + ?"
377
361
  when '%str'
378
- prompt = cmd.empty? || cmd.end_with?(' ') ? cmd : "#{cmd} "
379
- query = @user.ask("#{prefix}#{prompt}" => :line)
362
+ initial = cmd.empty? || cmd.end_with?( ' ' ) ? cmd : "#{cmd} "
363
+ query = Typr.read_line(reset + "> " + prefix +
364
+ color_code( @colors[:answer] ), left: @user.left, top: @user.top,
365
+ initial: initial, redraw: method(:show),
366
+ history: @cmd_history.map { |_, c| c },
367
+ prefixes: prefixes, regex: :shell)
380
368
  return unless query
381
- cmd += query
369
+ cmd = query
382
370
  end
383
371
  str = post
384
372
  end
@@ -454,7 +442,7 @@ class Filecon::App < Typr::Browser
454
442
  io.close
455
443
  text.pick(:none)
456
444
  elsif cmd[0] == ?|
457
- line = io.gets
445
+ line = io&.gets
458
446
  if line
459
447
  nc, ac = @colors[:commands]
460
448
  head = name ? "#{color_code(nc)}#{name}#{color_code(ac)}:" : color_code(nc)
@@ -469,7 +457,6 @@ class Filecon::App < Typr::Browser
469
457
  head = name ? "#{color_code(nc)}#{name}#{color_code(ac)}:" : color_code(nc)
470
458
  @user.show "> #{head}#{cmd[1..-1]}#{color_code(@colors[:default])} : #{output.lines.last}"
471
459
  show
472
- Typr.read_key
473
460
  end
474
461
  end
475
462
  if io.is_a?(IO) and !io.closed?
@@ -483,6 +470,10 @@ class Filecon::App < Typr::Browser
483
470
  end
484
471
  Array(id).sort.reverse.each { |i| refresh_row i } if id && cmd[0..2] != '!cd' && @directory == dir
485
472
  @selected[:rows] = [] if id && @directory != dir
473
+ if id && cmd[0..2] != '!cd' && @directory != dir
474
+ cd @directory
475
+ sort
476
+ end
486
477
  show
487
478
  io
488
479
  end
@@ -520,8 +511,10 @@ class Filecon::App < Typr::Browser
520
511
 
521
512
  entry = ordered[n][1]
522
513
  if is_cmd and picker.modifier == :alt
523
- edited = @user.cli("> ", initial: entry, redraw: -> { picker.show },
524
- prefixes: @prefixes&.keys&.join)
514
+ edited = Typr.read_line(color_code(@user.colors[:default]) + "> " +
515
+ color_code(@user.colors[:answer]), left: @user.left, top: @user.top,
516
+ initial: entry, redraw: -> { picker.show },
517
+ regex: @user.colors[:regex], prefixes: prefixes)
525
518
  return unless edited
526
519
  entry = build(edited, nil)
527
520
  return unless entry
@@ -604,7 +597,7 @@ class Filecon::App < Typr::Browser
604
597
  return if @directory.is_a?(Array)
605
598
  root = File.expand_path(@directory)
606
599
  dirs = [root] + Dir.glob("**/*", File::FNM_DOTMATCH, base: root).sort.filter_map { |p|
607
- next if !@show_hidden && p.split(?/).any? { |c| c.start_with?(?.) }
600
+ next if !@show_hidden && p.scrub.split(?/).any? { |c| c.start_with?(?.) }
608
601
  d = File.expand_path(p, root)
609
602
  d if File.directory?(d)
610
603
  }
@@ -640,8 +633,8 @@ class Filecon::App < Typr::Browser
640
633
  " entries first, then the rest in most-recent order. The top_history\n" \
641
634
  " setting in config.yaml (default 10) controls how many most-used entries\n" \
642
635
  " lead the list. In command history, Alt+number edits the picked entry instead of running it.\n\n" \
643
- "#{y}CONFIG:#{d}\n ~/.config/filecon/config.yaml\n /etc/filecon/config.yaml\n" \
644
- " (bundled defaults ship with the gem; delete your file to reseed its template)\n",
636
+ "#{y}CONFIG:#{d}\n ~/.config/filecon/config.yaml\n" \
637
+ " (your settings override the bundled defaults)\n",
645
638
  top: 2, right: -2, bottom: -3,
646
639
  colors: { border: @colors[:border] },
647
640
  border: :round )
@@ -676,10 +669,13 @@ class Filecon::App < Typr::Browser
676
669
  $palette = @colors.filter_map { |k, v|
677
670
  [k.to_sym, v] if %i[black red green yellow blue magenta cyan white].include?(k.to_s.to_sym) }.to_h
678
671
  @rawsort[NAME] = false
672
+ @colors ||= {}
679
673
  @cmd_history ||= []
680
674
  @dir_history ||= []
681
675
  @path ||= {}
682
- @top_history = args[:top_history] || 10
676
+ @views ||= {}
677
+ @commands ||= {}
678
+ @top_history = args[:top_history]
683
679
  @user.reset
684
680
  end
685
681
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filecon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kilian Reitmayr
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-10-13 00:00:00.000000000 Z
10
+ date: 2026-10-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: typr