diff options
author | hut <hut@lepus.uberspace.de> | 2015-04-13 12:49:49 +0200 |
---|---|---|
committer | hut <hut@lepus.uberspace.de> | 2015-04-13 12:49:49 +0200 |
commit | c0f2fc72eccb4127fba5f48ce4b422487d6ec752 (patch) | |
tree | 025f72dde6f7a7e5cdca82637da4e5dcef0ddd62 /examples/plugin_chmod_keybindings.py | |
parent | a9bbdc440c2ea33ccc4470e00949ffa16ce2300e (diff) | |
download | ranger-c0f2fc72eccb4127fba5f48ce4b422487d6ec752.tar.gz |
moved "doc/examples" to "examples" for more visibility
Diffstat (limited to 'examples/plugin_chmod_keybindings.py')
-rw-r--r-- | examples/plugin_chmod_keybindings.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/plugin_chmod_keybindings.py b/examples/plugin_chmod_keybindings.py new file mode 100644 index 00000000..0ab975ed --- /dev/null +++ b/examples/plugin_chmod_keybindings.py @@ -0,0 +1,20 @@ +# Compatible with ranger 1.6.* +# +# This plugin serves as an example for adding key bindings through a plugin. +# It could replace the ten lines in the rc.conf that create the key bindings +# for the "chmod" command. + +import ranger.api +old_hook_init = ranger.api.hook_init + +def hook_init(fm): + old_hook_init(fm) + + # Generate key bindings for the chmod command + command = "map {0}{1}{2} shell -d chmod {1}{0}{2} %s" + for mode in list('ugoa') + ['']: + for perm in "rwxXst": + fm.execute_console(command.format('-', mode, perm)) + fm.execute_console(command.format('+', mode, perm)) + +ranger.api.hook_init = hook_init |