Package: xontrib-xlsd
xontrib-xlsdis the next gen ls command forxonsh shell, inspired bylsd.ContentsHow to install xontrib-xlsdRelease versionFrom git (might be unstable)FeaturesCustomizingIconsRegistering an iconExtension based icon sourceLibmagic based icon sourceCreating a custom icon source and changing the orderFile orderSetting the file orderCreating your own sort function-lmode columnsChanging the columns/the orderWriting your own columnColorsItem nameHow to install xontrib-xlsdRelease versionInstall the xontribxpipinstallxontrib-xlsdAnd load it in your.xonshrc:xontrib load xlsdFrom git (might be unstable)xpipinstallgit+https://github.com/cafehaine/xontrib-xlsdAnd load it in your.xonshrc:xontrib load xlsdFeaturesEmojisColorsAtree-like display when called recursivelyCustomizableWritten in python so it doesn't need to run a separate binaryCustomizingIconsRegistering an iconIn xlsd, icons are registered using a name. The name is then used by the different rules to get an icon for anPathEntry.You can view the built-in icons inxlsd/icons.py.Here is how to add an icon (for example a rainbow). Put this in your.xonshrcimportxlsd.iconsxlsd.icons.LS_ICONS.add('rainbow',"🌈")Icon sources can now use your fancy icon.You can also override built-in icons this way.Extension based icon sourceThe extension based rules are the fastest to run, and thus are the prefered way of setting icons.For example, to use your previously defined rainbow icon as the icon for.txtfiles, you can add the following snippet in your.xonshrc:importxlsd.iconsxlsd.icons.EXTENSION_ICONS.insert(0,({'txt'},'rainbow'))Libmagic based icon sourceIMPORTANT NOTE: This source seems to only work on Arch Linux systems at the moment.The libmagic (used by thefilecommand on *nix) based rules are slower, but allow gettinganicon when no extension matched.For example, here we're going to use the xonsh icon for all folders. Add the following snippet in your.xonshrc:importxlsd.iconsxlsd.icons.MIMETYPE_ICONS.insert(0,("inode/directory",'xonsh'))Note that this won't work unless you set the icon source order with libmagic as the first source, since the extension source already defines an icon for directory entries.Creating a custom icon source and changing the orderThe following snipped registers a new icon source (that simply returns the xonsh icon for everything), and makes it the first checked source. Put this in your.xonshrc.@xlsd_register_icon_source('my_source')defmy_icon_source(direntry):return'xonsh'$XLSD_ICON_SOURCES=['my_source','extension','libmagic']File orderSetting the file orderIn your.xonshrc, define a$XLSD_SORT_METHODenvironment variable with one of the following values:"directories_first": The default: alphabetical order, with directories first"alphabetical": Simple alphabetical order"as_is": The default order of your OS.Creating your own sort functionYou can create a simple alphabetical (case sensitive) sort function with the snippet:importxlsd@xlsd.xlsd_register_sort_method('alpha_case_sensitive')defmy_sort_method(entries):entries.sort(key=lambdae:e.name)returnentries-lmode columnsChanging the columns/the orderIn your.xonshrc, define a$XLSD_LIST_COLUMNSenvironment variable and set it's value to your desires.The default value (similar to coreutil'sls) is the following:$XLSD_LIST_COLUMNS=['mode','hardlinks','uid','gid','size','mtime','name']All the built-in columns are used in this config.Writing your own columnA column is a function taking for only argument anPathEntryand that outputs a string.A simple filename column could be registered like this:@xlsd_register_column('filename',ColumnAlignment.LEFT)def_xlsd_column_filename(direntry):returndirentry.nameColorsThere are multiple colors/text effects that you can change in xlsd.The full list of used colors is available inxlsd/__init__.py.Here is a small example: we're going to make the size unit in -l mode appear red.importxlsdxlsd.COLORS['size_unit']='{INTENSE_RED}'You can use any valid xonsh color.For a quick list of colors/text effects, check out thexonsh tutorial on colors.Item NameBy default, xlsd prints the item name with{icon} {name}format. You can update the$XLSD_NAME_FORMATenvironment variable to change the format of the item. For example$XLSD_NAME_FORMAT={icon}{name}will remove the single space between icon & name.