onefetch Documentation

Command-line Git information tool

11,991 stars Rust Rust 1 file ยท ~2,771 tokens #cli#command-line#command-line-interface#git#rust#tool
RAW Doc

File: README.md


Onefetch is a command-line Git information tool that displays project information and code statistics for a local Git repository directly in your terminal. The tool works completely offline with a focus on performance and customizability.

Installation

Onefetch is available on Linux, macOS, and Windows platforms. Binaries for Linux, Windows, and macOS are available on the release page.

Linux

  • Ubuntu

    text
    wget https://github.com/o2sh/onefetch/releases/latest/download/onefetch_amd64.deb && sudo dpkg -i ./onefetch_amd64.deb && rm onefetch_amd64.deb
  • Arch Linux

    text
    pacman -S onefetch
  • openSUSE

    text
    zypper install onefetch

macOS

text
brew install onefetch

Windows

text
winget install onefetch

Usage

text
onefetch /path/of/your/repo

Or

text
cd /path/of/your/repo
onefetch

Customization

Onefetch can be customized via command-line arguments to display exactly what you want, the way you want it: adjust the text styling, disable info lines, ignore files and directories, output in multiple formats (JSON, YAML), etc.

Frequently Asked Questions

Why isn't my language detected?

By default, onefetch only displays programming and markup languages. Languages classified as prose (like Org mode, Markdown, or Text) or data (like JSON, YAML, or TOML) are hidden unless you include them with --type.

text
onefetch --type programming markup prose data

Why do duplicate authors appear?

Onefetch reads authors from the Git history. If the same person committed with different names or emails, they may appear more than once.

To merge those entries, add a .mailmap file to the repository.

Contributing

Currently, onefetch supports more than 100 different programming languages; if your language of choice isn't supported, open an issue and support will be added.

Contributions are very welcome! See CONTRIBUTING for more info.


File: ascii/README.md

ascii


Provides the primary interface to display ascii art to the terminal.

More info here.

This crate is designed as part of the onefetch project.



File: docs/wiki/_Sidebar.md


File: docs/wiki/ascii-art.md

This is the format onefetch uses for its ASCII art files.

Here's an example:

text
{2}            .:--::////::--.`
{1}        `/yNMMNho{2}////////////:.
{1}      `+NMMMMMMMMmy{2}/////////////:`
{0}    `-:::{1}ohNMMMMMMMNy{2}/////////////:`
{0}   .::::::::{1}odMMMMMMMNy{2}/////////////-
{0}  -:::::::::::{1}/hMMMMMMMmo{2}////////////-
{0} .::::::::::::::{1}oMMMMMMMMh{2}////////////-
{0}`:::::::::::::{1}/dMMMMMMMMMMNo{2}///////////`
{0}-::::::::::::{1}sMMMMMMmMMMMMMMy{2}//////////-
{0}-::::::::::{1}/dMMMMMMs{0}:{1}+NMMMMMMd{2}/////////:
{0}-:::::::::{1}+NMMMMMm/{0}:::{1}/dMMMMMMm+{2}///////:
{0}-::::::::{1}sMMMMMMh{0}:::::::{1}dMMMMMMm+{2}//////-
{0}`:::::::{1}sMMMMMMy{0}:::::::::{1}dMMMMMMm+{2}/////`
{0} .:::::{1}sMMMMMMs{0}:::::::::::{1}mMMMMMMd{2}////-
{0}  -:::{1}sMMMMMMy{0}::::::::::::{1}/NMMMMMMh{2}//-
{0}   .:{1}+MMMMMMd{0}::::::::::::::{1}oMMMMMMMo{2}-
{1}    `yMMMMMN/{0}:::::::::::::::{1}hMMMMMh.
{1}      -yMMMo{0}::::::::::::::::{1}/MMMy-
{1}        `/s{0}::::::::::::::::::{1}o/`
{0}            ``.---::::---..`

Features:

  • You can use {0} to {X}to color the ascii, with X > 0.
  • You can pass the flag -c, --ascii-colors 2 5 ... to set your own colors.
    • Look at the color palette to know the color order

File: docs/wiki/command-line-options.md

text
/* Detailed source-code truncated for AI context efficiency. */

File: docs/wiki/getting-started.md

Onefetch is installed, then what?

Usage

sh
> onefetch /path/of/your/repo

Or

sh
> cd /path/of/your/repo
> onefetch

Misc

By @spenserblack

sh
# Runs `onefetch -a Assembly`, `onefetch -a C`, etc.
onefetch -l | tr "[:upper:] " "[:lower:]-" | while read line; do echo "$line"; onefetch -a $line; done;

Automatic repo detection and running

If you want to automate the detection and running of onefetch every time you cd into a repository you can leverage one of the methods below:

1. Bash / Zsh

