-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
57 lines (40 loc) · 1.22 KB
/
__init__.py
File metadata and controls
57 lines (40 loc) · 1.22 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
import os.path
import subprocess
import ranger.api
import ranger.api.commands
HOOK_INIT_OLD = ranger.api.hook_init
def hook_init(fm):
fm.execute_console('map YY yoink')
return HOOK_INIT_OLD(fm)
ranger.api.hook_init = hook_init
class yoink(ranger.api.commands.Command):
"""
:yoink
Send to Yoink
"""
allow_abbrev = False
escape_macros_for_shell = True
def execute(self):
import shlex
from functools import partial
import os
if self.rest(1):
paths = shlex.split(self.rest(1))
if paths is None:
return
else:
cwd = self.fm.thisdir
tfile = self.fm.thisfile
if not cwd or not tfile:
self.fm.notify("Error: no file selected for deletion!", bad=True)
return
files = self.fm.thistab.get_selection()
paths = [file.path for file in files]
self._send_to_yoink(paths)
def tab(self, tabnum):
return self._tab_directory_content()
def _send_to_yoink(self, paths):
try:
subprocess.Popen(['open', '-g', '-a', 'Yoink', *paths])
except Exception as e:
self.fm.notify(e, bad=True)