├── .gitignore ├── COPYING ├── Makefile ├── ONEFETCH.md ├── README.md ├── img ├── default-light.png ├── git-light-large.png ├── git-light.png ├── onefetch-gfe-light.png └── onefetch-light.png ├── lib ├── human.sh └── util.sh ├── src ├── ascii.sh ├── authors.sh ├── commits.sh ├── created.sh ├── defconfig.sh ├── gitver.sh ├── head.sh ├── languages.sh ├── latest.sh ├── loc.sh ├── main.sh ├── project.sh ├── showinfo.sh ├── srcsize.sh ├── upstream.sh ├── user.sh └── version.sh └── tests ├── lib.sh └── main.sh /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | tmp/ 3 | 4 | **/*.*.sw[po] 5 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | MIT License 2 | =========== 3 | 4 | - Copyright © 2020 Kiëd Llaentenn 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights to 9 | (mis)use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is furnished 11 | to do so, subject to the following conditions: 12 | 13 | - The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # gfe: git fetch script 3 | # https://github.com/lptstr/gfe 4 | # 5 | # (c) Kiëd Llaentenn 6 | # See the COPYING file for more information 7 | # 8 | 9 | .POSIX: 10 | 11 | CMD = 12 | 13 | PREFIX = /usr/local 14 | DESTDIR = 15 | 16 | BIN = gfe 17 | OBJDIR = bin 18 | 19 | CAT = $(shell which cat) 20 | CHMOD = $(shell which chmod) 21 | RM = $(shell which rm) 22 | INSTALL = $(shell which install) 23 | 24 | SRC = lib/human.sh lib/util.sh \ 25 | src/commits.sh src/created.sh src/head.sh \ 26 | src/latest.sh src/authors.sh src/gitver.sh \ 27 | src/project.sh src/srcsize.sh src/user.sh \ 28 | src/upstream.sh src/version.sh src/languages.sh \ 29 | src/loc.sh \ 30 | src/defconfig.sh src/showinfo.sh src/ascii.sh \ 31 | src/main.sh 32 | 33 | all: bin/$(BIN) 34 | 35 | clean: 36 | $(CMD)$(RM) -rf $(OBJDIR) 37 | 38 | $(OBJDIR): 39 | $(CMD)mkdir -p $(OBJDIR) 40 | 41 | $(OBJDIR)/$(BIN): $(OBJDIR) $(SRC) 42 | $(CMD)printf "#!/bin/sh\n# gfe: git fetch\n\n" | \ 43 | $(CAT) - $(SRC) > $(OBJDIR)/$(BIN) 44 | $(CMD)$(CHMOD) +x $(OBJDIR)/$(BIN) 45 | 46 | run: 47 | @$(OBJDIR)/$(BIN) 48 | 49 | install: $(OBJDIR)/$(BIN) 50 | $(CMD)$(INSTALL) -Dm755 $(OBJDIR)/$(BIN) \ 51 | $(DESTDIR)/$(PREFIX)/bin/$(BIN) 52 | 53 | uninstall: 54 | $(CMD)$(RM) -f $(DESTDIR)/$(PREFIX)/bin/$(BIN) 55 | 56 | check: tests/main.sh 57 | $(CMD)tests/main.sh 58 | 59 | .PHONY: all clean $(OBJDIR)/$(BIN) run install uninstall check 60 | -------------------------------------------------------------------------------- /ONEFETCH.md: -------------------------------------------------------------------------------- 1 | # onefetch vs gfetch 2 | 3 | > NOTE: if you think any comparison here is unfair in the least to Onefetch, 4 | > submit an issue and I will remove it. 5 | 6 | ## design 7 | 8 | It's probably only me, but when I first started using Onefetch, I began to feel 9 | as if Onefetch was designed only for pretty screenshots. Huge ASCII art that 10 | can't be disabled, a strange license field, a *colorblocks* field (how on earth 11 | does the terminal's colorscheme relate to Git), written in Rust, slow for large 12 | projects. 13 | 14 | onefetch 16 | 17 | Again, it's probably only me, but I don't really like the fact that it's written 18 | in Rust. I've worked on a fetch tool in Rust myself [1](#f1), 19 | and I've come to the conclusion that Rust is *probably* not the best tool for a 20 | fetch program. Shell is a great language for a fetch tool, because all a fetch 21 | tool really does is extract text from commands and various files. And the fact 22 | that they're all in a hundred different formats doesn't matter either, because 23 | you can easily utilize `awk` and `sed` to massage it into the format you want. 24 | 25 | onefetch 27 | 28 | Onefetch solves the problem of text extraction by using various libraries (e.g. 29 | the `git2` crate) instead of running commands. [2](#f2) 30 | Again, probably only me, but I don't like that either. I like to see what 31 | commands my fetch tool is running, if only for the education. 32 | 33 | On the other hand, `gfetch` was designed for fetching information. I don't want 34 | you to wait while the you fetches all the information before printing 35 | it, I want it now! And when you do, I don't want a huge 40-column ASCII art with 36 | the logo of the language I'm using. I already know what language it's written 37 | in, and even if I didn't, the `Language` field is quite enough. And BTW, let me 38 | display my *own* info fields when I want to. The default ASCII can be ugly, I 39 | don't care, because I want to see the info, not the art. 40 | 41 | 42 | #### *This document is a work in progress.* 43 | 44 | 1. See [rsfetch](https://github.com/rsfetch/rsfetch) 45 | [↩](#a1) 46 | 2. Note, I only did a very cursory examination of the Onefetch 47 | source, so I'm probably a bit off there. [↩](#a2) 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

gfetch

2 |

what? | where? | how? | why? | faq | license

3 |
4 |

5 | GitHub code size in bytes 6 | Lines of code 7 | 8 | 9 |
10 | build with Neovim 11 |

12 | 13 |
14 | 15 | scrot 16 | 17 | `gfetch` is a tiny, lightweight Git fetch script that can be used as an alternative 18 | to [`onefetch`](https://github.com/o2sh/onefetch). 19 | 20 | ## what? 21 | 22 | `gfetch` runs a various commands (e.g. `git rev-list --count --all`) to 23 | retrieve some statistics (e.g. current branch) for the current project. 24 | It's just a little convenience utility to prevent having to run ten 25 | different commands and parsing with grep or sed. 26 | 27 | Compared to Onefetch, `gfetch` is 28 | 29 | - **small**: the entire script is less than 300 lines of code (not counting 30 | comments). 31 | - **fast**: shows information for the `git` repository in just a few seconds. 32 | - **POSIX**: runs on just about any modern POSIX shell: `bash`, `dash`, `mksh`, 33 | `loksh`, anything short of `tcsh` or `mksh`. 34 | - **less distracting**. `gfetch` does not have and never will have 35 | huge, ridiculous ASCII art that takes up half the screen. 36 | - **configurable**. This fetch script was designed from the ground up to be 37 | completely configurable, down to the order of the information fields. Every 38 | single field -- even the (small) ASCII art -- can be disabled. 39 | 40 | Note that `gfetch` is still in very early stages. Expect bugs, incorrect 41 | information, and lots of missing features. 42 | 43 | ## where? 44 | 45 | You will need: 46 | 47 | - a Unix-like system (Windows support is planned) 48 | - a fairly modern version of Git (duh) 49 | - a POSIX-compliant shell. (so no fish, tcsh, etc) 50 | - GNU sed and GNU awk (other sed/awk implementations *might* work, but are 51 | untested.) 52 | - GNU Make (the Makefile is incompatible with `bmake`) 53 | - SCC (optional, only required for language detection and LOC count) 54 | 55 | Then, simply grab a release tarball from the GitHub releases, extract, and run: 56 | 57 | ``` 58 | $ make clean all 59 | # make install 60 | ``` 61 | 62 | NOTE: ensure that the `/usr/local/bin` path is directory is in your path first, 63 | since that's where it's installed by default. If you want to install to a 64 | different location (e.g. `/usr/bin`) you can run `make PREFIX=/usr install` 65 | instead. 66 | 67 | ## how? 68 | 69 | Ensure that the `gfe` script is in your path, then execute it. 70 | 71 | **Configuration** is done by editing the shell script at 72 | `~/.config/gfe/config.sh`, which is created by default if it doesn't exist. 73 | It is then `source`d by `gfe` on startup. 74 | 75 | The configuration file consists of some environment variable definitions, 76 | which are only set if they are empty. This allows them to be overridden at 77 | runtime. 78 | 79 | The list of environment variables is as follows: 80 | 81 | ``` 82 | # ensure that you use the 83 | # form GFE_VALUE=\${GFE_VALUE:-othervalue} 84 | # to ensure that it can be overridden on 85 | # the command line!! 86 | # 87 | # GFE_LOGO: path to file with ASCII art. 88 | # if it\'s value is not a valid file, then 89 | # it is treated as ASCII art itself. 90 | GFE_LOGO=\"\${GFE_LOGO:-}\" 91 | 92 | # GFE_ALIGN: number of spaces for padding between 93 | # name and info columnds 94 | GFE_ALIGN=\"\${GFE_ALIGN:-13}\" 95 | 96 | # GFE_COL1: color for the first column (the 97 | # name column). possible values: 1-7 98 | GFE_COL1=\"\${GFE_COL1:-1}\" 99 | 100 | # GFE_COL2: color for the second column (the 101 | # info column). possible values: 1-7 102 | GFE_COL2=\"\${GFE_COL2:-7}\" 103 | 104 | # GFE_COL3: color for the header/title. 105 | # possible values: 1-7 106 | GFE_COL3=\"\${GFE_COL3:-1}\" 107 | 108 | # GFE_SEP: character or text to separate each name 109 | # and info line. 110 | # e.g. using the value ':' would become 'name: info' 111 | # in output. 112 | GFE_SEP=\"\${GFE_SEP:-}\" 113 | 114 | # GFE_DIR: directory/repository for gfetch to cd 115 | # into. 116 | GFE_DIR=\"\${GFE_DIR:-}\" 117 | 118 | # GFE_AUTHOR_MAX: maximum number of authors for the 119 | # AUTHORS gfe field. 120 | GFE_AUTHORS_MAX=\"\${GFE_AUTHORS_MAX:-2}\" 121 | 122 | # GFE_LANG_MAX: maximum number of languages for the 123 | # LANGUAGES gfe field. 124 | GFE_LANG_MAX=\"\${GFE_LANG_MAX:-2}\" 125 | ``` 126 | 127 | The config file also contains `gfe_info()` function, which is executed 128 | by `gfe` to show the information. It looks something like this: 129 | 130 | ``` 131 | gfe_info() { 132 | # print a newline. 133 | printf '' 134 | 135 | # print the default ASCII art. 136 | # note that the show_ascii() function must be 137 | # the FIRST if it is used. 138 | show_ascii 139 | 140 | # print a Onefetch-esque header, with the 141 | # Git username and Git version. 142 | # usage: showheader 143 | showheader "$(get_user)" "$(get_gitver)" " ~ " 144 | 145 | # Each showinfo call prints one row of info. 146 | # By default, all available info is printed. 147 | # each command inside the "$()" is a gfetch 148 | # function to get information. 149 | # 150 | # if you wish, you can even display your own text 151 | # with the showinfo function. 152 | # e.g. showinfo "$(hostname)" "HOSTNAME" 153 | 154 | # usage: showinfo