All Projects → github → Linguist

github / Linguist

Licence: mit
Language Savant. If your repository's language is being reported incorrectly, send us a pull request!

Programming Languages

ruby
36898 projects - #4 most used programming language
c
50402 projects - #5 most used programming language
go
31211 projects - #10 most used programming language
Lex
420 projects
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to Linguist

Highlight.js
JavaScript syntax highlighter with language auto-detection and zero dependencies.
Stars: ✭ 19,312 (+106.1%)
Mutual labels:  syntax-highlighting, language-grammars
Highlightr
iOS & OSX Syntax Highlighter.
Stars: ✭ 1,116 (-88.09%)
Mutual labels:  syntax-highlighting
Influx Prompt
An interactive command-line InfluxDB cli with auto completion.
Stars: ✭ 42 (-99.55%)
Mutual labels:  syntax-highlighting
O
🌀 Text editor suitable for writing git commit messages and editing Markdown files. Can build executables and jump to errors at the press of `ctrl-space`, for several programming languages. Can format code with `ctrl-w`. Provides general syntax highlighting, rainbow parenthesis and cut/paste portals. o is intentionally limited to VT100.
Stars: ✭ 54 (-99.42%)
Mutual labels:  syntax-highlighting
Vue Prism
Simple Vue.js Syntax highlighting with Prism.js
Stars: ✭ 43 (-99.54%)
Mutual labels:  syntax-highlighting
Brew.vim
🍺 Vim Syntax for Homebrew formulae
Stars: ✭ 55 (-99.41%)
Mutual labels:  syntax-highlighting
Downlit
Syntax Highlighting and Automatic Linking
Stars: ✭ 39 (-99.58%)
Mutual labels:  syntax-highlighting
Wirb
Ruby Object Inspection for IRB
Stars: ✭ 69 (-99.26%)
Mutual labels:  syntax-highlighting
Syntax Highlighter Bot
Syntax highlighter bot for telegram.
Stars: ✭ 60 (-99.36%)
Mutual labels:  syntax-highlighting
Yii2 Quill
Yii 2 implementation of Quill, modern WYSIWYG editor
Stars: ✭ 52 (-99.45%)
Mutual labels:  syntax-highlighting
Dhall Vim
Syntax highlighting for Dhall
Stars: ✭ 51 (-99.46%)
Mutual labels:  syntax-highlighting
Base2tone
2 base hues - 32 variations > 1 theme
Stars: ✭ 43 (-99.54%)
Mutual labels:  syntax-highlighting
Vim Systemd Syntax
Syntax highlighting for systemd service files in Vim.
Stars: ✭ 57 (-99.39%)
Mutual labels:  syntax-highlighting
Ft Syntax Highlight
Pure CSS syntax highlighter, no Javascript required. Includes built-in tooltips with UI themes and syntax highlighting themes
Stars: ✭ 42 (-99.55%)
Mutual labels:  syntax-highlighting
Smart Area
📝 Textareas on Steroids - AngularJS directive
Stars: ✭ 65 (-99.31%)
Mutual labels:  syntax-highlighting
Language Vue Component
Adds syntax highlighting to Vue Component files in Atom
Stars: ✭ 39 (-99.58%)
Mutual labels:  syntax-highlighting
Vim Html Template Literals
Syntax highlighting for html template literals in javascript (as in lit-html and polymer 3)
Stars: ✭ 48 (-99.49%)
Mutual labels:  syntax-highlighting
Vue Theme Vscode
+200.000 installs ⬇️ Theme for Visual Studio Code inspired by Vue.js, with support for more popular languages, trying to maintain a perfect harmony of colors.
Stars: ✭ 54 (-99.42%)
Mutual labels:  syntax-highlighting
Subethaedit
General purpose plain text editor for macOS. Widely known for its live collaboration feature.
Stars: ✭ 1,183 (-87.37%)
Mutual labels:  syntax-highlighting
Jupyter Themes
Custom Jupyter Notebook Themes
Stars: ✭ 8,879 (-5.24%)
Mutual labels:  syntax-highlighting

Linguist

Actions Status

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

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.

  1. charlock_holmes
  2. rugged

You may need to install missing dependencies before you can install Linguist. For example, on macOS with Homebrew:

brew install cmake pkg-config icu4c

On Ubuntu:

sudo apt-get install cmake pkg-config libicu-dev zlib1g-dev libcurl4-openssl-dev libssl-dev ruby-dev

Usage

Application usage

Linguist can be used in your application as follows:

require 'rugged'
require 'linguist'

repo = Rugged::Repository.new('.')
project = Linguist::Repository.new(repo, repo.head.target_id)
project.language       #=> "Ruby"
project.languages      #=> { "Ruby" => 119387 }

Command line usage

Git Repository

A repository's languages stats can also 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

--breakdown

The --breakdown or -b flag will additionally show the breakdown of files by language.

You can try running github-linguist on the root directory in this repository itself:

$ github-linguist --breakdown
66.84%  264519     Ruby
24.68%  97685      C
6.57%   25999      Go
1.29%   5098       Lex
0.32%   1257       Shell
0.31%   1212       Dockerfile

Ruby:
Gemfile
Rakefile
bin/git-linguist
bin/github-linguist
ext/linguist/extconf.rb
github-linguist.gemspec
lib/linguist.rb
--json

The --json or -j flag output the data into JSON format.

$ github-linguist --json
{"Dockerfile":{"size":1212,"percentage":"0.31"},"Ruby":{"size":264519,"percentage":"66.84"},"C":{"size":97685,"percentage":"24.68"},"Lex":{"size":5098,"percentage":"1.29"},"Shell":{"size":1257,"percentage":"0.32"},"Go":{"size":25999,"percentage":"6.57"}}

This option can be used in conjunction with --breakdown to get a full list of files along with the size and percentage data.

$ github-linguist --breakdown --json
{"Dockerfile":{"size":1212,"percentage":"0.31","files":["Dockerfile","tools/grammars/Dockerfile"]},"Ruby":{"size":264519,"percentage":"66.84","files":["Gemfile","Rakefile","bin/git-linguist","bin/github-linguist","ext/linguist/extconf.rb","github-linguist.gemspec","lib/linguist.rb",...]}}

Single file

Alternatively you can find stats for a single file using the github-linguist executable.

You can try running github-linguist on files in this repository itself:

$ github-linguist grammars.yml
grammars.yml: 884 lines (884 sloc)
  type:      Text
  mime type: text/x-yaml
  language:  YAML

Docker

If you have Docker installed you can build an image and run Linguist within a container:

$ docker build -t linguist .
$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t 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
$ docker run --rm -v $(pwd):$(pwd) -w $(pwd) -t linguist github-linguist --breakdown
66.84%  264519     Ruby
24.68%  97685      C
6.57%   25999      Go
1.29%   5098       Lex
0.32%   1257       Shell
0.31%   1212       Dockerfile

Ruby:
Gemfile
Rakefile
bin/git-linguist
bin/github-linguist
ext/linguist/extconf.rb
github-linguist.gemspec
lib/linguist.rb

Contributing

Please check out our contributing guidelines.

License

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].