about summary refs log tree commit diff stats
path: root/editor/subx.nanorc
blob: 9ac8c92afc93df88b9045417e6429f070b2a2532 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# include this file in your ~/.nanorc

syntax "subx" "\.subx$"
# function definitions
color yellow "^[a-z][^ ]*:"
# global variables
color red "^[A-Z][^ ]*:"
# tests
color green "^test-[^ ]*:"
# strings literals
color cyan ""([^"\]|\\.)+""
# comments
comment "#"
color brightblue "# - .*"
color blue "#.*$"
color brightblack "# \. .*"
style>
# 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