-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
90 lines (62 loc) · 2.02 KB
/
Copy pathREADME
File metadata and controls
90 lines (62 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
xopen
=====
xopen is a simple, fast and suckless replacement of xdg-open.
It determines the appropriate application to open a file or URL
based on the user-defined extension-command 'pairs' in config.h.
It also has optional MIME detection support using libmagic.
config.h has the author's preferred applications on Ubuntu.
Users should replace those with their preferences and compile xopen.
The utility is not supposed to be included in any distro.
Features
--------
* Lightweight and fast
* Minimal configuration
* Minimal dependencies
* File extention detection
* MIME detection (compile-in)
* Works on UNIX-like systems
Installation
------------
$ make
$ sudo make install
To enable MIME detection, install the libmagic development package
from the distro's standard package manager and compile the feature in.
For example, on Ubuntu (and family):
$ sudo apt install libmagic-dev
$ make O_MAGIC=1
$ sudo make install
Usage
-----
$ xopen music.mp3
$ xopen https://www.youtube.com/watch?v=PVD1LNDxOnc
To use with file manager nnn (https://github.com/jarun/nnn), run:
$ NNN_OPENER=xopen nnn "$@"
To let nnn handle text files in the terminal and xopen the rest:
$ NNN_OPENER=xopen nnn -eE "$@"
config.h
--------
xopen uses config.h for configuration,
New 'pairs' can be added with easy to use macros P and WEB_PREFIX,
static const Pair pairs[] = {
P( "\\.mp3", "st", "-e", "mplayer", "%s");
P( WEB_PREFIX("github.com") "/([^/]+)/([^/]+)/actions",
"gh run list --repo %1/%2/%3" )
...
};
For the input,
$ xopen 'https://www.github.com/jarun/xopen'
We get,
%1 - https://www.github.com
%2 - jarun
%3 - xopen
%s - https://www.github.com/jarun/xopen
%0-%9 and %s are available for substituion.
To know more the about capture group sytax, see regex(7).
xopen uses 'posix_spawnp()' to spawn processes faster.
So the following would NOT work.
/* config.h */
P( "\\.gif$",
"wget", "-O", "/tmp/tmp.gif %s && gifview -a /tmp/tmp_gifview.gif")
Credits
-------
Forked from chndlr - https://github.com/bharatvaj/chndlr