From 72e82deb5536a88b6438a708b3e825029f621d14 Mon Sep 17 00:00:00 2001 From: spl3g Date: Mon, 21 Aug 2023 09:14:28 +0000 Subject: damn --- home-manager/programs/ranger/commands.py | 183 +++++++++++ home-manager/programs/ranger/default.nix | 16 + home-manager/programs/ranger/plugins/__init__.py | 0 .../plugins/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 139 bytes .../plugins/__pycache__/__init__.cpython-311.pyc | Bin 0 -> 155 bytes .../ranger/plugins/__pycache__/fd.cpython-311.pyc | Bin 0 -> 6322 bytes .../plugins/__pycache__/quit_cd_wd.cpython-310.pyc | Bin 0 -> 1682 bytes .../plugins/__pycache__/quit_cd_wd.cpython-311.pyc | Bin 0 -> 3030 bytes home-manager/programs/ranger/plugins/quit_cd_wd.py | 38 +++ .../ranger/plugins/ranger_fzf_filter/.gitignore | 132 ++++++++ .../ranger/plugins/ranger_fzf_filter/LICENSE | 21 ++ .../ranger/plugins/ranger_fzf_filter/README.md | 47 +++ .../ranger/plugins/ranger_fzf_filter/__init__.py | 35 ++ .../ranger/plugins/ranger_fzf_filter/command.py | 59 ++++ .../ranger/plugins/ranger_fzf_filter/filter.py | 84 +++++ home-manager/programs/ranger/rc.conf | 12 + home-manager/programs/ranger/rifle.conf | 284 +++++++++++++++++ home-manager/programs/ranger/scope.sh | 351 +++++++++++++++++++++ 18 files changed, 1262 insertions(+) create mode 100644 home-manager/programs/ranger/commands.py create mode 100644 home-manager/programs/ranger/default.nix create mode 100644 home-manager/programs/ranger/plugins/__init__.py create mode 100644 home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-310.pyc create mode 100644 home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-311.pyc create mode 100644 home-manager/programs/ranger/plugins/__pycache__/fd.cpython-311.pyc create mode 100644 home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-310.pyc create mode 100644 home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-311.pyc create mode 100644 home-manager/programs/ranger/plugins/quit_cd_wd.py create mode 100644 home-manager/programs/ranger/plugins/ranger_fzf_filter/.gitignore create mode 100644 home-manager/programs/ranger/plugins/ranger_fzf_filter/LICENSE create mode 100644 home-manager/programs/ranger/plugins/ranger_fzf_filter/README.md create mode 100644 home-manager/programs/ranger/plugins/ranger_fzf_filter/__init__.py create mode 100644 home-manager/programs/ranger/plugins/ranger_fzf_filter/command.py create mode 100644 home-manager/programs/ranger/plugins/ranger_fzf_filter/filter.py create mode 100644 home-manager/programs/ranger/rc.conf create mode 100644 home-manager/programs/ranger/rifle.conf create mode 100755 home-manager/programs/ranger/scope.sh (limited to 'home-manager/programs/ranger') diff --git a/home-manager/programs/ranger/commands.py b/home-manager/programs/ranger/commands.py new file mode 100644 index 0000000..a41d42f --- /dev/null +++ b/home-manager/programs/ranger/commands.py @@ -0,0 +1,183 @@ +from ranger.api.commands import Command +from ranger.container.file import File +from ranger.ext.get_executables import get_executables +from collections import deque +import os +import subprocess + +# fd search + + +class fd_search(Command): + """ + :fd_search [-d] + Executes "fd -d " in the current directory and focuses the + first match. defaults to 1, i.e. only the contents of the current + directory. + + See https://github.com/sharkdp/fd + """ + + SEARCH_RESULTS = deque() + + def execute(self): + import re + import subprocess + from ranger.ext.get_executables import get_executables + + self.SEARCH_RESULTS.clear() + + if "fdfind" in get_executables(): + fd = "fdfind" + elif "fd" in get_executables(): + fd = "fd" + else: + self.fm.notify("Couldn't find fd in the PATH.", bad=True) + return + + if self.arg(1): + if self.arg(1)[:2] == "-d": + depth = self.arg(1) + target = self.rest(2) + else: + depth = "-d1" + target = self.rest(1) + else: + self.fm.notify(":fd_search needs a query.", bad=True) + return + + hidden = "--hidden" if self.fm.settings.show_hidden else "" + exclude = "--no-ignore-vcs --exclude '.git' --exclude '*.py[co]' --exclude '__pycache__'" + command = "{} --follow {} {} {} --print0 {}".format( + fd, depth, hidden, exclude, target + ) + fd = self.fm.execute_command( + command, universal_newlines=True, stdout=subprocess.PIPE + ) + stdout, _ = fd.communicate() + + if fd.returncode == 0: + results = filter(None, stdout.split("\0")) + if not self.fm.settings.show_hidden and self.fm.settings.hidden_filter: + hidden_filter = re.compile(self.fm.settings.hidden_filter) + results = filter( + lambda res: not hidden_filter.search(os.path.basename(res)), results + ) + results = map( + lambda res: os.path.abspath(os.path.join(self.fm.thisdir.path, res)), + results, + ) + self.SEARCH_RESULTS.extend(sorted(results, key=str.lower)) + if len(self.SEARCH_RESULTS) > 0: + self.fm.notify( + "Found {} result{}.".format( + len(self.SEARCH_RESULTS), + ("s" if len(self.SEARCH_RESULTS) > 1 else ""), + ) + ) + self.fm.select_file(self.SEARCH_RESULTS[0]) + else: + self.fm.notify("No results found.") + + +class fd_next(Command): + """ + :fd_next + Selects the next match from the last :fd_search. + """ + + def execute(self): + if len(fd_search.SEARCH_RESULTS) > 1: + fd_search.SEARCH_RESULTS.rotate(-1) # rotate left + self.fm.select_file(fd_search.SEARCH_RESULTS[0]) + elif len(fd_search.SEARCH_RESULTS) == 1: + self.fm.select_file(fd_search.SEARCH_RESULTS[0]) + + +class fd_prev(Command): + """ + :fd_prev + Selects the next match from the last :fd_search. + """ + + def execute(self): + if len(fd_search.SEARCH_RESULTS) > 1: + fd_search.SEARCH_RESULTS.rotate(1) # rotate right + self.fm.select_file(fd_search.SEARCH_RESULTS[0]) + elif len(fd_search.SEARCH_RESULTS) == 1: + self.fm.select_file(fd_search.SEARCH_RESULTS[0]) + + +# yank content +class YankContentWl(Command): + def execute(self): + if "wl-copy" not in get_executables(): + self.fm.notify("wl-clipboard is not found.", bad=True) + return + + arg = self.rest(1) + if arg: + if not os.path.isfile(arg): + self.fm.notify("{} is not a file".format(arg)) + return + file = File(arg) + else: + file = self.fm.thisfile + if not file.is_file: + self.fm.notify("{} is not a file".format(file.relative_path)) + return + if file.is_binary or file.image: + subprocess.check_call("wl-copy" + " < " + file.path, shell=True) + else: + self.fm.notify( + "{} is not an image file or a text file".format(file.relative_path) + ) + + +import os +import subprocess +from ranger.api.commands import Command +from ranger.container.file import File +from ranger.ext.get_executables import get_executables + + +class YankContent(Command): + """ + Copy the content of image file and text file with xclip + """ + + def execute(self): + if "xclip" not in get_executables(): + self.fm.notify("xclip is not found.", bad=True) + return + + arg = self.rest(1) + if arg: + if not os.path.isfile(arg): + self.fm.notify("{} is not a file.".format(arg)) + return + file = File(arg) + else: + file = self.fm.thisfile + if not file.is_file: + self.fm.notify("{} is not a file.".format(file.relative_path)) + return + + relative_path = file.relative_path + cmd = ["xclip", "-selection", "clipboard"] + if not file.is_binary(): + with open(file.path, "rb") as fd: + subprocess.check_call(cmd, stdin=fd) + elif file.image: + cmd += ["-t", file.mimetype, file.path] + subprocess.check_call(cmd) + self.fm.notify( + "Content of {} is copied to x clipboard".format(relative_path) + ) + else: + self.fm.notify( + "{} is not an image file or a text file.".format(relative_path) + ) + + def tab(self, tabnum): + return self._tab_directory_content() diff --git a/home-manager/programs/ranger/default.nix b/home-manager/programs/ranger/default.nix new file mode 100644 index 0000000..8e8ef1d --- /dev/null +++ b/home-manager/programs/ranger/default.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +let + configFiles = { + "ranger/rc.conf".text = builtins.readFile ./rc.conf; + "ranger/rifle.conf".text = builtins.readFile ./rifle.conf; + "ranger/scope.sh".text = builtins.readFile ./scope.sh; + "ranger/commands.py".source = ./commands.py; + "ranger/plugins".source = ./plugins; + }; +in +{ + home.packages = [ pkgs.ranger ]; + xdg.configFile = { + inherit (configFiles); + }; +} diff --git a/home-manager/programs/ranger/plugins/__init__.py b/home-manager/programs/ranger/plugins/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-310.pyc b/home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..1a26aa3 Binary files /dev/null and b/home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-310.pyc differ diff --git a/home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-311.pyc b/home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..87b2e7f Binary files /dev/null and b/home-manager/programs/ranger/plugins/__pycache__/__init__.cpython-311.pyc differ diff --git a/home-manager/programs/ranger/plugins/__pycache__/fd.cpython-311.pyc b/home-manager/programs/ranger/plugins/__pycache__/fd.cpython-311.pyc new file mode 100644 index 0000000..146af23 Binary files /dev/null and b/home-manager/programs/ranger/plugins/__pycache__/fd.cpython-311.pyc differ diff --git a/home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-310.pyc b/home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-310.pyc new file mode 100644 index 0000000..49d1db9 Binary files /dev/null and b/home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-310.pyc differ diff --git a/home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-311.pyc b/home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-311.pyc new file mode 100644 index 0000000..7b3ac1c Binary files /dev/null and b/home-manager/programs/ranger/plugins/__pycache__/quit_cd_wd.cpython-311.pyc differ diff --git a/home-manager/programs/ranger/plugins/quit_cd_wd.py b/home-manager/programs/ranger/plugins/quit_cd_wd.py new file mode 100644 index 0000000..e47837f --- /dev/null +++ b/home-manager/programs/ranger/plugins/quit_cd_wd.py @@ -0,0 +1,38 @@ +import ranger.api +from ranger.api.commands import * +import os + +def save_wd(command): + with open(os.path.expanduser('~/.ranger_quit_cd_wd'), 'w') as f: + f.write(command.fm.thisdir.path); + +class quit_cd_wd(Command): + """:chdir to working directory of ranger after quiting on ranger. + + """ + def _exit_no_work(self): + if self.fm.loader.has_work(): + self.fm.notify('Not quitting: Tasks in progress: Use `quit!` to force quit') + else: + self.fm.exit() + + def execute(self): + if len(self.fm.tabs) >= 2: + self.fm.tab_close() + else: + save_wd(self) + self._exit_no_work() + +class quitall_cd_wd(Command): + """:chdir to working directory of ranger after quitalling on ranger. + + """ + def _exit_no_work(self): + if self.fm.loader.has_work(): + self.fm.notify('Not quitting: Tasks in progress: Use `quitall!` to force quit') + else: + self.fm.exit() + + def execute(self): + save_wd(self) + self._exit_no_work() diff --git a/home-manager/programs/ranger/plugins/ranger_fzf_filter/.gitignore b/home-manager/programs/ranger/plugins/ranger_fzf_filter/.gitignore new file mode 100644 index 0000000..846dc44 --- /dev/null +++ b/home-manager/programs/ranger/plugins/ranger_fzf_filter/.gitignore @@ -0,0 +1,132 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Pycharm +.idea diff --git a/home-manager/programs/ranger/plugins/ranger_fzf_filter/LICENSE b/home-manager/programs/ranger/plugins/ranger_fzf_filter/LICENSE new file mode 100644 index 0000000..bd840f1 --- /dev/null +++ b/home-manager/programs/ranger/plugins/ranger_fzf_filter/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 MuXiu1997 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/home-manager/programs/ranger/plugins/ranger_fzf_filter/README.md b/home-manager/programs/ranger/plugins/ranger_fzf_filter/README.md new file mode 100644 index 0000000..6a65e17 --- /dev/null +++ b/home-manager/programs/ranger/plugins/ranger_fzf_filter/README.md @@ -0,0 +1,47 @@ +# ranger-fzf-filter +This is a plugin for [`ranger`](https://github.com/ranger/ranger) that add a fuzzy filter. It depends on [`fzf`](https://github.com/junegunn/fzf) + +https://user-images.githubusercontent.com/49554020/173509108-dc3edca4-8949-4026-a3ca-0ba8dac9bbce.mp4 + + +## Install + +For ranger >= 1.9.3, use Git to clone this repository into your `~/.config/ranger/plugins` folder. For example: + +```sh +git clone git@github.com:MuXiu1997/ranger-fzf-filter.git ~/.config/ranger/plugins/ranger_fzf_filter +``` + +**Legacy Install** + +For ranger versions older than 1.9.3, or to install without Git, download `__init__.py` to your `~/.config/ranger/plugins` directory. For example: + +```shell +mkdir -p ~/.config/ranger/plugins +wget -O ~/.config/ranger/plugins/ranger_fzf_filter.py https://raw.githubusercontent.com/MuXiu1997/ranger-fzf-filter/main/__init__.py +``` + + + +## Usage + +Command: + +- `:fzf_filter [query]`: filtering files with fzf, see this [search syntax](https://github.com/junegunn/fzf#search-syntax) + + + +## Keyboard Shortcut + +Add a binding to your `~/.config/ranger/rc.conf` file to quickly use `:fzf_filter`: + +``` +map f console fzf_filter%space +``` + + + +## License + +[MIT](LICENSE) + diff --git a/home-manager/programs/ranger/plugins/ranger_fzf_filter/__init__.py b/home-manager/programs/ranger/plugins/ranger_fzf_filter/__init__.py new file mode 100644 index 0000000..b5d5b46 --- /dev/null +++ b/home-manager/programs/ranger/plugins/ranger_fzf_filter/__init__.py @@ -0,0 +1,35 @@ +import ranger.api +import ranger.container.directory +# noinspection PyUnresolvedReferences +from .command import fzf_filter, KEY_FZF_FILTER + +# region overwrite hook_init +HOOK_INIT_OLD = ranger.api.hook_init + + +def hook_init(fm): + def clear_fzf_filter(signal): + if fm.settings.clear_filters_on_dir_change and signal.previous: + signal.previous.__dict__[KEY_FZF_FILTER] = None + signal.previous.refilter() + + fm.signal_bind('cd', clear_fzf_filter) + return HOOK_INIT_OLD(fm) + + +ranger.api.hook_init = hook_init +# endregion overwrite hook_init + +# region overwrite accept_file +ACCEPT_FILE_OLD = ranger.container.directory.accept_file + + +def accept_file(fobj, filters): + _fzf_filter = fobj.fm.thisdir.__dict__.get(KEY_FZF_FILTER, None) + if _fzf_filter: + filters.append(_fzf_filter) + return ACCEPT_FILE_OLD(fobj, filters) + + +ranger.container.directory.accept_file = accept_file +# endregion overwrite accept_file diff --git a/home-manager/programs/ranger/plugins/ranger_fzf_filter/command.py b/home-manager/programs/ranger/plugins/ranger_fzf_filter/command.py new file mode 100644 index 0000000..92aee83 --- /dev/null +++ b/home-manager/programs/ranger/plugins/ranger_fzf_filter/command.py @@ -0,0 +1,59 @@ +import ranger.api.commands +from .filter import FzfFilter + +# noinspection PyUnreachableCode +# This is done to enhance auto-completion and inference in the editor. +if False: + import ranger.core.fm + +KEY_FZF_FILTER = 'fzf_filter' + + +# noinspection PyPep8Naming,PyUnresolvedReferences +class fzf_filter(ranger.api.commands.Command): + """ + :fzf_filter + + This command allows you to use fzf fuzzy search to filter files and directories in the ranger. + """ + + def execute(self): + fm = self.fm # type: ranger.core.fm.FM + # Check if a filter is already set + _filter = fm.thisdir.__dict__.get(KEY_FZF_FILTER, None) + if isinstance(_filter, FzfFilter): + # If a filter is set, just update the query + _filter.set_query(self._get_query()) + else: + # If no filter is set, build a new one + fm.thisdir.__dict__[KEY_FZF_FILTER] = self._build_filter() + + fm.thisdir.refilter() + if self.quickly_executed: + fm.open_console(self.line) + + def cancel(self): + fm = self.fm # type: ranger.core.fm.FM + fm.thisdir.__dict__[KEY_FZF_FILTER] = None + fm.thisdir.refilter() + + def quick(self): + return True + + def _get_query(self): + """ + Get the search query. + + Returns: + str: The search query. + """ + return self.rest(1) + + def _build_filter(self): + """ + Build a new FzfFilter. + + Returns: + FzfFilter: A new FzfFilter object with the current directory and search query. + """ + return FzfFilter(self.fm.thisdir, self._get_query()) diff --git a/home-manager/programs/ranger/plugins/ranger_fzf_filter/filter.py b/home-manager/programs/ranger/plugins/ranger_fzf_filter/filter.py new file mode 100644 index 0000000..3d12756 --- /dev/null +++ b/home-manager/programs/ranger/plugins/ranger_fzf_filter/filter.py @@ -0,0 +1,84 @@ +import os.path +import subprocess + + +class FzfFilter: + """ + A filter class for FZF fuzzy search. + + Attributes: + thisdir (ranger.container.directory.Directory): The current directory. + query (str): The search query. + source (list[str]): List of relative paths of all files in the current directory. + result (list[str]): The result of fzf search. + """ + + def __init__(self, thisdir, query): + """ + Initialize the FzfFilter class. + + Args: + thisdir (ranger.container.directory.Directory): The current directory. + query (str): The search query. + """ + self.thisdir = thisdir + self.files_all = thisdir.files_all + + self.query = query + + self.source = [] + self.recalc_source() + + self.result = [] + self.recalc_result() + + def recalc_source(self): + """ + Recalculate the source list based on the files in the current directory. + """ + self.source = [f.relative_path for f in self.thisdir.files_all] + + def recalc_result(self): + """ + Recalculate the result list by executing the fzf command. + """ + cmd = subprocess.Popen( + ['fzf', '-f', self.query], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + ) + stdout, _ = cmd.communicate('\n'.join(self.source).encode('utf-8')) + self.result = stdout.decode('utf-8').strip().splitlines() + + def set_query(self, query): + """ + Update the query and recalculate the result list. + + Args: + query (str): The new search query. + """ + self.query = query + self.recalc_result() + + def __call__(self, fobj): + """ + Perform the actual filtering. + + Args: + fobj (ranger.container.file.File | ranger.container.directory.Directory): The file or directory to check. + + Returns: + bool: True if the file or directory is in the result list, False otherwise. + """ + # Check if the files in the current directory have changed, and if so, recalculate source and result + if self.thisdir.files_all is not self.files_all: + self.files_all = self.thisdir.files_all + self.recalc_source() + self.recalc_result() + + # Ensure the relative path start of the file or directory is in the current directory + if os.path.relpath(fobj.path, fobj.relative_path) != '.': + return True + + # Check if the relative path of the file or directory is in the result list + return fobj.relative_path in self.result diff --git a/home-manager/programs/ranger/rc.conf b/home-manager/programs/ranger/rc.conf new file mode 100644 index 0000000..271d239 --- /dev/null +++ b/home-manager/programs/ranger/rc.conf @@ -0,0 +1,12 @@ +map f console fzf_filter%space +map x quit_cd_wd +map X quitall_cd_wd +map / console fd_search -d5%space +map n fd_next +map p fd_prev +map e shell dragon -x %p & +map yc YankContent +set preview_images true +set preview_images_method kitty +set use_preview_script True +map gj cd /run/media/jerpo/ diff --git a/home-manager/programs/ranger/rifle.conf b/home-manager/programs/ranger/rifle.conf new file mode 100644 index 0000000..3b565af --- /dev/null +++ b/home-manager/programs/ranger/rifle.conf @@ -0,0 +1,284 @@ +# vim: ft=cfg +# +# This is the configuration file of "rifle", ranger's file executor/opener. +# Each line consists of conditions and a command. For each line the conditions +# are checked and if they are met, the respective command is run. +# +# Syntax: +# , , ... = command +# +# The command can contain these environment variables: +# $1-$9 | The n-th selected file +# $@ | All selected files +# +# If you use the special command "ask", rifle will ask you what program to run. +# +# Prefixing a condition with "!" will negate its result. +# These conditions are currently supported: +# match | The regexp matches $1 +# ext | The regexp matches the extension of $1 +# mime | The regexp matches the mime type of $1 +# name | The regexp matches the basename of $1 +# path | The regexp matches the absolute path of $1 +# has | The program is installed (i.e. located in $PATH) +# env | The environment variable "variable" is non-empty +# file | $1 is a file +# directory | $1 is a directory +# number | change the number of this command to n +# terminal | stdin, stderr and stdout are connected to a terminal +# X | A graphical environment is available (darwin, Xorg, or Wayland) +# +# There are also pseudo-conditions which have a "side effect": +# flag | Change how the program is run. See below. +# label