Last active
April 23, 2025 20:49
-
-
Save marcbelmont/c12d2fd2519a372d3b347f665b37e74a to your computer and use it in GitHub Desktop.
Add Unicode Icons to Ranger File Manager (see first comment for details). πΌοΈ π π΅ π₯³
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Unicode Icons in Ranger File Manager | |
# | |
# How to install? | |
# https://gist.github.com/marcbelmont/c12d2fd2519a372d3b347f665b37e74a#gistcomment-3240106 | |
from __future__ import absolute_import, division, print_function | |
from itertools import repeat | |
import ranger.api | |
from ranger.core.linemode import LinemodeBase | |
# https://unicode.org/emoji/charts/full-emoji-list.html | |
EXTENSIONS = {} | |
for extensions, icon in [ | |
('py pyc', 'π'), | |
('yml ini', 'β '), | |
]: | |
EXTENSIONS.update(dict(zip(extensions.split(), repeat(icon)))) | |
# https://github.com/ranger/ranger/blob/081e73152a9391211770fab56676d7d974413ae6/ranger/container/fsobject.py | |
@ranger.api.register_linemode | |
class MyLinemode(LinemodeBase): | |
name = "unicode_icons" | |
def filetitle(self, fobj, metadata): | |
if fobj.is_directory: | |
icon = 'π' | |
elif fobj.extension in EXTENSIONS: | |
icon = EXTENSIONS[fobj.extension] | |
elif fobj.is_link: | |
icon = 'π' | |
elif fobj.audio: | |
icon = 'π΅' | |
elif fobj.container: | |
icon = 'π¦' | |
elif fobj.document: | |
icon = 'π' | |
elif fobj.image: | |
icon = 'πΌοΈ ' | |
elif fobj.video: | |
icon = 'ποΈ ' | |
elif 'Dockerfile' in fobj.relative_path: | |
icon = 'π' | |
else: | |
icon = 'π' | |
return (icon + ' ' if icon else '') + fobj.relative_path | |
def infostring(self, fobj, metadata): | |
raise NotImplementedError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple Ranger Linemode Icon Plugin
This plugin will add icons to Ranger. All the icons are Unicode emojis. No special font needed. Tested on Ubuntu with Terminator and Gnome Terminal.
How to install?
Save unicode_icons.py to disk.