Tokei (時計)
Tokei is a program that displays statistics about your code. Tokei will show number of files, total lines within those files and code, comments, and blanks grouped by language.
This is tokei running on its own directory
- Features
- Installation
- How to use Tokei
- Options
- Badges
- Plugins
- Supported Languages
- Changelog
- Common Issues
- Canonical Source
- Copyright and License
- Tokei is very fast, below are the Tokei's times on a select few large
repositories, with a hot cache(times are in seconds and measured using
/usr/bin/time
on macOS Sierra, with 2.7 GHz Intel Core i7, results will vary).
Repository | Real time |
---|---|
DragonFlyBSD | 1.50s |
Rust | 0.28s |
CPython | 0.18s |
-
Tokei is accurate, Tokei correctly handles multi line comments, nested comments, and not counting comments that are in strings. Providing an accurate code statistics.
-
Tokei has huge range of languages, supporting over 100 languages, and their various extensions.
-
Tokei can output in multiple formats(CBOR, JSON, TOML, YAML) allowing Tokei's output to be easily stored, and reused. These can also be reused in tokei combining a previous run's statistics with another set.
-
Tokei is available on Mac, Linux, and Windows. See installation instructions for how to get Tokei on your platform.
-
Tokei is also a library allowing you to easily integrate it with other projects.
$ pacman -S tokei
$ cargo install tokei
$ sudo dnf install tokei
$ pkg install tokei
$ brew install tokei
# using unstable nixpkgs channel
$ nix-env -i tokei
You can download prebuilt binaries in the releases section, or create from source.
$ git clone https://github.com/Aaronepower/tokei.git
$ cd tokei
$ cargo build --release
# sudo mv target/release/tokei /usr/local/bin
# sudo mv target/release/tokei /usr/local/bin/tokei
- Create a folder for tokei
- search for
env
- open "edit your enviroment variables"
- edit
PATH
- append folder path to the end of the string ie:
<path_stuff_here>;C:/tokei/;
This is the basic way to use tokei. Which will report on the code in ./foo
and all subfolders.
$ tokei ./foo
To have tokei report on multiple folders in the same call simply add a comma, or a space followed by another path.
$ tokei ./foo ./bar ./baz
$ tokei ./foo, ./bar, ./baz
Tokei will respect all .gitignore
and .ignore
files, and you can optionally
the --exclude
option to exclude any addtional files. The --exclude
flag has
the same semantics as .gitignore
.
$ tokei ./foo --exclude *.rs
By default tokei sorts alphabetically by language name, however using --sort
tokei can also sort by any of the columns.
blanks, code, comments, lines
$ tokei ./foo --sort code
By default tokei only outputs the total of the languages, and using --files
flag tokei can also output individual file statistics.
$ tokei ./foo --files
Tokei normally outputs into a nice human readable format designed for terminals.
There is also using the --output
option various other formats that are more
useful for bringing the data into another program.
Currently supported formats
- JSON
--output json
- YAML
--output yaml
- TOML
--output toml
- CBOR
--output cbor
$ tokei ./foo --output json
Tokei can also take in the outputted formats added the previous results to it's current run. Tokei can take either a path to a file, the format passed in as a value to the option, or from stdin.
$ tokei ./foo --input ./stats.json
Tokei 4.5.3
Aaron P. <theaaronepower@gmail.com>
Count Code, Quickly.
USAGE:
Tokei [FLAGS] [OPTIONS] <input>...
FLAGS:
-f, --files Will print out statistics on individual files.
-h, --help Prints help information
-l, --languages Prints out supported languages and their extensions.
-V, --version Prints version information
-v, --verbose Set verbose output level: 1: for unknown extensions
OPTIONS:
-e, --exclude <exclude> Ignore all files & directories containing the word.
-i, --input <file_input> Gives statistics from a previous tokei run. Can be given a file path, or "stdin" to read from stdin.
-o, --output <output> Outputs Tokei in a specific format. [values: cbor, json, toml, yaml]
-s, --sort <sort> Will sort based on column [values: files, lines, blanks, code, comments]
ARGS:
<input>... The input file(s)/directory(ies)
Tokei has support for badges. For example .
[![](https://tokei.rs/b1/github/Aaronepower/tokei)](https://github.com/Aaronepower/tokei).
Tokei's URL scheme is as follows.
https://tokei.rs/{host: values: github|gitlab}/{Repo Owner eg: Aaronepower}/{Repo name eg: tokei}
By default the badge will show the repo's LoC(Lines of Code), you can also
specify for it to show a different category, by using the ?category=
query
string. It can be either code
, blanks
, files
, lines
, comments
,
Example show total lines:
[![](https://tokei.rs/b1/github/Aaronepower/tokei?category=lines)](https://github.com/Aaronepower/tokei).
Thanks to contributors tokei is now available as a plugin for some text editors.
If there is a language that you want added, feel free to submit a pull request
with the following information. If you're unsure have a look at
languages.json
to see how other languages are defined.
- Name of language
- File Extension(s)
- The comment syntax (Does it have block comments? is it the same as C?)
- The string literal syntax
ABAP
ActionScript
Ada
Alex
Agda
ASP
ASP.NET
Assembly
Autoconf
SH
AutoHotKey
BASH
FISH
Batch
C
C Header
C#
C Shell
Cabal
Cassius
Ceylon
Clojure
CMake
COBOL
CoffeeScript
Cogent
ColdFusion
ColdFusion CFScript
Coq
C++
C++ Header
CSS
Crystal
D
Dart
Device Tree
Dockerfile
Elixir
Elm
Emacs Development Environment
Emacs Lisp
Erlang
Forth
F*
F#
FORTRAN Legacy
FORTRAN Modern
GDScript
GLSL
Go
Groovy
Happy
Handlebars
Haskell
Haxe
HEX
HTML
Hamlet
Idris
Intel HEX
Isabelle
JAI
Java
JavaScript
JSON
JSX
Julia
Julius
Kotlin
Lean
LESS
LD Script
LISP
Lua
Lucius
Madlang
Makefile
Markdown
Meson
ModuleDef
Mustache
Nim
Nix
OCaml
Objective C
Objective C++
Org mode
Oz
Pascal
Perl
PHP
Polly
Processing
Prolog
Protocol Buffers
PSL Assertions
PureScript
Python
QCL
QML
R
Rakefile
Razor
ReStructuredText
Ruby
Ruby HTML
Rust
Sass
Scala
Scons
SRecode Template
Standard ML
Specman e
SPICE Netlists
SQL
SVG
Swift
SystemVerilog
TCL
TeX
Plain Text
TOML
TypeScript
Unreal Script
Ur/Web
Vala
Verilog
Verilog argument files
VHDL
Vim Script
Wolfram
Xaml
XML
Xtend
YAML
Zsh
This is likely due to gcc
generating .d
files. Until the D people decide on
a different file extension, you can always exclude .d
files using the
-e --exclude
flag like so
$ tokei . -e *.d
The canonical source of this repo is hosted on GitHub. If you have a GitHub account, please make your issues, and pull requests there.
(C) Copyright 2015 by Aaron Power and contributors
See CONTRIBUTORS.md for a full list of contributors.
Tokei is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENCE-APACHE, LICENCE-MIT for more information.