An open-source entry in TopGit's GitHub warehouse: github-linguist/linguist, 13.8k stars, Ruby. Language Savant. If your repository's language is being reported incorrectly, send us a pull request!
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This library is used on GitHub.com to detect blob languages, ignore binary or vendored files, suppress generated files in diffs, and generate language breakdown graphs.
Documentation
How Linguist works
Change Linguist's behaviour with overrides
Troubleshooting
Contributing guidelines
Installation
Install the gem:
gem install github-linguist
Dependencies
Linguist is a Ruby library so you will need a recent version of Ruby installed.
There are known problems with the macOS/Xcode supplied version of Ruby that causes problems installing some of the dependencies.
Accordingly, we highly recommend you install a version of Ruby using Homebrew, rbenv, rvm, ruby-build, asdf or other packaging system, before attempting to install Linguist and the dependencies.
Linguist uses charlock_holmes for character encoding and rugged for libgit2 bindings for Ruby.
These components have their own dependencies.
charlock_holmes
cmake
pkg-config
ICU
zlib
rugged
libcurl
OpenSSL
You may need to install missing dependencies before you can install Linguist.
For example, on macOS with Homebrew:
The github-linguist executable operates in two distinct modes:
Git Repository mode - Analyzes an entire Git repository (when given a directory path or no path)
Single file mode - Analyzes a specific file (when given a file path)
Git Repository
A repository's languages stats can be assessed from the command line using the github-linguist executable.
Without any options, github-linguist will output the language breakdown by percentage and file size.
cd /path-to-repository
github-linguist
You can try running github-linguist on the root directory in this repository itself:
$ github-linguist
66.84% 264519 Ruby
24.68% 97685 C
6.57% 25999 Go
1.29% 5098 Lex
0.32% 1257 Shell
0.31% 1212 Dockerfile
Additional options
--rev REV
The --rev REV flag will change the git revision being analyzed to any gitrevisions(1) compatible revision you specify.
This is useful to analyze the makeup of a repo as of a certain tag, or in a certain branch.
For example, here is the popular Jekyll open source project.
The --strategies or -s flag will show the language detection strategy used for each file. This is useful for understanding how Linguist determined the language of specific files. Note that unless the --json flag is specified, this flag will set the --breakdown flag implicitly.
You can try running github-linguist on the root directory in this repository itself with the strategies flag:
If a file's language is affected by .gitattributes, the strategy will show the original detection method along with a note indicating whether the gitattributes setting changed the result or confirmed it.
For instance, if you had the following .gitattributes overrides in your repo:
If a file's language is affected by .gitattributes, the strategy will show whether the gitattributes setting changed the result or confirmed it:
In this fictitious example, it says "confirmed by .gitattributes" since the detection process (using the Filename strategy) would have given the same output as the override:
.devcontainer/devcontainer.json: 27 lines (27 sloc)
type: Text
mime type: application/json
language: JSON with Comments
strategy: Filename (confirmed by .gitattributes)
In this other fictitious example, it says "overridden by .gitattributes" since the gitattributes setting changes the detected language to something different:
test.rb: 13 lines (11 sloc)
type: Text
mime type: application/x-ruby
language: Java
strategy: Extension (overridden by .gitattributes)
Here, the .rb file would normally be detected as Ruby by the Extension strategy, but .gitattributes overrides it to be detected as Java instead.
--json
Using the --json flag will give you the output for a single file in JSON format:
The language grammars included in this gem are covered by their repositories' respective licenses.
vendor/README.md lists the repository for each grammar.
All other files are covered by the MIT license, see LICENSE.
How active is development on github-linguist/linguist?
The most recent commit recorded on github-linguist/linguist was 13 days ago, based on the GitHub push timestamp. The repository has 5.5k forks — one of the better signals of community interest.
How many stars does github-linguist/linguist have?
github-linguist/linguist has 13.8k GitHub stars — refresh the page for the live number, or check github.com/github-linguist/linguist. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is github-linguist/linguist written in?
github-linguist/linguist is written primarily in Ruby. GitHub's language field is based on the largest share of bytes in the default branch.
What topics is github-linguist/linguist associated with?
GitHub's repository topics for github-linguist/linguist: "language-grammars", "language-statistics", "linguistic", "syntax-highlighting". TopGit's editorial category is open-source.
Where do I read more about github-linguist/linguist?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/github-linguist/linguist is the definitive source.
Read full README in the tab above.
Still deciding about linguist?
One click hands the question to an AI along with this page — see what it says about linguist.