Skip to content

Linguist

Ruby library that detects a code file's language and reports language breakdowns for a Git repository.

Stars
13.8k
Forks
5.5k
Licence
MIT
Language
Ruby
Last update
6 days ago
Type
Library

What it is

Linguist is a Ruby library and command-line tool that figures out which programming language each file in a project is written in, and how much of the project each language makes up. The README says GitHub.com uses it to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and draw language breakdown graphs. You can run it on a repository to see a percentage breakdown by language.

  • Run github-linguist in a repository folder to see the percentage of code per language
  • Use --breakdown to list which files belong to each language
  • Use --json to export language statistics for another script
  • Check how a single file is classified with github-linguist on that file
  • Add .gitattributes overrides to correct how a file's language is reported

Great for

  • Developers who want a language breakdown of a Git repository from the command line
  • Maintainers who need to fix how GitHub labels their repository's languages
  • Developers building tools that need to detect file languages in Ruby code
  • Teams that want to add per-file language overrides using .gitattributes

Not ideal for

  • People who only want to write code or edit files, since this is an analysis tool and not an editor
  • Users who need a non-Ruby library, because the README describes it as a Ruby library requiring Ruby
  • Anyone whose system cannot build native dependencies like charlock_holmes and rugged, since the README notes these have their own system requirements
Step-by-step guide: how to use LinguistInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Ruby (a recent version; the README recommends installing it via a version manager or Homebrew) · cmake · pkg-config · ICU · zlib

    Install the gem

    gem install github-linguist

    Install dependencies on macOS with Homebrew (example)

    brew install cmake pkg-config icu4c

    Install dependencies on Ubuntu (example)

    sudo apt-get install build-essential cmake pkg-config libicu-dev zlib1g-dev libcurl4-openssl-dev libssl-dev ruby-dev
  2. 2

    Run it

    • Install Ruby and the listed system dependencies
    • Run gem install github-linguist
    • Change into a Git repository folder with cd /path-to-repository
    • Run github-linguist to see the language breakdown
  3. 3

    Get the most out of it

    • Use --breakdown or -b to see which files are counted under each language
    • Use --rev to analyze a specific tag, branch, or revision of a repository
    • Use --strategies or -s to see how each file's language was detected
    • Add .gitattributes linguist-language overrides to correct wrong results
    • Use --json or -j to get machine-readable output

Downloads

Strengths

  • Used on GitHub.com itself, according to the README
  • Offers multiple output modes, including plain text, per-file breakdown, and JSON
  • Supports overrides through .gitattributes and clear explanations of which detection strategy was used

Trade-offs

  • Installation can require native build tools and system libraries such as ICU, cmake, and libcurl
  • The README warns about known problems with the macOS system version of Ruby, so a separately installed Ruby is recommended
  • The README's install and usage sections are clear, but the truncated text leaves the full feature set and some details unclear

How it compares

ProjectStarsTypeLevelUpdatedBest for
linguist (this)13.8kLibraryintermediate6 days agoDevelopers who want a language breakdown of a Git repository from the command line
rich57.7kLibrarybeginner5 months agoPython developers who write command-line scripts and want clearer output
shiki13.9kLibraryintermediate4 days agoDevelopers building documentation or blog sites that show code samples
DevToys32.2kAppbeginner1 months agoDevelopers who often decode, encode, or format small pieces of data

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.