Skip to content

emacsattic/magit-file-icons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED

Starting from 223461b, Magit natively supports custom formatting functions for file entries through the magit-format-file-function customizable variable. It also ships with pre-defined formatting functions for both nerd-icons and all-the-icons - rendering this package effectively obsolete.

Users are encouraged to update magit to the latest version and make use of its built-in formatting facilities:

(use-package nerd-icons
  :ensure t)

(use-package magit
  :ensure t
  :after nerd-icons
  :custom
  (magit-format-file-function #'magit-format-file-nerd-icons))

Thank you, Jonas Bernoulli, for your continued improvements to our favorite Git client!

magit-file-icons.el

Display icons for filenames in Magit buffers!

Build status Version License

Preview

Magit status buffer with file icons

Magit revision diffstat with file icons

Changelog

3.0.1

Version 3.0.0 contained a bug, and only seemingly fixed the compatibility issue with newer Magit versions.

  • Remove icon functionality for untracked files. This is a temporary hack to prevent errors until a working patch can be found.

3.0.0

Version 3.0.0 is a breaking version bump, compatible with magit MELPA version 20250203 and greater.

  • Apply fix related to changes in Magit's internals introduced in 83d89ee.
  • Drop magit from Package-Requires. Users are now expected to supply the correct magit package version themselves.

Installation

You can install this package from MELPA.

For example, with use-package:

(use-package magit-file-icons
  :ensure t
  :after magit
  :init
  (magit-file-icons-mode 1)
  :custom
  ;; These are the default values:
  (magit-file-icons-enable-diff-file-section-icons t)
  (magit-file-icons-enable-untracked-icons t)
  (magit-file-icons-enable-diffstat-icons t))

If you are using some other method to install, you will need to ensure the following dependencies:

  • el-patch
  • nerd-icons

Nix

Alternatively, you can use Nix. This repository is a flake and outputs the following packages (versions omitted):

└───packages
    ├───aarch64-darwin
    │   ├───default: package 'emacs-magit-file-icons-vX.X.X'
    │   └───magit-file-icons: package 'emacs-magit-file-icons-vX.X.X'
    ├───aarch64-linux
    │   ├───default: package 'emacs-magit-file-icons-vX.X.X'
    │   └───magit-file-icons: package 'emacs-magit-file-icons-vX.X.X'
    ├───x86_64-darwin
    │   ├───default: package 'emacs-magit-file-icons-vX.X.X'
    │   └───magit-file-icons: package 'emacs-magit-file-icons-vX.X.X'
    └───x86_64-linux
        ├───default: package 'emacs-magit-file-icons-vX.X.X'
        └───magit-file-icons: package 'emacs-magit-file-icons-vX.X.X'

A minimal flake for creating an Emacs with the magit-file-icons package could look like this:

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    magit-file-icons.url = "github:gekoke/magit-file-icons";
    magit-file-icons.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs =
    inputs:
    let
      system = "x86_64-linux";
      pkgs = inputs.nixpkgs.legacyPackages.${system};
    in
    {
      packages.${system}.default = pkgs.emacsWithPackages (_: [
        inputs.magit-file-icons.packages.${system}.default
      ]);
    };
}

Commentary

This package uses nerd-icons.el to render icons. Currently, this is the only supported icon backend.

The author is not opposed to adding additional icon backends — such as all-the-icons.el or vscode-icons-emacs — in the future.