How to script ranger to copy a file to another directory via python
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
ranger
is a command line file manager that can be extended with python. The commands.py
file contains examples of the built in commands:
https://github.com/ranger/ranger/blob/master/ranger/config/commands.py
I can see how to delete files via self.fm.delete()
and I have explored the fm.py
file and don't see a function that looks to be exposed that would allow me to copy files in a straightforward way (but I'm not a python dev so maybe I don't understand it):
https://github.com/ranger/ranger/blob/master/ranger/core/fm.py
I just want a function that will copy the current selection
to a ~/.directory/
.
I know I could do this with a key mapping, but I want to do it in python so that I can extend it, but I can't get past this one basic step.
python ranger
add a comment |Â
up vote
0
down vote
favorite
ranger
is a command line file manager that can be extended with python. The commands.py
file contains examples of the built in commands:
https://github.com/ranger/ranger/blob/master/ranger/config/commands.py
I can see how to delete files via self.fm.delete()
and I have explored the fm.py
file and don't see a function that looks to be exposed that would allow me to copy files in a straightforward way (but I'm not a python dev so maybe I don't understand it):
https://github.com/ranger/ranger/blob/master/ranger/core/fm.py
I just want a function that will copy the current selection
to a ~/.directory/
.
I know I could do this with a key mapping, but I want to do it in python so that I can extend it, but I can't get past this one basic step.
python ranger
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
ranger
is a command line file manager that can be extended with python. The commands.py
file contains examples of the built in commands:
https://github.com/ranger/ranger/blob/master/ranger/config/commands.py
I can see how to delete files via self.fm.delete()
and I have explored the fm.py
file and don't see a function that looks to be exposed that would allow me to copy files in a straightforward way (but I'm not a python dev so maybe I don't understand it):
https://github.com/ranger/ranger/blob/master/ranger/core/fm.py
I just want a function that will copy the current selection
to a ~/.directory/
.
I know I could do this with a key mapping, but I want to do it in python so that I can extend it, but I can't get past this one basic step.
python ranger
ranger
is a command line file manager that can be extended with python. The commands.py
file contains examples of the built in commands:
https://github.com/ranger/ranger/blob/master/ranger/config/commands.py
I can see how to delete files via self.fm.delete()
and I have explored the fm.py
file and don't see a function that looks to be exposed that would allow me to copy files in a straightforward way (but I'm not a python dev so maybe I don't understand it):
https://github.com/ranger/ranger/blob/master/ranger/core/fm.py
I just want a function that will copy the current selection
to a ~/.directory/
.
I know I could do this with a key mapping, but I want to do it in python so that I can extend it, but I can't get past this one basic step.
python ranger
python ranger
asked Jan 20 '17 at 18:32
hermancain
699612
699612
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
Welp... this is what I ended up with, but I'm not sure if there is a better way:
class cpto(Command):
""":cpto
copies the file to a special directory
"""
def execute(self):
self.fm.execute_console("shell cp %s ~/.special_directory &")
I was able to explore the fm
object more in-depth by cloning the ranger repo, cd
ing into it, and running pydoc.ranger.core.actions
add a comment |Â
up vote
0
down vote
You can have the same function by creating a mapping in your rc.conf
file as follows:
map cto shell -f cp %s ~/.special_directory/
Then, you will select the files you need to copy, and press cto
.
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Welp... this is what I ended up with, but I'm not sure if there is a better way:
class cpto(Command):
""":cpto
copies the file to a special directory
"""
def execute(self):
self.fm.execute_console("shell cp %s ~/.special_directory &")
I was able to explore the fm
object more in-depth by cloning the ranger repo, cd
ing into it, and running pydoc.ranger.core.actions
add a comment |Â
up vote
0
down vote
accepted
Welp... this is what I ended up with, but I'm not sure if there is a better way:
class cpto(Command):
""":cpto
copies the file to a special directory
"""
def execute(self):
self.fm.execute_console("shell cp %s ~/.special_directory &")
I was able to explore the fm
object more in-depth by cloning the ranger repo, cd
ing into it, and running pydoc.ranger.core.actions
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Welp... this is what I ended up with, but I'm not sure if there is a better way:
class cpto(Command):
""":cpto
copies the file to a special directory
"""
def execute(self):
self.fm.execute_console("shell cp %s ~/.special_directory &")
I was able to explore the fm
object more in-depth by cloning the ranger repo, cd
ing into it, and running pydoc.ranger.core.actions
Welp... this is what I ended up with, but I'm not sure if there is a better way:
class cpto(Command):
""":cpto
copies the file to a special directory
"""
def execute(self):
self.fm.execute_console("shell cp %s ~/.special_directory &")
I was able to explore the fm
object more in-depth by cloning the ranger repo, cd
ing into it, and running pydoc.ranger.core.actions
answered Jan 20 '17 at 20:15
hermancain
699612
699612
add a comment |Â
add a comment |Â
up vote
0
down vote
You can have the same function by creating a mapping in your rc.conf
file as follows:
map cto shell -f cp %s ~/.special_directory/
Then, you will select the files you need to copy, and press cto
.
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
add a comment |Â
up vote
0
down vote
You can have the same function by creating a mapping in your rc.conf
file as follows:
map cto shell -f cp %s ~/.special_directory/
Then, you will select the files you need to copy, and press cto
.
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You can have the same function by creating a mapping in your rc.conf
file as follows:
map cto shell -f cp %s ~/.special_directory/
Then, you will select the files you need to copy, and press cto
.
You can have the same function by creating a mapping in your rc.conf
file as follows:
map cto shell -f cp %s ~/.special_directory/
Then, you will select the files you need to copy, and press cto
.
answered Sep 22 at 20:54
user314583
1
1
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
add a comment |Â
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
Except for the part where the OP says: âÂÂI know I could do this with a key mapping, but I want to do it in pythonâÂÂ
â Jeff Schaller
Sep 22 at 21:23
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f338941%2fhow-to-script-ranger-to-copy-a-file-to-another-directory-via-python%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password