filecon 0.1.0 → 0.1.1

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: b254f6b7438d2e85fe743aacb1a2b5946b6b6ab855cb86259ed12a48b6c7e7f9
4
- data.tar.gz: 7c38a7b9c191511d5684def2b6ef312e5d3aef5d37c5b38a22d82654dea96508
3
+ metadata.gz: 7f656a074b7160a9c362539e004b02f9e5d474cfafa6dd009df97040cc4398bf
4
+ data.tar.gz: 28f6a13ebf1aa1d536b69928f0f0e279cb0a5f60adadbf17e6bfbeb30d0213e1
5
5
  SHA512:
6
- metadata.gz: 86fcec1e7a0c0d7d0a77838fc91acdfcb89d81536ea58f348de75cb881fa9e6609e685aaffc8f2d52fa8f3641b1e2af4c6b1a222828e05ca8380c4f82c9a9f61
7
- data.tar.gz: 67bff21259f80836d24af248434943a59b6c6803cfb1711a59b6b4cd2cefec45a045767d2b0fbfaaa5f0476c8472535cf61f7ac3b5467e7815f2b3adc379f8bb
6
+ metadata.gz: aee107ce9e33a5529ce0b574079d22471e7f96b5e42b246bb8b547730b40676a87d5f99f8f9988d108610af0d2c7d922bdefd0d8593b22cf8ce8027942304d7b
7
+ data.tar.gz: b4ca16e0cb4b8b5de25f0cc8088db0178894afe92f270176f6cb39cac7edd2a2f168470376357a85eba183fbfa7c827f547971840322f42bb10e8003b0b87f6a
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users.
15
+
16
+ For the complete license text, see: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # Filecon
2
+
3
+ A terminal-based file manager built on the [Typr](https://codeberg.org/typr/typr) terminal UI toolkit.
4
+
5
+ ## Features
6
+
7
+ - Directory browsing with MIME-type detection
8
+ - Customizable views (content preview, file types, line counts, etc.)
9
+ - Command execution with pipe support
10
+ - Directory and command history
11
+ - Configurable keybindings and colors
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ gem install filecon
17
+ ```
18
+
19
+ Or add to your Gemfile:
20
+
21
+ ```ruby
22
+ gem "filecon", "~> 0.1"
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ```bash
28
+ filecon [directory]
29
+ ```
30
+
31
+ ### Keybindings
32
+
33
+ **Navigation**
34
+ - Arrow keys / Page Up/Down / Home / End — Navigate files
35
+ - Backspace — Go to parent directory
36
+ - Number keys — Open file with default command
37
+ - Tab — Cycle hint numbers for rows beyond the first 10
38
+
39
+ **Actions**
40
+ - `o` — Open list of all commands for selected file
41
+ - `c` — Command history
42
+ - `h` — Help
43
+ - `v` — Views
44
+ - `s` — Sort view
45
+ - `f` — Filter view
46
+ - `r` — Reset view
47
+ - `R` — Toggle recursive listing
48
+
49
+ **Marking**
50
+ - `m` — Mark file
51
+ - `M` — Mark range
52
+ - `a` — Mark all
53
+ - `i` — Invert mark
54
+
55
+ **Directory**
56
+ - `~` — Go to home directory
57
+ - `` ` `` — Go to root directory
58
+ - `d` — Directory history
59
+
60
+ **Other**
61
+ - Enter — Select / confirm
62
+ - Esc — Quit
63
+
64
+ ### Configuration
65
+
66
+ Config is stored at `~/.config/filecon/config.yaml` and includes:
67
+
68
+ - Color settings
69
+ - Command definitions per file type
70
+ - View configurations
71
+ - History limits
72
+
73
+ ## Development
74
+
75
+ ```bash
76
+ git clone https://codeberg.org/typr/filecon
77
+ cd filecon
78
+ bundle install
79
+ rake test
80
+ ```
81
+
82
+ ## License
83
+
84
+ GPL-2.0-only
data/config.yaml CHANGED
@@ -106,7 +106,7 @@ commands:
106
106
  cd: "!cd %name"
107
107
 
108
108
  text:
109
- view: "+less %name"
109
+ view: "+moor %name"
110
110
  edit: "+micro %name"
111
111
  count: "|wc -l %name"
112
112
 
@@ -117,7 +117,7 @@ commands:
117
117
  run: "+ruby %name"
118
118
 
119
119
  html:
120
- terminal: "+w3m %name"
120
+ terminal: "+cha %name"
121
121
  graphics: "|vimb %name"
122
122
 
123
123
  image:
@@ -138,6 +138,72 @@ commands:
138
138
  help: "=%name --help"
139
139
  manual: "+man %name"
140
140
 
141
+ "x-python":
142
+ run: "+python3 %name"
143
+
144
+ "x PERL":
145
+ run: "+perl %name"
146
+
147
+ "x-shellscript":
148
+ run: "+bash %name"
149
+
150
+ "x-javascript":
151
+ run: "+node %name"
152
+
153
+ "x-php":
154
+ run: "+php %name"
155
+
156
+ "x-go":
157
+ run: "+go run %name"
158
+
159
+ "x-rust":
160
+ run: "+rustc %name && ./a.out"
161
+
162
+ java-archive:
163
+ run: "+java -jar %name"
164
+
165
+ "x-c":
166
+ run: "+gcc %name && ./a.out"
167
+
168
+ "x-c++":
169
+ run: "+g++ %name && ./a.out"
170
+
171
+ markdown:
172
+ view: "+glow %name"
173
+ edit: "+micro %name"
174
+
175
+ json:
176
+ view: "=cat %name | jq ."
177
+
178
+ "zip":
179
+ list: "|unzip -l %name"
180
+ extract: "|unzip %name -d %dir"
181
+
182
+ "x-gzip":
183
+ list: "|tar -tzf %name"
184
+ extract: "|tar -xzf %name -C %dir"
185
+
186
+ "x-bzip2":
187
+ list: "|tar -tjf %name"
188
+ extract: "|tar -xjf %name -C %dir"
189
+
190
+ "x-xz":
191
+ list: "|tar -tJf %name"
192
+ extract: "|tar -xJf %name -C %dir"
193
+
194
+ "x-tar":
195
+ list: "|tar -tf %name"
196
+ extract: "|tar -xf %name -C %dir"
197
+
198
+ "epub+zip":
199
+ view: "+folio %name"
200
+
201
+ "font-ttf":
202
+ view: "=fc-query %name | head -20"
203
+
204
+ "font-otf":
205
+ view: "=fc-query %name | head -20"
206
+
141
207
 
142
208
  # =============================================================================
143
209
  # VIEWS
@@ -148,9 +214,11 @@ commands:
148
214
  #
149
215
  # View values can be:
150
216
  # - true Use the built-in column for this field
151
- # - A string A shell command to execute (with %name substitution)
217
+ # - A string Command to execute (with %name substitution)
152
218
  # - A symbol Reference to a system field (e.g., :size, :type, :subtype)
153
219
  #
220
+ # Prefix ! to evaluate as Ruby, prefix | for shell commands.
221
+ #
154
222
  # Available system fields:
155
223
  # target, permissions, owner, group, size,
156
224
  # accessed, modified, created, type, subtype
@@ -162,15 +230,15 @@ commands:
162
230
 
163
231
  views:
164
232
  content:
165
- content: "|head -n 50 %name"
233
+ content: "head -n 50 %name"
166
234
 
167
235
  filetype:
168
236
  type: true
169
237
  subtype: true
170
- description: "|file -b %name"
238
+ description: "file -b %name"
171
239
 
172
240
  lines:
173
- lines: "|wc -l %name"
241
+ lines: "wc -l %name"
174
242
 
175
243
  whatis:
176
244
  whatis: "!open('|whatis %name 2>&1').read.match(/[-:]\\s(.*)$/)[1]"
data/filecon.1 CHANGED
@@ -1,25 +1,37 @@
1
1
  .TH FILECON 1 "2026-07-26" "filecon" "User Commands"
2
2
  .SH NAME
3
- filecon \- interactive terminal file manager with speed-typing navigation
3
+ filecon \- interactive terminal file manager with hint-based navigation
4
4
  .SH SYNOPSIS
5
5
  .B filecon
6
6
  .RI [ directory ]
7
7
  .SH DESCRIPTION
8
8
  .B filecon
9
9
  is a terminal-based file manager built on top of the
10
- .B typerspeed
10
+ .B Typr
11
11
  Ruby library. It displays directory entries in a grid with columns for name,
12
12
  symlink target, permissions, owner, group, size, timestamps, and MIME type.
13
13
  Directories appear first in yellow; files are colored by MIME type.
14
14
  .PP
15
- Navigation is done by typing hint characters (1\-9, 0) displayed at the
16
- start of each row, enabling fast keyboard-only operation.
15
+ Navigation is done by typing hint characters (1\-9, 0, then letters) displayed
16
+ at the start of each row, enabling fast keyboard-only operation.
17
17
  .SH OPTIONS
18
18
  .TP
19
19
  .I directory
20
20
  Starting directory to browse. Defaults to the current working directory.
21
21
  .SH NAVIGATION KEYS
22
22
  .TP
23
+ .B Arrow keys / Page Up/Down / Home / End
24
+ Navigate files
25
+ .TP
26
+ .B Backspace
27
+ Go to parent directory
28
+ .TP
29
+ .B Number keys
30
+ Open file with default command
31
+ .TP
32
+ .B Tab
33
+ Cycle hint numbers for rows beyond the first 10
34
+ .TP
23
35
  .B h
24
36
  Show help
25
37
  .TP
@@ -61,32 +73,18 @@ Quit
61
73
  .SH FILECON KEYS
62
74
  .TP
63
75
  .B o
64
- Open file with configured command (prompts command picker if multiple match)
76
+ Open list of all commands for selected file
65
77
  .TP
66
78
  .B c
67
79
  Browse command history
68
- .SH COMMANDS
69
- Commands are triggered by the [o]pen action on a file. The command executed
70
- depends on the file's MIME type and subtype. If multiple commands match the
71
- file type, a picker is shown.
72
- .SS Command Prefixes
73
- .TP
74
- .B |
75
- Internal execution (output piped to a viewer within the UI)
76
- .TP
77
- .B +
78
- Terminal execution (spawns an external terminal program, e.g. mpv, nano)
79
- .TP
80
- .B !
81
- Ruby code evaluation (result displayed in UI)
82
80
  .SH CONFIGURATION
83
81
  On first run, the default
84
- .B config.rb
82
+ .B config.yaml
85
83
  is copied from the installation directory to
86
84
  .BR ~/.config/filecon/ .
87
85
  .SS Config File Locations
88
86
  .TP
89
- .B ~/.config/filecon/config.rb
87
+ .B ~/.config/filecon/config.yaml
90
88
  Main configuration (colors, commands, views, term)
91
89
  .TP
92
90
  .B ~/.config/filecon/dir_history
@@ -107,35 +105,6 @@ Prompt to pick a file
107
105
  .TP
108
106
  .B %str
109
107
  Prompt for a text string (line input)
110
- .SH CONFIGURATION EXAMPLES
111
- .nf
112
- colors: {
113
- types: {
114
- directory: :yellow,
115
- image: :blue,
116
- video: :cyan,
117
- audio: :green,
118
- text: 146,
119
- 'x-pie-executable': :red
120
- }
121
- }
122
-
123
- commands: {
124
- default: { info: '|file %name', copy: '+rsync --progress %name %dir' },
125
- text: { view: '+less %name', edit: '+nano %name' },
126
- html: { terminal: '+w3m %name', graphics: '|vimb %name' },
127
- image: { play: '|mpv %name' },
128
- video: { play: '|mpv %name' },
129
- pdf: { view: '|mupdf %name' },
130
- 'x-pie-executable': { run: '|%name', run_terminal: '+%name',
131
- help: '+%name --help', manual: '+man %name' }
132
- }
133
-
134
- views: {
135
- content: { content: '|head %name' },
136
- whatis: { whatis: "!open('|whatis %name 2>&1').read.match(...)..." }
137
- }
138
- .fi
139
108
  .SH VIEWS
140
109
  Column views control which fields are shown for each file entry.
141
110
  .TP
@@ -145,11 +114,11 @@ Displays first lines of file content via head(1)
145
114
  .B whatis
146
115
  Shows man page description via whatis(1)
147
116
  .PP
148
- Custom views can be defined in config.rb by adding entries to the views hash.
117
+ Custom views can be defined in config.yaml by adding entries to the views hash.
149
118
  .SH ENVIRONMENT
150
119
  .TP
151
120
  .B TERM
152
- Terminal type used for curses initialization.
121
+ Terminal type used for terminal initialization.
153
122
  .TP
154
123
  .B HOME
155
124
  Used to resolve ~ and config directory path (~/.config/filecon/).
@@ -160,12 +129,12 @@ Configuration and history directory
160
129
  .SH SEE ALSO
161
130
  .BR mpv (1),
162
131
  .BR less (1),
163
- .BR nano (1),
132
+ .BR micro (1),
164
133
  .BR file (1),
165
134
  .BR rsync (1),
166
135
  .BR whatis (1),
167
136
  .BR typr (1)
168
137
  .SH AUTHOR
169
- Part of the Typerspeed ecosystem.
138
+ Kilian Reitmayr
170
139
  .SH LICENSE
171
140
  GPL-2.0-only
@@ -1,3 +1,3 @@
1
1
  module Filecon
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/filecon.rb CHANGED
@@ -64,8 +64,13 @@ class Filecon::App < Typr::Browser
64
64
  view = @views[id]
65
65
  return super if view.is_a? Array
66
66
  data = @data.map.with_index{ |row, id| row + view.values.map{ |cmd|
67
- run( build cmd, id ).read(width).to_s.scrub.gsub(/[\n\t]/, ?|) if
68
- cmd.is_a?(String) }.compact }
67
+ next unless cmd.is_a?(String)
68
+ built = build cmd, id
69
+ io = built[0] == ?! ?
70
+ StringIO.new( eval( built[1..-1] ).to_s ) :
71
+ open( ?| + built + " 2>&1" )
72
+ io.read(width).to_s.scrub.gsub(/[\n\t]/, ?|)
73
+ }.compact }
69
74
  @sequence = [ NAME ] + view.keys.map{ |head|
70
75
  @header.index(head.to_s) || (@header += [head.to_s]; @header.count-1) }
71
76
  clear
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filecon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kilian Reitmayr
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '13.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '13.0'
69
69
  description: A terminal-based file manager with customizable views, commands, and
70
70
  MIME-type based file operations, built on the Typr terminal UI toolkit.
71
71
  email:
@@ -75,13 +75,14 @@ executables:
75
75
  extensions: []
76
76
  extra_rdoc_files: []
77
77
  files:
78
+ - LICENSE
79
+ - README.md
78
80
  - bin/filecon
79
- - config.rb
80
81
  - config.yaml
81
82
  - filecon.1
82
83
  - lib/filecon.rb
83
84
  - lib/filecon/version.rb
84
- homepage: https://github.com/kilianh/filecon
85
+ homepage: https://codeberg.org/typr/filecon
85
86
  licenses:
86
87
  - GPL-2.0-only
87
88
  metadata: {}
data/config.rb DELETED
@@ -1,91 +0,0 @@
1
-
2
- term: ENV["TERM"],
3
- term_hold: ENV["TERM"] + ' --hold',
4
- max_history: 100,
5
-
6
- #########################################################################
7
- #
8
- # COLORS
9
- #
10
- # standard colors: black red green yellow blue magenta cyan white grey
11
- # grey shades: grey with percentage ( e.g. :grey62 for 62% grey )
12
- # 8bit color: 0 - 255
13
- # rgb values: [ 0-255, 0-255, 0-255 ]
14
- #
15
- #########################################################################
16
-
17
- colors: {
18
- types: {
19
- default: [ :white, :black ],
20
- image: :blue,
21
- audio: :green,
22
- video: :cyan,
23
- directory: :yellow,
24
- 'x-pie-executable': :red
25
- }
26
- },
27
-
28
- #########################################################################
29
- #
30
- # COMMANDS
31
- #
32
- # execution type:
33
- #
34
- # | output in status line
35
- # = output in text space
36
- # + run in new terminal
37
- # ! ruby code evaluation
38
- #
39
- # substitutions:
40
- #
41
- # %name - selected file name
42
- # %dir - pick a directory
43
- # %file - pick a file
44
- # %str - read string
45
- #
46
- ########################################################################
47
-
48
- commands: {
49
- # default: { copy: 'cp %s %s' },#, move: 'mv %s %s' },
50
- # default:{ list: '!Grid.new({input: %w[%name] }).pick', open: '|xdg-open',
51
- default:{ open: '|xdg-open %name', diskuse: '|du -hs %name',
52
- info: '=file %name', copy: '+rsync --progress %name %dir',
53
- move: '|mv %name %dir', delete: '|rm %name ' },
54
- directory:{ cd: '!cd %name ' },
55
- text:{ view: '+less %name', edit: '+micro %name',
56
- count: '|wc -l %name' },
57
- troff: { manual: '+man %name' },
58
- "x-ruby":{ run: '+ruby %name' },
59
- html:{terminal: '+w3m %name',graphics: '|vimb %name' },
60
- image:{ play: '|mpv %name' },
61
- video:{ play: '|mpv %name' },
62
- audio:{ play: '|mpv %name' },
63
- pdf:{ view: '|mupdf %name' },
64
- # epub: :pdf
65
- 'x-pie-executable':{ run: '|%name', run_terminal: '+%name',
66
- help: '=%name --help', manual: '+man %name' }
67
- },
68
-
69
- #######################################################################
70
- #
71
- # VIEWS
72
- #
73
- # system infos :
74
- # target permissions owner group size accessed modified created type subtype
75
- #
76
- ######################################################################
77
-
78
- views: {
79
- # detail_ls: { ls: '|ls -l %s' },
80
- # mimetypes: { type: '!type', subtype: '!subtype' },
81
- # type_detail: { info: %w[ size access ], type: '|file -b %s' },
82
- # type_detail:{ size: :size, type: '|file -b %name' },
83
- content:{ content: '|head -n 50 %name' },
84
- filetype:{ type: true, subtype: true, description: '|file -b %name' },
85
- lines:{ lines: '|wc -l %name' },
86
-
87
- # content:{ content: '!`head -n 50 %name `.gsub $/, ?|' },
88
- whatis:{ whatis: #'|whatis %name' }
89
- '!open(\'|whatis %name 2>&1\').read.match(/[-:]\s(.*)$/)[1] ' }
90
- # "!open(\"|whatis %name 2>&1\").read.match(/[-:]\s(.*)$/)[1] " }
91
- }