diff options
author | Theo Laurent <theo.laurent@ens.fr> | 2016-12-22 11:28:28 +0100 |
---|---|---|
committer | nfnty <git@nfnty.se> | 2017-01-29 18:54:17 +0100 |
commit | f557329083d964027d79f4a14e4e2951c11eac4d (patch) | |
tree | 840b3b7d5e0db912742c7c46f21c12dc7e9640e9 | |
parent | ae99c2c9e71797c2777d4441db451f0e2ac967cc (diff) | |
download | ranger-f557329083d964027d79f4a14e4e2951c11eac4d.tar.gz |
examples: Added plugin_fasd_add.py
-rw-r--r-- | examples/plugin_fasd_add.py | 25 |
1 files changed, 25 insertions, 0 deletions
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 |