-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with ranger #61
Comments
Sorry for reply late, I was studying writing plugins for ranger, because I seldom use it. here is the first script for path tracking: import ranger.api
import subprocess
old_hook_init = ranger.api.hook_init
PATH_LUA='/usr/bin/lua'
PATH_ZLUA='/home/skywind/.local/etc/z.lua'
def hook_init(fm):
def update_zlua(signal):
subprocess.Popen([PATH_LUA, PATH_ZLUA, "--add", signal.new.path])
fm.signal_bind('cd', update_zlua)
return old_hook_init(fm)
ranger.api.hook_init = hook_init Remember to change |
OK, finished, import ranger.api
import subprocess
old_hook_init = ranger.api.hook_init
PATH_LUA='/usr/bin/lua'
PATH_ZLUA='/home/skywind/.local/etc/z.lua'
def hook_init(fm):
def update_zlua(signal):
subprocess.Popen([PATH_LUA, PATH_ZLUA, "--add", signal.new.path])
fm.signal_bind('cd', update_zlua)
return old_hook_init(fm)
ranger.api.hook_init = hook_init
class z(ranger.api.commands.Command):
def execute (self):
args = self.args[1:]
if args:
directory = subprocess.check_output([PATH_LUA, PATH_ZLUA, '--cd'] + args)
directory = directory.decode("utf-8", "ignore")
directory = directory.rstrip('\n')
self.fm.cd(directory)
return True |
I submitted a You can use it in your export RANGER_ZLUA="/path/to/z.lua" |
I mention it in the FAQ |
Thank you very much! |
Can you explain more how this works? I followed the instructions but don't see a |
It's just like Using |
What would be the equivalent command for z.lua to integrate with ranger directory switch?
https://github.com/ranger/ranger/wiki/Integration-with-other-programs#fasd
Great tool, by the way!
Thanks,
-rif
The text was updated successfully, but these errors were encountered: