feat(ranger): 添加Ranger配置文件

This commit is contained in:
2025-12-15 10:02:47 +08:00
parent c1b5852314
commit 66e64a7774
18 changed files with 4279 additions and 2 deletions

View File

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Maxim Andreev
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.

View File

@@ -0,0 +1,23 @@
# ranger-devicons2
Adds an icon and type (like `ls -F`) to the ranger's file list
![screenshot](./screenshot.png)
## Why, if ranger-devicons already exists?
- simple sync with nvim-web-devicons: gen_icons.sh
- not only exact match, but also pattern_match (ex: `.*vimrc.*`)
- show "type symbol" (like `ls -F`)
## Installation
1. Install a [Nerd Font compatible font](https://github.com/ryanoasis/nerd-fonts#font-installation) or [patch your own](https://github.com/ryanoasis/nerd-fonts#font-patcher), then set your terminal font
2. Clone:
```sh
git clone https://github.com/cdump/ranger-devicons2 ~/.config/ranger/plugins/devicons2
```
3. Add/change `default_linemode devicons2` in your `~/.config/ranger/rc.conf`
## Acknowledgments
- icons rules autogenerated (with gen_icons.sh) from [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons)
- inspired by [ranger-devicons](https://github.com/alexanderjeurissen/ranger_devicons)

View File

@@ -0,0 +1,67 @@
# vim: set fileencoding=utf-8
import fnmatch
import os
import stat
from ranger.api import register_linemode
from ranger.core.linemode import LinemodeBase
from .icons import file_node_extensions, file_node_exact_matches, file_node_pattern_matches
def get_icon(file):
basename = os.path.basename(file.relative_path)
em_icon = file_node_exact_matches.get(basename.lower())
if em_icon is not None:
return em_icon
for pattern, pm_icon in file_node_pattern_matches.items():
if fnmatch.filter([basename], pattern):
return pm_icon
default = '' if file.is_directory else ''
return file_node_extensions.get(file.extension, default)
def get_symbol(file):
if file.is_link:
if not file.exists:
return '!'
if file.stat and stat.S_ISDIR(file.stat.st_mode):
return '~'
return '@'
if file.is_socket:
return '='
if file.is_fifo:
return '|'
if not file.is_directory and file.stat:
mode = file.stat.st_mode
if mode & stat.S_IXUSR:
return '*'
if stat.S_ISCHR(mode):
return '-'
if stat.S_ISBLK(mode):
return '+'
# if file.is_directory:
# return '/'
return ''
@register_linemode
class DevIcons2Linemode(LinemodeBase):
name = 'devicons2'
uses_metadata = False
def filetitle(self, file, metadata):
return '{0} {1}{2}'.format(
get_icon(file),
file.relative_path,
get_symbol(file),
)

View File

@@ -0,0 +1,49 @@
#!/bin/bash
set -e
SRC_URL="https://raw.githubusercontent.com/nvim-tree/nvim-web-devicons/master/lua/nvim-web-devicons/icons-default.lua"
echo "Updating from ${SRC_URL}..."
curl -o icons-default.lua -s ${SRC_URL}
cat <<EOF | lua > icons.py
local function p(name, d)
print(name .. ' = {')
local keys = {}
for k in pairs(d) do table.insert(keys, k) end
table.sort(keys)
for _, k in ipairs(keys) do
local v = d[k]
print(" '" .. k .. "': '" .. v.icon .. "',")
end
print('}')
end
local d = loadfile('icons-default.lua')()
print('# vim: set fileencoding=utf-8')
print('# autogenerated with gen_icons.sh')
print('')
p('file_node_extensions', d.icons_by_file_extension)
p('file_node_exact_matches', d.icons_by_filename)
print([[
file_node_pattern_matches = {
'.*jquery.*.js$' : '',
'.*angular.*.js$' : '',
'.*backbone.*.js$' : '',
'.*require.*.js$' : '',
'.*materialize.*.js$' : '',
'.*materialize.*.css$' : '',
'.*mootools.*.js$' : '',
'.*vimrc.*' : '',
'Vagrantfile$' : ''
}
]])
EOF
rm -f icons-default.lua
echo "Testing updated icons.py"
python icons.py
echo "Success!"

View File

@@ -0,0 +1,621 @@
# vim: set fileencoding=utf-8
# autogenerated with gen_icons.sh
file_node_extensions = {
'3gp': '',
'3mf': '󰆧',
'7z': '',
'Dockerfile': '󰡨',
'R': '󰟔',
'a': '',
'aac': '',
'ai': '',
'aif': '',
'aiff': '',
'android': '',
'ape': '',
'apk': '',
'apl': '',
'app': '',
'applescript': '',
'asc': '󰦝',
'ass': '󰨖',
'astro': '',
'awk': '',
'azcli': '',
'bak': '󰁯',
'bash': '',
'bat': '',
'bazel': '',
'bib': '󱉟',
'bicep': '',
'bicepparam': '',
'bin': '',
'blade.php': '',
'blend': '󰂫',
'blp': '󰺾',
'bmp': '',
'bqn': '',
'brep': '󰻫',
'bz': '',
'bz2': '',
'bz3': '',
'bzl': '',
'c': '',
'c++': '',
'cache': '',
'cast': '',
'cbl': '',
'cc': '',
'ccm': '',
'cfg': '',
'cjs': '',
'clj': '',
'cljc': '',
'cljd': '',
'cljs': '',
'cmake': '',
'cob': '',
'cobol': '',
'coffee': '',
'conf': '',
'config.ru': '',
'cow': '󰆚',
'cp': '',
'cpp': '',
'cppm': '',
'cpy': '',
'cr': '',
'crdownload': '',
'cs': '󰌛',
'csh': '',
'cshtml': '󱦗',
'cson': '',
'csproj': '󰪮',
'css': '',
'csv': '',
'cts': '',
'cu': '',
'cue': '󰲹',
'cuh': '',
'cxx': '',
'cxxm': '',
'd': '',
'd.ts': '',
'dart': '',
'db': '',
'dconf': '',
'desktop': '',
'diff': '',
'dll': '',
'doc': '󰈬',
'docx': '󰈬',
'dot': '󱁉',
'download': '',
'drl': '',
'dropbox': '',
'dump': '',
'dwg': '󰻫',
'dxf': '󰻫',
'ebook': '',
'ebuild': '',
'edn': '',
'eex': '',
'ejs': '',
'el': '',
'elc': '',
'elf': '',
'elm': '',
'eln': '',
'env': '',
'eot': '',
'epp': '',
'epub': '',
'erb': '',
'erl': '',
'ex': '',
'exe': '',
'exs': '',
'f#': '',
'f3d': '󰻫',
'f90': '󱈚',
'fbx': '󰆧',
'fcbak': '',
'fcmacro': '',
'fcmat': '',
'fcparam': '',
'fcscript': '',
'fcstd': '',
'fcstd1': '',
'fctb': '',
'fctl': '',
'fdmdownload': '',
'fish': '',
'flac': '',
'flc': '',
'flf': '',
'fnl': '',
'fs': '',
'fsi': '',
'fsscript': '',
'fsx': '',
'gcode': '󰐫',
'gd': '',
'gemspec': '',
'gif': '',
'git': '',
'glb': '',
'gleam': '',
'gnumakefile': '',
'go': '',
'godot': '',
'gql': '',
'gradle': '',
'graphql': '',
'gresource': '',
'gv': '󱁉',
'gz': '',
'h': '',
'haml': '',
'hbs': '',
'heex': '',
'hex': '',
'hh': '',
'hpp': '',
'hrl': '',
'hs': '',
'htm': '',
'html': '',
'http': '',
'huff': '󰡘',
'hurl': '',
'hx': '',
'hxx': '',
'ical': '',
'icalendar': '',
'ico': '',
'ics': '',
'ifb': '',
'ifc': '󰻫',
'ige': '󰻫',
'iges': '󰻫',
'igs': '󰻫',
'image': '',
'img': '',
'import': '',
'info': '',
'ini': '',
'ino': '',
'ipynb': '',
'iso': '',
'ixx': '',
'java': '',
'jl': '',
'jpeg': '',
'jpg': '',
'js': '',
'json': '',
'json5': '',
'jsonc': '',
'jsx': '',
'jwmrc': '',
'jxl': '',
'kbx': '󰯄',
'kdb': '',
'kdbx': '',
'kdenlive': '',
'kdenlivetitle': '',
'kicad_dru': '',
'kicad_mod': '',
'kicad_pcb': '',
'kicad_prl': '',
'kicad_pro': '',
'kicad_sch': '',
'kicad_sym': '',
'kicad_wks': '',
'ko': '',
'kpp': '',
'kra': '',
'krz': '',
'ksh': '',
'kt': '',
'kts': '',
'lck': '',
'leex': '',
'less': '',
'lff': '',
'lhs': '',
'lib': '',
'license': '',
'liquid': '',
'lock': '',
'log': '󰌱',
'lrc': '󰨖',
'lua': '',
'luac': '',
'luau': '',
'm': '',
'm3u': '󰲹',
'm3u8': '󰲹',
'm4a': '',
'm4v': '',
'magnet': '',
'makefile': '',
'markdown': '',
'material': '󰔉',
'md': '',
'md5': '󰕥',
'mdx': '',
'mint': '󰌪',
'mjs': '',
'mk': '',
'mkv': '',
'ml': '',
'mli': '',
'mm': '',
'mo': '',
'mobi': '',
'mojo': '',
'mov': '',
'mp3': '',
'mp4': '',
'mpp': '',
'msf': '',
'mts': '',
'mustache': '',
'nfo': '',
'nim': '',
'nix': '',
'nswag': '',
'nu': '>',
'o': '',
'obj': '󰆧',
'ogg': '',
'opus': '',
'org': '',
'otf': '',
'out': '',
'part': '',
'patch': '',
'pck': '',
'pcm': '',
'pdf': '',
'php': '',
'pl': '',
'pls': '󰲹',
'ply': '󰆧',
'pm': '',
'png': '',
'po': '',
'pot': '',
'pp': '',
'ppt': '󰈧',
'prisma': '',
'pro': '',
'ps1': '󰨊',
'psb': '',
'psd': '',
'psd1': '󰨊',
'psm1': '󰨊',
'pub': '󰷖',
'pxd': '',
'pxi': '',
'py': '',
'pyc': '',
'pyd': '',
'pyi': '',
'pyo': '',
'pyw': '',
'pyx': '',
'qm': '',
'qml': '',
'qrc': '',
'qss': '',
'query': '',
'r': '󰟔',
'rake': '',
'rar': '',
'razor': '󱦘',
'rb': '',
'res': '',
'resi': '',
'rlib': '',
'rmd': '',
'rproj': '󰗆',
'rs': '',
'rss': '',
'sass': '',
'sbt': '',
'sc': '',
'scad': '',
'scala': '',
'scm': '󰘧',
'scss': '',
'sh': '',
'sha1': '󰕥',
'sha224': '󰕥',
'sha256': '󰕥',
'sha384': '󰕥',
'sha512': '󰕥',
'sig': 'λ',
'signature': 'λ',
'skp': '󰻫',
'sldasm': '󰻫',
'sldprt': '󰻫',
'slim': '',
'sln': '',
'slvs': '󰻫',
'sml': 'λ',
'so': '',
'sol': '',
'spec.js': '',
'spec.jsx': '',
'spec.ts': '',
'spec.tsx': '',
'sql': '',
'sqlite': '',
'sqlite3': '',
'srt': '󰨖',
'ssa': '󰨖',
'ste': '󰻫',
'step': '󰻫',
'stl': '󰆧',
'stp': '󰻫',
'strings': '',
'styl': '',
'sub': '󰨖',
'sublime': '',
'suo': '',
'sv': '󰍛',
'svelte': '',
'svg': '󰜡',
'svh': '󰍛',
'swift': '',
't': '',
'tbc': '󰛓',
'tcl': '󰛓',
'templ': '',
'terminal': '',
'test.js': '',
'test.jsx': '',
'test.ts': '',
'test.tsx': '',
'tex': '',
'tf': '',
'tfvars': '',
'tgz': '',
'tmux': '',
'toml': '',
'torrent': '',
'tres': '',
'ts': '',
'tscn': '',
'tsconfig': '',
'tsx': '',
'ttf': '',
'twig': '',
'txt': '󰈙',
'txz': '',
'typoscript': '',
'ui': '',
'v': '󰍛',
'vala': '',
'vh': '󰍛',
'vhd': '󰍛',
'vhdl': '󰍛',
'vim': '',
'vsh': '',
'vsix': '',
'vue': '',
'wasm': '',
'wav': '',
'webm': '',
'webmanifest': '',
'webp': '',
'webpack': '󰜫',
'wma': '',
'woff': '',
'woff2': '',
'wrl': '󰆧',
'wrz': '󰆧',
'wv': '',
'wvc': '',
'x': '',
'xaml': '󰙳',
'xcf': '',
'xcplayground': '',
'xcstrings': '',
'xls': '󰈛',
'xlsx': '󰈛',
'xm': '',
'xml': '󰗀',
'xpi': '',
'xul': '',
'xz': '',
'yaml': '',
'yml': '',
'zig': '',
'zip': '',
'zsh': '',
'zst': '',
'🔥': '',
}
file_node_exact_matches = {
'.SRCINFO': '󰣇',
'.Xauthority': '',
'.Xresources': '',
'.babelrc': '',
'.bash_profile': '',
'.bashrc': '',
'.dockerignore': '󰡨',
'.ds_store': '',
'.editorconfig': '',
'.env': '',
'.eslintignore': '',
'.eslintrc': '',
'.git-blame-ignore-revs': '',
'.gitattributes': '',
'.gitconfig': '',
'.gitignore': '',
'.gitlab-ci.yml': '',
'.gitmodules': '',
'.gtkrc-2.0': '',
'.gvimrc': '',
'.justfile': '',
'.luaurc': '',
'.mailmap': '󰊢',
'.npmignore': '',
'.npmrc': '',
'.nuxtrc': '󱄆',
'.nvmrc': '',
'.prettierignore': '',
'.prettierrc': '',
'.prettierrc.cjs': '',
'.prettierrc.js': '',
'.prettierrc.json': '',
'.prettierrc.json5': '',
'.prettierrc.mjs': '',
'.prettierrc.toml': '',
'.prettierrc.yaml': '',
'.prettierrc.yml': '',
'.settings.json': '',
'.vimrc': '',
'.xinitrc': '',
'.xsession': '',
'.zprofile': '',
'.zshenv': '',
'.zshrc': '',
'FreeCAD.conf': '',
'PKGBUILD': '',
'PrusaSlicer.ini': '',
'PrusaSlicerGcodeViewer.ini': '',
'QtProject.conf': '',
'_gvimrc': '',
'_vimrc': '',
'avif': '',
'brewfile': '',
'bspwmrc': '',
'build': '',
'build.gradle': '',
'build.zig.zon': '',
'cantorrc': '',
'checkhealth': '󰓙',
'cmakelists.txt': '',
'code_of_conduct': '',
'code_of_conduct.md': '',
'commit_editmsg': '',
'commitlint.config.js': '󰜘',
'commitlint.config.ts': '󰜘',
'compose.yaml': '󰡨',
'compose.yml': '󰡨',
'config': '',
'containerfile': '󰡨',
'copying': '',
'copying.lesser': '',
'docker-compose.yaml': '󰡨',
'docker-compose.yml': '󰡨',
'dockerfile': '󰡨',
'eslint.config.cjs': '',
'eslint.config.js': '',
'eslint.config.mjs': '',
'eslint.config.ts': '',
'ext_typoscript_setup.txt': '',
'favicon.ico': '',
'fp-info-cache': '',
'fp-lib-table': '',
'gemfile$': '',
'gnumakefile': '',
'go.mod': '',
'go.sum': '',
'go.work': '',
'gradle-wrapper.properties': '',
'gradle.properties': '',
'gradlew': '',
'groovy': '',
'gruntfile.babel.js': '',
'gruntfile.coffee': '',
'gruntfile.js': '',
'gruntfile.ts': '',
'gtkrc': '',
'gulpfile.babel.js': '',
'gulpfile.coffee': '',
'gulpfile.js': '',
'gulpfile.ts': '',
'hypridle.conf': '',
'hyprland.conf': '',
'hyprlock.conf': '',
'hyprpaper.conf': '',
'i18n.config.js': '󰗊',
'i18n.config.ts': '󰗊',
'i3blocks.conf': '',
'i3status.conf': '',
'ionic.config.json': '',
'justfile': '',
'kalgebrarc': '',
'kdeglobals': '',
'kdenlive-layoutsrc': '',
'kdenliverc': '',
'kritadisplayrc': '',
'kritarc': '',
'license': '',
'license.md': '',
'lxde-rc.xml': '',
'lxqt.conf': '',
'makefile': '',
'mix.lock': '',
'mpv.conf': '',
'node_modules': '',
'nuxt.config.cjs': '󱄆',
'nuxt.config.js': '󱄆',
'nuxt.config.mjs': '󱄆',
'nuxt.config.ts': '󱄆',
'package-lock.json': '',
'package.json': '',
'platformio.ini': '',
'pom.xml': '',
'prettier.config.cjs': '',
'prettier.config.js': '',
'prettier.config.mjs': '',
'prettier.config.ts': '',
'procfile': '',
'py.typed': '',
'rakefile': '',
'rmd': '',
'robots.txt': '󰚩',
'security': '󰒃',
'security.md': '󰒃',
'settings.gradle': '',
'svelte.config.js': '',
'sxhkdrc': '',
'sym-lib-table': '',
'tailwind.config.js': '󱏿',
'tailwind.config.mjs': '󱏿',
'tailwind.config.ts': '󱏿',
'tmux.conf': '',
'tmux.conf.local': '',
'tsconfig.json': '',
'unlicense': '',
'vagrantfile$': '',
'vercel.json': '',
'vlcrc': '󰕼',
'webpack': '󰜫',
'weston.ini': '',
'workspace': '',
'xmobarrc': '',
'xmobarrc.hs': '',
'xmonad.hs': '',
'xorg.conf': '',
'xsettingsd.conf': '',
}
file_node_pattern_matches = {
'.*jquery.*.js$' : '',
'.*angular.*.js$' : '',
'.*backbone.*.js$' : '',
'.*require.*.js$' : '',
'.*materialize.*.js$' : '',
'.*materialize.*.css$' : '',
'.*mootools.*.js$' : '',
'.*vimrc.*' : '',
'Vagrantfile$' : ''
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB