Last active
July 22, 2016 19:09
-
-
Save fphammerle/8d00f83c4eb21d0c3cee46793730946b to your computer and use it in GitHub Desktop.
ranger plugin: update gnu screen's working directory whenever the current directory in ranger changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import ranger.api | |
import subprocess | |
# https://github.com/ranger/ranger/wiki/Signals-and-Hooks | |
def ranger_signal_bind(signal_name): | |
def decorate(handler): | |
old_hook_ready = ranger.api.hook_ready | |
def hook_ready(fm): | |
fm.notify('%s %r' % (signal_name, handler)) | |
fm.signal_bind(signal_name, handler) | |
return old_hook_ready(fm) | |
ranger.api.hook_ready = hook_ready | |
return decorate | |
# triggered in ranger/core/tab.py | |
@ranger_signal_bind('cd') | |
def cd_handler(params): | |
if os.environ['TERM'].startswith('screen'): | |
subprocess.call(['screen', '-X', 'chdir', params['new'].path]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment