xontrib-superfile 0.0.2__tar.gz
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.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020, Noortheen Raja NJ
|
|
4
|
+
Copyright (c) 2026, TechnoStrife
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: xontrib-superfile
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: superfile support function for xonsh shell
|
|
5
|
+
Keywords: xontrib,xonsh
|
|
6
|
+
Author-Email: TechnoStrife <technostrife@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Natural Language :: English
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: System :: Shells
|
|
13
|
+
Classifier: Topic :: System :: System Shells
|
|
14
|
+
Classifier: Topic :: Terminals
|
|
15
|
+
Classifier: Programming Language :: Python
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Project-URL: Documentation, https://github.com/TechnoStrife/xontrib-superfile/blob/master/README.md
|
|
18
|
+
Project-URL: Code, https://github.com/TechnoStrife/xontrib-superfile
|
|
19
|
+
Project-URL: Issue tracker, https://github.com/TechnoStrife/xontrib-superfile/issues
|
|
20
|
+
Project-URL: repository, https://github.com/TechnoStrife/xontrib-superfile
|
|
21
|
+
Requires-Python: >=3.7
|
|
22
|
+
Requires-Dist: xonsh>=0.12
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# Overview
|
|
27
|
+
[superfile](https://github.com/yorukot/superfile) support function for xonsh shell
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
To install use pip:
|
|
33
|
+
``` bash
|
|
34
|
+
xpip install -U git+https://github.com/TechnoStrife/xontrib-superfile
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
pip package not implemented yet:
|
|
38
|
+
``` bash
|
|
39
|
+
xpip install xontrib-superfile
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
Enable `cd_on_quit` in [superfile config](https://superfile.dev/configure/superfile-config/):
|
|
44
|
+
```
|
|
45
|
+
cd_on_quit = true
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This xontrib adds `sf` alias function. So commands like `cd` will work from superfile.
|
|
49
|
+
``` bash
|
|
50
|
+
$ xontrib load superfile
|
|
51
|
+
$ sf
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Now you can quit superfile normally and xonsh will cd into the last directory.
|
|
55
|
+
|
|
56
|
+
`superfile` can also be launched with shortcut `Ctrl+N`.
|
|
57
|
+
This can be changed by `$XONSH_SUPERFILE_KEY="c-n"` or disabled with `$XONSH_SUPERFILE_KEY=""`.
|
|
58
|
+
(PS [PTK's keybinding guide](https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/key_bindings.html#list-of-special-keys)
|
|
59
|
+
for full list of key names.)
|
|
60
|
+
|
|
61
|
+
## Credits
|
|
62
|
+
|
|
63
|
+
This package was created from [xontrib broot example](https://github.com/jnoortheen/xontrib-broot).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
[superfile](https://github.com/yorukot/superfile) support function for xonsh shell
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
To install use pip:
|
|
8
|
+
``` bash
|
|
9
|
+
xpip install -U git+https://github.com/TechnoStrife/xontrib-superfile
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
pip package not implemented yet:
|
|
13
|
+
``` bash
|
|
14
|
+
xpip install xontrib-superfile
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
Enable `cd_on_quit` in [superfile config](https://superfile.dev/configure/superfile-config/):
|
|
19
|
+
```
|
|
20
|
+
cd_on_quit = true
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This xontrib adds `sf` alias function. So commands like `cd` will work from superfile.
|
|
24
|
+
``` bash
|
|
25
|
+
$ xontrib load superfile
|
|
26
|
+
$ sf
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Now you can quit superfile normally and xonsh will cd into the last directory.
|
|
30
|
+
|
|
31
|
+
`superfile` can also be launched with shortcut `Ctrl+N`.
|
|
32
|
+
This can be changed by `$XONSH_SUPERFILE_KEY="c-n"` or disabled with `$XONSH_SUPERFILE_KEY=""`.
|
|
33
|
+
(PS [PTK's keybinding guide](https://python-prompt-toolkit.readthedocs.io/en/master/pages/advanced_topics/key_bindings.html#list-of-special-keys)
|
|
34
|
+
for full list of key names.)
|
|
35
|
+
|
|
36
|
+
## Credits
|
|
37
|
+
|
|
38
|
+
This package was created from [xontrib broot example](https://github.com/jnoortheen/xontrib-broot).
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
authors = [
|
|
3
|
+
{ name = "TechnoStrife", email = "technostrife@gmail.com" },
|
|
4
|
+
]
|
|
5
|
+
requires-python = ">=3.7"
|
|
6
|
+
dependencies = [
|
|
7
|
+
"xonsh>=0.12",
|
|
8
|
+
]
|
|
9
|
+
name = "xontrib-superfile"
|
|
10
|
+
version = "0.0.2"
|
|
11
|
+
description = "superfile support function for xonsh shell"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
keywords = [
|
|
14
|
+
"xontrib",
|
|
15
|
+
"xonsh",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Natural Language :: English",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Topic :: System :: Shells",
|
|
23
|
+
"Topic :: System :: System Shells",
|
|
24
|
+
"Topic :: Terminals",
|
|
25
|
+
"Programming Language :: Python",
|
|
26
|
+
"Programming Language :: Python :: 3",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = []
|
|
31
|
+
|
|
32
|
+
[project.license]
|
|
33
|
+
text = "MIT"
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Documentation = "https://github.com/TechnoStrife/xontrib-superfile/blob/master/README.md"
|
|
37
|
+
Code = "https://github.com/TechnoStrife/xontrib-superfile"
|
|
38
|
+
"Issue tracker" = "https://github.com/TechnoStrife/xontrib-superfile/issues"
|
|
39
|
+
repository = "https://github.com/TechnoStrife/xontrib-superfile"
|
|
40
|
+
|
|
41
|
+
[tool.pdm.build]
|
|
42
|
+
includes = [
|
|
43
|
+
"xontrib",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[build-system]
|
|
47
|
+
requires = [
|
|
48
|
+
"pdm-backend>=2.0.0",
|
|
49
|
+
]
|
|
50
|
+
build-backend = "pdm.backend"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import subprocess
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from xonsh.built_ins import XSH
|
|
5
|
+
from xonsh.tools import uncapturable
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
superfile = "superfile" # for nixos
|
|
9
|
+
if shutil.which("superfile") is None:
|
|
10
|
+
superfile = "spf"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@uncapturable
|
|
14
|
+
def _sf(args, stdin=None, stdout=None, stderr=None):
|
|
15
|
+
spf_last_dir = Path(XSH.env.get("HOME") + "/.local/state/superfile/lastdir")
|
|
16
|
+
status_code: int = subprocess.call(
|
|
17
|
+
(superfile,) + tuple(args),
|
|
18
|
+
stdin=stdin,
|
|
19
|
+
stderr=stderr,
|
|
20
|
+
stdout=stdout,
|
|
21
|
+
)
|
|
22
|
+
if status_code == 0 and spf_last_dir.is_file():
|
|
23
|
+
with spf_last_dir.open() as f:
|
|
24
|
+
content = f.read()
|
|
25
|
+
if content:
|
|
26
|
+
XSH.builtins.evalx(content)
|
|
27
|
+
spf_last_dir.unlink()
|
|
28
|
+
|
|
29
|
+
return status_code
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
XSH.aliases["sf"] = _sf
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@XSH.builtins.events.on_ptk_create
|
|
36
|
+
def custom_keybindings(bindings, **kw):
|
|
37
|
+
def handler(key_name: str, default: str):
|
|
38
|
+
def do_nothing(_):
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
if key_name not in XSH.env:
|
|
42
|
+
key = default
|
|
43
|
+
else:
|
|
44
|
+
key = XSH.env.get(key_name)
|
|
45
|
+
if key:
|
|
46
|
+
return bindings.add(key)
|
|
47
|
+
return do_nothing
|
|
48
|
+
|
|
49
|
+
@handler("XONSH_SUPERFILE_KEY", "c-n")
|
|
50
|
+
def start_superfile(event):
|
|
51
|
+
_sf([])
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
if __name__ == "__main__":
|
|
55
|
+
from xonsh.built_ins import XSH
|
|
56
|
+
|
|
57
|
+
XSH.load()
|
|
58
|
+
data = XSH.execer.eval("")
|