By @quazar-omega

A script to put in your .bashrc - or .zshrc - to run onefetch whenever you open a shell into a repository or cd into a repository, making sure that it's different from the last one you were in:

sh
# git repository greeter
last_repository=
check_directory_for_new_repository() {
 current_repository=$(git rev-parse --show-toplevel 2> /dev/null)
 
 if [ "$current_repository" ] && \
    [ "$current_repository" != "$last_repository" ]; then
  onefetch
 fi
 last_repository=$current_repository
}
cd() {
 builtin cd "$@"
 check_directory_for_new_repository
}

# optional, greet also when opening shell directly in repository directory
# adds time to startup
check_directory_for_new_repository

2. Fish

By @TheSast

A fish adaptation of the previous script, run it once in your shell to save it:

fish
function cd -w='cd'
  builtin cd $argv || return
  check_directory_for_new_repository
end

function check_directory_for_new_repository
  set current_repository (git rev-parse --show-toplevel 2> /dev/null)
  if [ "$current_repository" ] && \
    [ "$current_repository" != "$last_repository" ]
    onefetch
  end
  set -gx last_repository $current_repository
end

funcsave cd
funcsave check_directory_for_new_repository

3. CMD

By @mataha

An adaptation of the above snippet suited for Windows's cmd.exe,
specifically for inclusion in AutoRun scripts or DOSKEY macrofiles:

bat
@set LAST_REPOSITORY=

@doskey cd = ( ^
    for %%^^^^ in ("") do @for /f "delims=" %%i in (^^""$*%%~^^"^") do @( ^
        if "%%~i"=="" ( ^
            if defined USERPROFILE ( ^
                if /i not "%%CD%%"=="%%USERPROFILE%%" ( ^
                    chdir /d "%%USERPROFILE%%" ^&^& set "OLDPWD=%%CD%%" ^
                ) ^
            ) else (call) ^
        ) else if "%%~i"=="-" ( ^
            if defined OLDPWD ( ^
                if /i not "%%CD%%"=="%%OLDPWD%%" ( ^
                    chdir /d "%%OLDPWD%%"      ^&^& set "OLDPWD=%%CD%%" ^
                ) ^
            ) else (call) ^
        ) else ( ^
            if defined CD ( ^
                if /i not "%%CD%%"=="%%~fi" ( ^
                    chdir /d %%~fi             ^&^& set "OLDPWD=%%CD%%" ^
                ) ^
            ) else (call) ^
        ) ^
    ) ^
) ^&^& for /f "delims=" %%r in ('git rev-parse --show-toplevel 2^^^>nul') do @( ^
    if not "%%~r"=="%%LAST_REPOSITORY%%" ( ^
        onefetch ^
    ) ^& set "LAST_REPOSITORY=%%~r" ^
)

4. Powershell

By @kiapanahi

An adaptation of the above snippet suited for Powershell. Put this script in the $PROFILE.

pwsh
# git repository greeter

# Set the console output encoding to UTF-8, so that special characters are displayed correctly when piping to Write-Host
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$global:lastRepository = $null

function Check-DirectoryForNewRepository {
    $currentRepository = git rev-parse --show-toplevel 2>$null
    if ($currentRepository -and ($currentRepository -ne $global:lastRepository)) {
        onefetch | Write-Host
    }
    $global:lastRepository = $currentRepository
}

function Set-Location {
    Microsoft.PowerShell.Management\Set-Location @args  
    Check-DirectoryForNewRepository
}

# Optional: Check the repository also when opening a shell directly in a repository directory
# Uncomment the following line if desired
#Check-DirectoryForNewRepository

Git alias

By @mbrehin

You can also add git alias to run onefetch during your git workflows

sh
# Add Git alias for onefetch.
git config --global alias.project-summary '!which onefetch && onefetch'

File: docs/wiki/home.md

Welcome to the onefetch's wiki!


File: docs/wiki/images-in-the-terminal.md

Onefetch supports displaying images using kitty, Sixel and iTerm protocols.

When running onefetch --image ./My-picture.jpg, the program looks for the first Image Protocol supported by the terminal and use it to display the requested image instead of the Ascii logo.

If you decide to go manual, and want to force the use of a specific image protocol: onefetch --image ./My-picture.jpg --image-protocol sixel|kitty|iterm

Sixel

The Sixel protocol is handled by multiple terminal emulators such as iterm2, xterm (enabled via flag -ti 340), mlterm and WezTerm which are actively maintained.

You can increase the color resolution using the --color-resolution flag.

Kitty

The kitty terminal graphics protocol used on the terminal of the same name allows the program running in the terminal, to render graphics to the screen of the terminal emulator.

ITerm

The iTerm inline image protocol supported by iTerm2 (also WezTerm) allows to display images within the terminal.