From f557329083d964027d79f4a14e4e2951c11eac4d Mon Sep 17 00:00:00 2001 From: Theo Laurent Date: Thu, 22 Dec 2016 11:28:28 +0100 Subject: examples: Added plugin_fasd_add.py --- examples/plugin_fasd_add.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/plugin_fasd_add.py (limited to 'examples') diff --git a/examples/plugin_fasd_add.py b/examples/plugin_fasd_add.py new file mode 100644 index 00000000..c107ecc1 --- /dev/null +++ b/examples/plugin_fasd_add.py @@ -0,0 +1,25 @@ +# This plugin adds opened files to `fasd` + +from __future__ import (absolute_import, division, print_function) + +import subprocess + +import ranger.api +from ranger.ext.spawn import check_output + + +HOOK_INIT_OLD = ranger.api.hook_init + + +def hook_init(fm): + def fasd_add(): + for fobj in fm.thistab.get_selection(): + try: + check_output(['fasd', '--add', fobj.path]) + except subprocess.CalledProcessError: + pass + fm.signal_bind('execute.before', fasd_add) + return HOOK_INIT_OLD(fm) + + +ranger.api.hook_init = hook_init -- cgit 1.4.1-2-gfad0