20 Commits
Author SHA1 Message Date
Yash-Handa e9103c7b9f bumped up version to 1.3.7 2021-01-19 14:46:25 +05:30
Yash Handa a63c74a66b fixed windows os display 2021-01-19 14:03:52 +05:30
Yash-Handa 2492038848 optamization of -D (git status) command 2020-12-29 12:24:40 +05:30
Yash-Handa 50b0a296ec Updated snapshort for change from white to noColor 2020-12-28 20:46:20 +05:30
Yash HandaandGitHub f05b146afe Merge pull request #17 from Ortiye/master
Fix colors
2020-12-28 19:19:50 +05:30
Yash HandaandGitHub 77afdeb394 removed reference of white 2020-12-28 19:15:07 +05:30
Yash-Handa c32decf6d5 Go build passing 2020-12-28 19:08:42 +05:30
Yash-Handa 8495741d5f Made recursion alphabetic for re-producability 2020-12-28 19:06:25 +05:30
Yash HandaandGitHub 24436936f0 Create go.yml 2020-12-28 18:40:49 +05:30
Yash-Handa 81e700ab5d Added end to end tests for commands 2020-12-28 18:36:43 +05:30
Yash HandaandGitHub 9972f5644a Merge pull request #18 from komem3/shellwidth
Supported for terminals that do not support 'TIOCGWINSZ'
2020-11-01 18:15:49 +05:30
Yash-Handa c6c7cf7b1f Added support for sub-extentions for files.
The list of sub-extentions added are :
routing.ts, routing.tsx, routing.js, routing.jsx, routes.ts, routes.tsx, routes.js, routes.jsx, sln.dotsettings, d.ts, vcxitems.filters, vcxproj.filters, js.map, mjs.map, css.map, spec.ts, e2e-spec.ts, test.ts, ts.snap, spec.tsx, test.tsx, tsx.snap, spec.jsx, test.jsx, jsx.snap, spec.js, e2e-spec.js, test.js, js.snap, tf.json, blade.php, inky.php, gitlab-ci.yml, stories.js, stories.jsx, story.js, story.jsx, stories.ts, stories.tsx, story.ts, story.tsx, azure-pipelines.yml, azure-pipelines.yaml
2020-11-01 17:38:01 +05:30
Yash HandaandGitHub 483c3a3060 Merge pull request #6 from mattn/windows
Support Windows
2020-11-01 06:34:29 +05:30
Yash HandaandGitHub 9542954447 Merge pull request #14 from EugeneChung/patch-1
change Mac OS man page
2020-11-01 05:57:57 +05:30
Yasuhiro Matsumoto bd000027bf Merge branch 'master' into windows 2020-10-05 23:46:45 +09:00
komem3 023e18fcb3 Supported for terminals that do not support 'TIOCGWINSZ'
Not all terminals can use 'TIOCGWINSZ' to get the size of the terminal.
That's why I used the "COLUMNS" variable to get the size when the width is zero.
2020-10-01 19:46:39 +09:00
Ortiye e0da5f56f6 fix colors 2020-09-30 22:07:27 +02:00
Eugene ChungandGitHub f43afd530a change Mac OS man page
to /usr/local/share/man/man1/

sudo cp logo-ls.1.gz /usr/share/man/man1/
cp: /usr/share/man/man1/logo-ls.1.gz: Read-only file system
(On Catalina 10.15.7)
2020-09-30 14:11:48 +09:00
Yasuhiro Matsumoto 503f937cf3 Fix .goreleaser.yml 2020-09-23 11:24:06 +09:00
Yasuhiro Matsumoto 1b76d79de4 Support Windows 2020-09-23 10:42:45 +09:00
34 changed files with 785 additions and 116 deletions
+36
View File
@@ -0,0 +1,36 @@
name: Go
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
+4 -1
View File
@@ -23,4 +23,7 @@ dist
# env stuff
*.env
.gh_token
.gh_token
# test related data
testdata/dirEnv*
+2 -2
View File
@@ -17,7 +17,7 @@ builds:
# supported OS
goos:
- linux
# - windows
- windows
- darwin
# supported ARCH
goarch:
@@ -98,4 +98,4 @@ nfpms:
recommends:
- golang
files:
"logo-ls.1.gz": "/usr/share/man/man1/logo-ls.1.gz"
"logo-ls.1.gz": "/usr/share/man/man1/logo-ls.1.gz"
+3 -3
View File
@@ -7,12 +7,12 @@
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/Yash-Handa/logo-ls?style=flat-square)
![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/Yash-Handa/logo-ls?sort=semver&style=flat-square)
![PRs](https://img.shields.io/badge/PRs-welcome-56cc14?style=flat-square)
[![HitCount](http://hits.dwyl.com/Yash-Handa/logo-ls.svg)](http://hits.dwyl.com/Yash-Handa/logo-ls)
![AUR](https://img.shields.io/aur/version/logo-ls?style=flat-square&logo=Arch-Linux&labelColor=abcdef&label=AUR)
![deb](https://img.shields.io/badge/-Deb%20Package-A81D33?style=flat-square&logo=Debian&link=https://github.com/Yash-Handa/logo-ls/releases/)
![rpm](https://img.shields.io/badge/-RPM%20Package-EE0000?style=flat-square&logo=Red-Hat&link=https://github.com/Yash-Handa/logo-ls/releases/)
![linux](https://img.shields.io/badge/-Linux%20Binary-FCC624?style=flat-square&logo=Linux&logoColor=000000&link=https://github.com/Yash-Handa/logo-ls/releases/)
![apple](https://img.shields.io/badge/-Darwin%20Binary-999999?style=flat-square&logo=Apple&logoColor=ffffff&link=https://github.com/Yash-Handa/logo-ls/releases/)
![Go](https://github.com/Yash-Handa/logo-ls/workflows/Go/badge.svg)
modern ls command with beautiful Icons and Git Integrations . Written in Golang
@@ -291,10 +291,10 @@ $ sudo cp logo-ls /usr/local/bin
#### Step 4
If you want the man page of `logo-ls` place `logo-ls.1.gz` in `/usr/share/man/man1/`
If you want the man page of `logo-ls` place `logo-ls.1.gz` in `/usr/local/share/man/man1/`
```cmd
$ sudo cp logo-ls.1.gz /usr/share/man/man1/
$ sudo cp logo-ls.1.gz /usr/local/share/man/man1/
```
### Linux
+8
View File
@@ -331,6 +331,14 @@ var Icon_FileName = map[string]*Icon_Info{
".modernizrrc": Icon_Set["modernizr"],
".modernizrrc.js": Icon_Set["modernizr"],
".modernizrrc.json": Icon_Set["modernizr"],
"routing.ts": Icon_Set["routing"],
"routing.tsx": Icon_Set["routing"],
"routing.js": Icon_Set["routing"],
"routing.jsx": Icon_Set["routing"],
"routes.ts": Icon_Set["routing"],
"routes.tsx": Icon_Set["routing"],
"routes.js": Icon_Set["routing"],
"routes.jsx": Icon_Set["routing"],
// ".vfl": Icon_Set["vfl"],
// ".kl": Icon_Set["kl"],
// "project.graphcool": Icon_Set["graphcool"],
+9
View File
@@ -31,6 +31,7 @@ var Icon_Set = map[string]*Icon_Info{
"html": {i: "\uf13b", c: [3]uint8{228, 79, 57}}, // html
"markdown": {i: "\uf853", c: [3]uint8{66, 165, 245}}, // markdown
"css": {i: "\uf81b", c: [3]uint8{66, 165, 245}}, // css
"css-map": {i: "\ue749", c: [3]uint8{66, 165, 245}}, // css-map
"sass": {i: "\ue603", c: [3]uint8{237, 80, 122}}, // sass
"less": {i: "\ue60b", c: [3]uint8{2, 119, 189}}, // less
"json": {i: "\ue60b", c: [3]uint8{251, 193, 60}}, // json
@@ -38,10 +39,15 @@ var Icon_Set = map[string]*Icon_Info{
"xml": {i: "\uf72d", c: [3]uint8{64, 153, 69}}, // xml
"image": {i: "\uf71e", c: [3]uint8{48, 166, 154}}, // image
"javascript": {i: "\ue74e", c: [3]uint8{255, 202, 61}}, // javascript
"javascript-map": {i: "\ue781", c: [3]uint8{255, 202, 61}}, // javascript-map
"test-jsx": {i: "\uf595", c: [3]uint8{35, 188, 212}}, // test-jsx
"test-js": {i: "\uf595", c: [3]uint8{255, 202, 61}}, // test-js
"react": {i: "\ue7ba", c: [3]uint8{35, 188, 212}}, // react
"react_ts": {i: "\ue7ba", c: [3]uint8{36, 142, 211}}, // react_ts
"settings": {i: "\uf013", c: [3]uint8{66, 165, 245}}, // settings
"typescript": {i: "\ue628", c: [3]uint8{3, 136, 209}}, // typescript
"typescript-def": {i: "\ufbe4", c: [3]uint8{3, 136, 209}}, // typescript-def
"test-ts": {i: "\uf595", c: [3]uint8{3, 136, 209}}, // test-ts
"pdf": {i: "\uf724", c: [3]uint8{244, 68, 62}}, // pdf
"table": {i: "\uf71a", c: [3]uint8{139, 195, 74}}, // table
"visualstudio": {i: "\ue70c", c: [3]uint8{173, 99, 188}}, // visualstudio
@@ -57,6 +63,7 @@ var Icon_Set = map[string]*Icon_Info{
"cpp": {i: "\ufb71", c: [3]uint8{2, 119, 189}}, // cpp
"go": {i: "\ufcd1", c: [3]uint8{32, 173, 194}}, // go
"go-mod": {i: "\ufcd1", c: [3]uint8{237, 80, 122}}, // go-mod
"go-test": {i: "\ufcd1", c: [3]uint8{255, 213, 79}}, // go-test
"python": {i: "\uf81f", c: [3]uint8{52, 102, 143}}, // python
"python-misc": {i: "\uf820", c: [3]uint8{130, 61, 28}}, // python-misc
"url": {i: "\uf836", c: [3]uint8{66, 165, 245}}, // url
@@ -185,6 +192,8 @@ var Icon_Set = map[string]*Icon_Info{
"centOS": {i: "\uf304", c: [3]uint8{157, 83, 135}}, // centOS
"alpine": {i: "\uf300", c: [3]uint8{14, 87, 123}}, // alpine
"mint": {i: "\uf30f", c: [3]uint8{125, 190, 58}}, // mint
"routing": {i: "\ufb40", c: [3]uint8{67, 160, 71}}, // routing
"laravel": {i: "\ue73f", c: [3]uint8{248, 80, 81}}, // laravel
"pug": {i: "\ue60e", c: [3]uint8{239, 204, 163}}, // pug (Not supported by nerdFont)
"blink": {i: "\uf72a", c: [3]uint8{249, 169, 60}}, // blink (The Foundry Nuke) (Not supported by nerdFont)
"postcss": {i: "\uf81b", c: [3]uint8{244, 68, 62}}, // postcss (Not supported by nerdFont)
+47
View File
@@ -0,0 +1,47 @@
package assets
var Icon_SubExt = map[string]*Icon_Info{
"routing.ts": Icon_Set["routing"],
"routing.tsx": Icon_Set["routing"],
"routing.js": Icon_Set["routing"],
"routing.jsx": Icon_Set["routing"],
"routes.ts": Icon_Set["routing"],
"routes.tsx": Icon_Set["routing"],
"routes.js": Icon_Set["routing"],
"routes.jsx": Icon_Set["routing"],
"sln.dotsettings": Icon_Set["settings"],
"d.ts": Icon_Set["typescript-def"],
"vcxitems.filters": Icon_Set["visualstudio"],
"vcxproj.filters": Icon_Set["visualstudio"],
"js.map": Icon_Set["javascript-map"],
"mjs.map": Icon_Set["javascript-map"],
"css.map": Icon_Set["css-map"],
"spec.ts": Icon_Set["test-ts"],
"e2e-spec.ts": Icon_Set["test-ts"],
"test.ts": Icon_Set["test-ts"],
"ts.snap": Icon_Set["test-ts"],
"spec.tsx": Icon_Set["test-jsx"],
"test.tsx": Icon_Set["test-jsx"],
"tsx.snap": Icon_Set["test-jsx"],
"spec.jsx": Icon_Set["test-jsx"],
"test.jsx": Icon_Set["test-jsx"],
"jsx.snap": Icon_Set["test-jsx"],
"spec.js": Icon_Set["test-js"],
"e2e-spec.js": Icon_Set["test-js"],
"test.js": Icon_Set["test-js"],
"js.snap": Icon_Set["test-js"],
"tf.json": Icon_Set["terraform"],
"blade.php": Icon_Set["laravel"],
"inky.php": Icon_Set["laravel"],
"gitlab-ci.yml": Icon_Set["gitlab"],
"stories.js": Icon_Set["storybook"],
"stories.jsx": Icon_Set["storybook"],
"story.js": Icon_Set["storybook"],
"story.jsx": Icon_Set["storybook"],
"stories.ts": Icon_Set["storybook"],
"stories.tsx": Icon_Set["storybook"],
"story.ts": Icon_Set["storybook"],
"story.tsx": Icon_Set["storybook"],
"azure-pipelines.yml": Icon_Set["azure-pipelines"],
"azure-pipelines.yaml": Icon_Set["azure-pipelines"],
}
+2 -2
View File
@@ -34,7 +34,7 @@ func TestFileIcons(t *testing.T) {
i := assets.Icon_Set[v]
fmt.Fprintln(os.Stderr)
buf := bytes.NewBuffer([]byte(""))
log.Println("Printing files of type", i.GetColor(1)+v+"\033[38;2;255;255;255m")
log.Println("Printing files of type", i.GetColor(1)+v+"\033[0m")
w := ctw.New(terminalWidth)
for f, d := range assets.Icon_FileName {
if d == i {
@@ -46,7 +46,7 @@ func TestFileIcons(t *testing.T) {
io.Copy(os.Stderr, buf)
buf = bytes.NewBuffer([]byte(""))
log.Println("Printing extentions of type", i.GetColor(1)+v+"\033[38;2;255;255;255m")
log.Println("Printing extentions of type", i.GetColor(1)+v+"\033[0m")
w = ctw.New(terminalWidth)
for e, d := range assets.Icon_Ext {
if d == i {
+86
View File
@@ -0,0 +1,86 @@
# The below list of icons are not included as are not currently supported by nerd fonts, If you are interested consider opening PRs on Nerd Fonts repo
icons:
- riot
- autoit
- livescript
- reason
- bucklescript
- mathematica
- wolframlanguage
- nunjucks
- haml
- cucumber
- vfl
- kl
- coldfusion
- cabal
- restql
- kivy
- graphcool
- sbt
- flow
- bithound
- appveyor
- fusebox
- editorconfig
- watchman
- aurelia
- rollup
- hack
- apollo
- nodemon
- webhint
- browserlist
- crystal
- snyk
- drone
- cuda
- dotjs
- sequelize
- gatsby
- wakatime
- circleci
- cloudfoundry
- processing
- wepy
- hcl
- san
- wallaby
- stencil
- red
- webassembly
- foxpro
- jupyter
- ballerina
- racket
- bazel
- mint
- velocity
- prisma
- abc
- istanbul
- lisp
- buildkite
- netlify
- svelte
- nest
- percy
- gitpod
- advpl_prw
- advpl_ptm
- advpl_tlpp
- advpl_include
- tilt
- capacitor
- adonis
- forth
- uml
- meson
- buck
- sml
- nrwl
- imba
- drawio
- sas
- slug
+127
View File
@@ -0,0 +1,127 @@
package main
import (
"bytes"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"testing"
)
type nodes []struct {
name string
textContent []byte
dirContent *nodes
}
func (n *nodes) create(t *testing.T, dir string) {
for _, f := range *n {
fn := filepath.Join(dir, f.name)
if f.textContent != nil {
if err := ioutil.WriteFile(fn, f.textContent, 0666); err != nil {
t.Fatal(err)
}
} else if f.dirContent != nil {
if err := os.Mkdir(fn, 0777); err != nil {
t.Log(err)
t.Fail()
continue
}
f.dirContent.create(t, fn)
}
}
}
func TestE2E(t *testing.T) {
goExec, err := exec.LookPath("go")
if err != nil {
t.Fatal(err)
}
dirEnv := filepath.Join("./testdata", "dirEnv")
os.RemoveAll(dirEnv)
// create a temp directory environment
if err := os.Mkdir(dirEnv, 0777); err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dirEnv)
// if you update the fileStruct or create any changes that may break the snapshorts present in ./testdata/logo-ls*.txt
// then you do have to update the snapshorts like: logo-ls -V > ./testdata/logo-ls-V.txt
fileStruct := nodes{
{name: "1test.go", textContent: []byte("package main\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello\")\n}")},
{name: "2test.js", textContent: []byte("consol.log('Hello')")},
{name: "test.routes.tsx", textContent: []byte("consol.log('Hello')")},
{name: "Dockerfile", textContent: []byte("FROM golang:1.15.2-buster AS base")},
{name: "abc.css", textContent: []byte("h1 {\n color : red;\n}")},
{name: "abc.sass", textContent: []byte("h1 {\n color : red;\n}")},
{name: ".abc.txt", textContent: []byte("Hello")},
{name: "3test.py", textContent: []byte("print('Hello')")},
{name: "testDir", dirContent: &nodes{
{name: "abc.txt", textContent: []byte("Hello")},
{name: "1test.go", textContent: []byte("package main\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello\")\n}")},
{name: "2test.js", textContent: []byte("consol.log('Hello')")},
}},
{name: ".privateDir", dirContent: &nodes{
{name: "abc.txt", textContent: []byte("Hello")},
{name: "1test.go", textContent: []byte("package main\nimport \"fmt\"\nfunc main() {\n fmt.Println(\"Hello\")\n}")},
{name: "2test.js", textContent: []byte("consol.log('Hello')")},
}},
{name: "Downloads", dirContent: &nodes{}},
}
fileStruct.create(t, dirEnv)
tt := []struct {
args []string
testFile string
td string
}{
{args: []string{"-1"}, testFile: "logo-ls.snap", td: "Testing normal execution"},
{args: []string{"-1a"}, testFile: "logo-ls-a.snap", td: "Testing -a (all) execution"},
{args: []string{"-1A"}, testFile: "logo-ls-A.snap", td: "Testing -A (almost all) execution"},
{args: []string{"-1i"}, testFile: "logo-ls-i.snap", td: "Testing -i (no icon) execution"},
{args: []string{"-1r"}, testFile: "logo-ls-r.snap", td: "Testing -r (reverse) execution"},
{args: []string{"-1sh"}, testFile: "logo-ls-sh.snap", td: "Testing -sh (human readable size) execution"},
{args: []string{"-1R"}, testFile: "logo-ls-R.snap", td: "Testing -R (recursive) execution"},
{args: []string{"-1Ra"}, testFile: "logo-ls-Ra.snap", td: "Testing -Ra (recursive, all) execution"},
{args: []string{"-1shRa"}, testFile: "logo-ls-shRa.snap", td: "Testing -shRa execution"},
{args: []string{"-V"}, testFile: "logo-ls-V.snap", td: "Testing -V option prints version"},
{args: []string{"-?"}, testFile: "logo-ls--help.snap", td: "Testing -? (help) prints help message"},
}
for _, test := range tt {
t.Run(test.td, func(st *testing.T) {
args := []string{"run", "."}
args = append(args, test.args...)
cmd := exec.Command(goExec, append(args, dirEnv)...)
stdout, err := cmd.StdoutPipe()
defer stdout.Close()
if err != nil {
st.Fatal(err)
}
if err := cmd.Start(); err != nil {
st.Fatal(err)
}
cmdData, err := ioutil.ReadAll(stdout)
if err != nil {
st.Fatal(err)
}
if err := cmd.Wait(); err != nil {
st.Fatal(err)
}
fileData, err := ioutil.ReadFile(filepath.Join("./testdata", test.testFile))
if err != nil {
st.Fatal(err)
}
if bytes.Compare(cmdData, fileData) != 0 {
t.Fatalf("expected output of the command:\n-----------\n%s\n=============\nbut got:\n-----------\n%s", fileData, cmdData)
}
})
}
}
+9 -2
View File
@@ -3,7 +3,14 @@ module github.com/Yash-Handa/logo-ls
go 1.15
require (
github.com/go-git/go-git/v5 v5.1.0
github.com/Microsoft/go-winio v0.4.16 // indirect
github.com/go-git/go-git/v5 v5.2.0
github.com/imdario/mergo v0.3.11 // indirect
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
github.com/mattn/go-colorable v0.1.7
github.com/pborman/getopt/v2 v2.0.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad
golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
)
+44 -6
View File
@@ -1,3 +1,7 @@
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/Microsoft/go-winio v0.4.16 h1:FtSW/jqD+l4ba5iPBj9CODVtgfYAD8w2wS923g/cFDk=
github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
@@ -18,24 +22,33 @@ github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E=
github.com/go-git/go-billy/v5 v5.0.0 h1:7NQHvd9FVid8VL4qVUMm8XifBK+2xCoZ2lSk0agRrHM=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-git-fixtures/v4 v4.0.1 h1:q+IFMfLx200Q3scvt2hN79JsEzy4AmBTp/pqnefH+Bc=
github.com/go-git/go-git-fixtures/v4 v4.0.1/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.1.0 h1:HxJn9g/E7eYvKW3Fm7Jt4ee8LXfPOm/H1cdDu8vEssk=
github.com/go-git/go-git/v5 v5.1.0/go.mod h1:ZKfuPUoY1ZqIG4QG9BDBh3G4gLM5zvPuSJAozQrZuyM=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12 h1:PbKy9zOy4aAKrJ5pibIRpVO2BXnK1Tlcg+caKI7Ox5M=
github.com/go-git/go-git-fixtures/v4 v4.0.2-0.20200613231340-f56387b50c12/go.mod h1:m+ICp2rF3jDhFgEZ/8yziagdT1C+ZpZcrJjappBCDSw=
github.com/go-git/go-git/v5 v5.2.0 h1:YPBLG/3UK1we1ohRkncLjaXWLW+HKp5QNM/jTli2JgI=
github.com/go-git/go-git/v5 v5.2.0/go.mod h1:kh02eMX+wdqqxgNMEyq8YgwlIOsDOa9homkUq1PoTMs=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg=
github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA=
github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY=
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgyYSX4TO5NpyC606/Z4SxnNYbT+WX27or6Ck=
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
@@ -44,32 +57,55 @@ github.com/pborman/getopt/v2 v2.0.0 h1:Tn8XVmhb93Wbc346Tk4P6KutfpMVp+iztUzkZrTSy
github.com/pborman/getopt/v2 v2.0.0/go.mod h1:4NtW75ny4eBw9fO1bhtNdYTlZKYX5/tBLtsOpwKIKd0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70=
github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4=
github.com/xanzy/ssh-agent v0.3.0 h1:wUMzuKtKilRgBAD1sUb8gOwwRr2FGoBVumcjoOACClI=
github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad h1:DN0cp81fZ3njFcrLCytUHRSUkqBjfTo4Tx9RJTWs0EY=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a h1:GuSPYbZzB5/dcLNCwLQLsg3obCJtX9IJhpXkvY7kzk0=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b h1:iFwSg7t5GZmB/Q5TjiEAsdoLDrdJRC1RiF2WhuV29Qw=
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527 h1:uYVVQ9WP/Ds2ROhcaGPeIdVq0RIXVLwsHlnvJ+cT1So=
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -80,3 +116,5 @@ gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRN
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+6 -1
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"os"
"strconv"
"time"
"github.com/Yash-Handa/logo-ls/internal/sysState"
@@ -220,6 +221,10 @@ func Bootstrap() {
// screen width for custom tw
w, _, e := terminal.GetSize(int(os.Stdout.Fd()))
if e == nil {
if w == 0 {
// for systems that dont support TIOCGWINSZ.
w, _ = strconv.Atoi(os.Getenv("COLUMNS"))
}
sysState.TerminalWidth(w)
}
}
@@ -253,7 +258,7 @@ func Bootstrap() {
// if f_V is provided version will be printed and exit(0)
if *f_V {
fmt.Printf("logo-ls %s\nCopyright (c) 2020 Yash Handa\nLicense MIT <https://opensource.org/licenses/MIT>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n", "v1.3.6")
fmt.Printf("logo-ls %s\nCopyright (c) 2020 Yash Handa\nLicense MIT <https://opensource.org/licenses/MIT>.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n", "v1.3.7")
fmt.Println("\nWritten by Yash Handa")
os.Exit(sysState.GetExitCode())
}
+3 -3
View File
@@ -174,11 +174,11 @@ func (w *CTW) printCell(buf *bytes.Buffer, i int, cs [4]int) {
fmt.Fprintf(buf, "%-*s%s", cs[0]-1, w.d[i][0], brailEmpty)
}
if w.showIcon {
fmt.Fprintf(buf, "%s%1s%s%s", w.ic[i], w.d[i][1], white, brailEmpty)
fmt.Fprintf(buf, "%s%1s%s%s", w.ic[i], w.d[i][1], noColor, brailEmpty)
}
fmt.Fprintf(buf, "%s%-*s%s", getGitColor(w.d[i][3]), cs[2], w.d[i][2], white)
fmt.Fprintf(buf, "%s%-*s%s", getGitColor(w.d[i][3]), cs[2], w.d[i][2], noColor)
if cs[3] > 0 {
fmt.Fprintf(buf, "%s%s%1s%s", brailEmpty, getGitColor(w.d[i][3]), w.d[i][3], white)
fmt.Fprintf(buf, "%s%s%1s%s", brailEmpty, getGitColor(w.d[i][3]), w.d[i][3], noColor)
}
}
+2 -2
View File
@@ -64,10 +64,10 @@ func (l *LongCTW) Flush(buf *bytes.Buffer) {
}
if j == l.cols-2 {
fmt.Fprintf(buf, "%s%*s%s", l.ic[i], l.c[j], c, white)
fmt.Fprintf(buf, "%s%*s%s", l.ic[i], l.c[j], c, noColor)
} else if j >= l.cols-1 && (1<<l.cols)&skipCol == 0 {
color := getGitColor(r[l.cols])
fmt.Fprintf(buf, "%s%-*s%s", color, l.c[j], c, white)
fmt.Fprintf(buf, "%s%-*s%s", color, l.c[j], c, noColor)
} else {
fmt.Fprintf(buf, "%-*s", l.c[j], c)
}
+3 -3
View File
@@ -3,7 +3,7 @@ package ctw
import "strings"
var (
white string = "\033[38;2;255;255;255m"
noColor string = "\033[0m"
green string = "\033[38;2;055;183;021m"
brown string = "\033[38;2;192;154;107m"
brailEmpty string = "\u2800"
@@ -11,7 +11,7 @@ var (
func DisplayColor(b bool) {
if b == false {
white = ""
noColor = ""
green = ""
brown = ""
}
@@ -26,7 +26,7 @@ func DisplayBrailEmpty(b bool) {
func getGitColor(gitStatus string) string {
switch strings.Trim(gitStatus, " ") {
case "":
return white
return noColor
case "U":
return green
default:
+13 -6
View File
@@ -8,6 +8,7 @@ import (
"log"
"os"
"path/filepath"
"runtime"
"sort"
"strings"
"time"
@@ -16,10 +17,11 @@ import (
"github.com/Yash-Handa/logo-ls/internal/api"
"github.com/Yash-Handa/logo-ls/internal/ctw"
"github.com/Yash-Handa/logo-ls/internal/sysState"
"github.com/mattn/go-colorable"
)
// create the open dir icon
var OpenDirIcon = assets.Icon_Def["diropen"].GetColor(1) + assets.Icon_Def["diropen"].GetGlyph() + "\033[38;2;255;255;255m" + " "
var OpenDirIcon = assets.Icon_Def["diropen"].GetColor(1) + assets.Icon_Def["diropen"].GetGlyph() + "\033[0m" + " "
type file struct {
name, ext, indicator string
@@ -77,7 +79,7 @@ func New(d *os.File) (*dir, error) {
t.info.owner, t.info.group = getOwnerGroupInfo(ds)
}
if api.FlagVector&api.Flag_s > 0 {
t.info.blocks = getFileBlocks(ds)
dirBlocks(t.info, ds)
}
if api.FlagVector&api.Flag_i == 0 {
t.info.icon = assets.Icon_Def["diropen"].GetGlyph()
@@ -112,7 +114,7 @@ func New(d *os.File) (*dir, error) {
f.owner, f.group = getOwnerGroupInfo(v)
}
if api.FlagVector&api.Flag_s > 0 {
f.blocks = getFileBlocks(v)
dirBlocks(f, v)
}
if api.FlagVector&api.Flag_i == 0 {
@@ -160,7 +162,7 @@ func New(d *os.File) (*dir, error) {
t.parent.owner, t.parent.group = getOwnerGroupInfo(pds)
}
if api.FlagVector&api.Flag_s > 0 {
t.parent.blocks = getFileBlocks(pds)
dirBlocks(t.parent, pds)
}
if api.FlagVector&api.Flag_i == 0 {
t.parent.icon = assets.Icon_Def["diropen"].GetGlyph()
@@ -195,7 +197,7 @@ func New_ArgFiles(files []os.FileInfo) *dir {
f.owner, f.group = getOwnerGroupInfo(v)
}
if api.FlagVector&api.Flag_s > 0 {
f.blocks = getFileBlocks(v)
dirBlocks(f, v)
}
if api.FlagVector&api.Flag_i == 0 {
f.icon, f.iconColor = getIcon(f.name, f.ext, f.indicator)
@@ -216,13 +218,18 @@ func New_Recussion(d *os.File) {
sysState.ExitCode(sysState.Code_Minor)
}
// print the info of the files of the directory
io.Copy(os.Stdout, dd.Print())
var out io.Writer = os.Stdout
if runtime.GOOS == "windows" {
out = colorable.NewColorableStdout()
}
io.Copy(out, dd.Print())
if len(dd.dirs) == 0 {
return
}
// at this point dd.print has sorted the children files
// but not using it instead printing children in directory order
temp := make([]string, len(dd.dirs))
sort.Strings(dd.dirs)
for i, v := range dd.dirs {
temp[i] = filepath.Join(d.Name(), v)
}
+63
View File
@@ -0,0 +1,63 @@
// this file contain dir type definition
// +build !windows
package dir
import (
"os"
"os/user"
"strconv"
"syscall"
"github.com/Yash-Handa/logo-ls/internal/api"
)
func dirBlocks(info *file, fi os.FileInfo) {
if s, ok := fi.Sys().(*syscall.Stat_t); ok {
info.blocks = s.Blocks
}
}
func getOwnerGroupInfo(fi os.FileInfo) (o string, g string) {
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
if api.FlagVector&(api.Flag_l|api.Flag_o) > 0 {
UID := strconv.Itoa(int(stat.Uid))
if n, ok := userMap[UID]; ok {
o = n
} else {
u, err := user.LookupId(UID)
if err != nil {
o = ""
} else {
o = u.Name
userMap[UID] = u.Name
}
}
}
if api.FlagVector&api.Flag_G == 0 && api.FlagVector&(api.Flag_l|api.Flag_g) > 0 {
GID := strconv.Itoa(int(stat.Gid))
if n, ok := grpMap[GID]; ok {
g = n
} else {
grp, err := user.LookupGroupId(GID)
if err != nil {
g = ""
} else {
g = grp.Name
grpMap[GID] = grp.Name
}
}
}
}
return
}
func getFileBlocks(fi os.FileInfo) int64 {
if s, ok := fi.Sys().(*syscall.Stat_t); ok {
return s.Blocks
}
return 0
}
+16
View File
@@ -0,0 +1,16 @@
// this file contain dir type definition
// +build windows
package dir
import (
"os"
)
func dirBlocks(info *file, fi os.FileInfo) {
}
func getOwnerGroupInfo(fi os.FileInfo) (o string, g string) {
return
}
+24 -68
View File
@@ -3,10 +3,7 @@ package dir
import (
"fmt"
"os"
"os/user"
"strconv"
"strings"
"syscall"
"github.com/Yash-Handa/logo-ls/assets"
"github.com/Yash-Handa/logo-ls/internal/api"
@@ -79,49 +76,6 @@ func lessFuncGenerator(d *dir) {
var grpMap = make(map[string]string)
var userMap = make(map[string]string)
func getOwnerGroupInfo(fi os.FileInfo) (o string, g string) {
if stat, ok := fi.Sys().(*syscall.Stat_t); ok {
if api.FlagVector&(api.Flag_l|api.Flag_o) > 0 {
UID := strconv.Itoa(int(stat.Uid))
if n, ok := userMap[UID]; ok {
o = n
} else {
u, err := user.LookupId(UID)
if err != nil {
o = ""
} else {
o = u.Name
userMap[UID] = u.Name
}
}
}
if api.FlagVector&api.Flag_G == 0 && api.FlagVector&(api.Flag_l|api.Flag_g) > 0 {
GID := strconv.Itoa(int(stat.Gid))
if n, ok := grpMap[GID]; ok {
g = n
} else {
grp, err := user.LookupGroupId(GID)
if err != nil {
g = ""
} else {
g = grp.Name
grpMap[GID] = grp.Name
}
}
}
}
return
}
func getFileBlocks(fi os.FileInfo) int64 {
if s, ok := fi.Sys().(*syscall.Stat_t); ok {
return s.Blocks
}
return 0
}
// get indicator of the file
func getIndicator(modebit os.FileMode) (i string) {
switch {
@@ -160,9 +114,9 @@ func getSizeInFormate(b int64) string {
func getIcon(name, ext, indicator string) (icon, color string) {
var i *assets.Icon_Info
var ok bool
switch indicator {
case "/":
// send dir related stuff
i, ok = assets.Icon_Dir[strings.ToLower(name+ext)]
if ok {
break
@@ -172,33 +126,26 @@ func getIcon(name, ext, indicator string) (icon, color string) {
break
}
i = assets.Icon_Def["dir"]
case "*":
// send executable related stuff
i, ok = assets.Icon_FileName[strings.ToLower(name+ext)]
if ok {
i.MakeExe()
break
}
i, ok = assets.Icon_Ext[strings.ToLower(strings.TrimPrefix(ext, "."))]
if ok {
i.MakeExe()
break
}
if len(name) == 0 || '.' == name[0] {
i = assets.Icon_Def["hiddenfile"]
i.MakeExe()
break
}
i = assets.Icon_Def["exe"]
default:
// send file related stuff
i, ok = assets.Icon_FileName[strings.ToLower(name+ext)]
if ok {
break
}
// a special admiration for goLang
if ext == ".go" && strings.HasSuffix(name, "_test") {
i = assets.Icon_Set["go-test"]
break
}
t := strings.Split(name, ".")
if len(t) > 1 && t[0] != "" {
i, ok = assets.Icon_SubExt[strings.ToLower(t[len(t)-1]+ext)]
if ok {
break
}
}
i, ok = assets.Icon_Ext[strings.ToLower(strings.TrimPrefix(ext, "."))]
if ok {
break
@@ -210,5 +157,14 @@ func getIcon(name, ext, indicator string) (icon, color string) {
}
i = assets.Icon_Def["file"]
}
// change icon color if the file is executable
if indicator == "*" {
if i.GetGlyph() == "\uf723" {
i = assets.Icon_Def["exe"]
}
i.MakeExe()
}
return i.GetGlyph(), i.GetColor(1)
}
+65 -15
View File
@@ -1,30 +1,81 @@
package dir
import (
"os/exec"
"path/filepath"
"strings"
"github.com/go-git/go-git/v5"
)
// gitStatus returns the status of modified files in the worktree. It will attempt to execute 'git status'
// and will fall back to git.Worktree.Status() if that fails.
func gitStatus(wt *git.Worktree) (git.Status, error) {
c := exec.Command("git", "status", "--porcelain", "-z")
c.Dir = wt.Filesystem.Root()
output, err := c.Output()
if err != nil {
stat, err := wt.Status()
return stat, err
}
lines := strings.Split(string(output), "\000")
stat := make(map[string]*git.FileStatus, len(lines))
for _, line := range lines {
if len(line) == 0 {
continue
}
// For copy/rename the output looks like
// R destination\000source
// Which means we can split on space and ignore anything with only one result
parts := strings.SplitN(strings.TrimLeft(line, " "), " ", 2)
if len(parts) == 2 {
stat[strings.Trim(parts[1], " ")] = &git.FileStatus{
Worktree: git.StatusCode([]byte(parts[0])[0]),
}
}
}
return stat, err
}
var (
gitRepo git.Status
gitRoot string
gitError error
gitRepoComputedAlready = false
)
func getRepoStatus(path string) (git.Status, string, error) {
op := git.PlainOpenOptions{DetectDotGit: true}
r, err := git.PlainOpenWithOptions(path, &op)
if err != nil {
return nil, "", err
}
if !gitRepoComputedAlready {
gitRepoComputedAlready = true
op := git.PlainOpenOptions{DetectDotGit: true}
r, err := git.PlainOpenWithOptions(path, &op)
if err != nil {
gitError = err
return nil, "", err
}
w, err := r.Worktree()
if err != nil {
return nil, "", err
}
w, err := r.Worktree()
if err != nil {
gitError = err
return nil, "", err
}
ws, err := w.Status()
if err != nil {
return nil, "", err
}
ws, err := gitStatus(w)
if err != nil {
gitError = err
return nil, "", err
}
return ws, w.Filesystem.Root(), nil
gitRepo, gitRoot, gitError = ws, w.Filesystem.Root(), nil
}
return gitRepo, gitRoot, gitError
}
// use this function when multiple dirs are given as input, to recalculate the git tree for each
func GitRepoCompute() {
gitRepoComputedAlready = false
}
func getFilesGitStatus(p string) map[string]string {
@@ -38,7 +89,6 @@ func getFilesGitStatus(p string) map[string]string {
}
t := make(map[string]string)
for i, v := range gitRepo {
i = gitFilePath(gitRoot+"/"+i, pAbs+"/")
if i == "" {
BIN
View File
Binary file not shown.
+15 -2
View File
@@ -5,6 +5,7 @@ import (
"io"
"log"
"os"
"runtime"
"sort"
"github.com/Yash-Handa/logo-ls/assets"
@@ -12,6 +13,7 @@ import (
"github.com/Yash-Handa/logo-ls/internal/ctw"
"github.com/Yash-Handa/logo-ls/internal/dir"
"github.com/Yash-Handa/logo-ls/internal/sysState"
"github.com/mattn/go-colorable"
)
func main() {
@@ -65,9 +67,14 @@ func main() {
}
}
var out io.Writer = os.Stdout
if runtime.GOOS == "windows" {
out = colorable.NewColorableStdout()
}
// process and display all files
if len(args.files) > 0 {
io.Copy(os.Stdout, dir.New_ArgFiles(args.files).Print())
io.Copy(out, dir.New_ArgFiles(args.files).Print())
if len(args.dirs) > 0 {
fmt.Println()
}
@@ -81,6 +88,9 @@ func main() {
fmt.Println()
}
fmt.Printf("%s:\n", dir.OpenDirIcon+v.Name())
if api.FlagVector&api.Flag_D > 0 {
dir.GitRepoCompute()
}
dir.New_Recussion(v)
}
} else {
@@ -89,6 +99,9 @@ func main() {
if pName {
fmt.Printf("%s:\n", dir.OpenDirIcon+v.Name())
}
if api.FlagVector&api.Flag_D > 0 {
dir.GitRepoCompute()
}
d, err := dir.New(v)
v.Close()
if err != nil {
@@ -96,7 +109,7 @@ func main() {
sysState.ExitCode(sysState.Code_Serious)
}
// print the info of the files of the directory
io.Copy(os.Stdout, d.Print())
io.Copy(out, d.Print())
if i < len(args.dirs)-1 {
fmt.Println()
}
+50
View File
@@ -0,0 +1,50 @@
List information about the FILEs with ICONS and GIT STATUS (the current dir
by default). Sort entries alphabetically if none of -tvSUX is specified.
Usage: logo-ls [-1?aAcdDgGhiloRrSstUvVX] [-T value] [files ...]
-1 list one file per line.
-?, --help display this help and exit
-a, --all do not ignore entries starting with .
-A, --almost-all do not list implied . and ..
-c, --disable-color
don't color icons, filenames and git status (use this to
print to a file)
-d, --directory list directories themselves, not their contents
-D, --git-status print git status of files
-g like -l, but do not list owner
-G, --no-group in a long listing, don't print group names
-h, --human-readable
with -l and -s, print sizes like 1K 234M 2G etc.
-i, --disable-icon
don't print icons of the files
-l use a long listing format
-o like -l, but do not list group information
-R, --recursive list subdirectories recursively
-r, --reverse reverse order while sorting
-S sort by file size, largest first
-s, --size print the allocated size of each file, in blocks
-t sort by modification time, newest first
-T, --time-style=value
time/date format with -l; see time-style below [Stamp]
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-V, --version output version information and exit
-X sort alphabetically by entry extension
Possible value for --time-style (-T)
ANSIC "Mon Jan _2 15:04:05 2006"
UnixDate "Mon Jan _2 15:04:05 MST 2006"
RubyDate "Mon Jan 02 15:04:05 -0700 2006"
RFC822 "02 Jan 06 15:04 MST"
RFC822Z "02 Jan 06 15:04 -0700"
RFC850 "Monday, 02-Jan-06 15:04:05 MST"
RFC1123 "Mon, 02 Jan 2006 15:04:05 MST"
RFC1123Z "Mon, 02 Jan 2006 15:04:05 -0700"
RFC3339 "2006-01-02T15:04:05Z07:00"
Kitchen "3:04PM"
Stamp "Mon Jan _2 15:04:05" [Default]
StampMilli "Jan _2 15:04:05.000"
Exit status:
0 if OK,
1 if minor problems (e.g., cannot access subdirectory),
2 if serious trouble (e.g., cannot access command-line argument).
+11
View File
@@ -0,0 +1,11 @@
ﳑ1test.go
2test.js
3test.py
abc.css
abc.sass
.abc.txt
Dockerfile
Downloads/
.privateDir/
נּtest.routes.tsx
testDir/
+17
View File
@@ -0,0 +1,17 @@
ﱮ testdata/dirEnv:
ﳑ1test.go
2test.js
3test.py
abc.css
abc.sass
Dockerfile
Downloads/
נּtest.routes.tsx
testDir/
ﱮ testdata/dirEnv/Downloads:
ﱮ testdata/dirEnv/testDir:
ﳑ1test.go
2test.js
abc.txt
+32
View File
@@ -0,0 +1,32 @@
ﱮ testdata/dirEnv:
ﱮ.
ﱮ..
ﳑ1test.go
2test.js
3test.py
abc.css
abc.sass
.abc.txt
Dockerfile
Downloads/
.privateDir/
נּtest.routes.tsx
testDir/
ﱮ testdata/dirEnv/.privateDir:
ﱮ.
ﱮ..
ﳑ1test.go
2test.js
abc.txt
ﱮ testdata/dirEnv/Downloads:
ﱮ.
ﱮ..
ﱮ testdata/dirEnv/testDir:
ﱮ.
ﱮ..
ﳑ1test.go
2test.js
abc.txt
+7
View File
@@ -0,0 +1,7 @@
logo-ls v1.3.7
Copyright (c) 2020 Yash Handa
License MIT <https://opensource.org/licenses/MIT>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Yash Handa
+13
View File
@@ -0,0 +1,13 @@
ﱮ.
ﱮ..
ﳑ1test.go
2test.js
3test.py
abc.css
abc.sass
.abc.txt
Dockerfile
Downloads/
.privateDir/
נּtest.routes.tsx
testDir/
+9
View File
@@ -0,0 +1,9 @@
1test.go
2test.js
3test.py
abc.css
abc.sass
Dockerfile
Downloads/
test.routes.tsx
testDir/
+9
View File
@@ -0,0 +1,9 @@
testDir/
נּtest.routes.tsx
Downloads/
Dockerfile
abc.sass
abc.css
3test.py
2test.js
ﳑ1test.go
+9
View File
@@ -0,0 +1,9 @@
4.0Kﳑ1test.go
4.0K2test.js
4.0K3test.py
4.0Kabc.css
4.0Kabc.sass
4.0KDockerfile
4.0KDownloads/
4.0Kנּtest.routes.tsx
4.0KtestDir/
+32
View File
@@ -0,0 +1,32 @@
ﱮ testdata/dirEnv:
4.0Kﱮ.
4.0Kﱮ..
4.0Kﳑ1test.go
4.0K2test.js
4.0K3test.py
4.0Kabc.css
4.0Kabc.sass
4.0K.abc.txt
4.0KDockerfile
4.0KDownloads/
4.0K.privateDir/
4.0Kנּtest.routes.tsx
4.0KtestDir/
ﱮ testdata/dirEnv/.privateDir:
4.0Kﱮ.
4.0Kﱮ..
4.0Kﳑ1test.go
4.0K2test.js
4.0Kabc.txt
ﱮ testdata/dirEnv/Downloads:
4.0Kﱮ.
4.0Kﱮ..
ﱮ testdata/dirEnv/testDir:
4.0Kﱮ.
4.0Kﱮ..
4.0Kﳑ1test.go
4.0K2test.js
4.0Kabc.txt
+9
View File
@@ -0,0 +1,9 @@
ﳑ1test.go
2test.js
3test.py
abc.css
abc.sass
Dockerfile
Downloads/
נּtest.routes.tsx
testDir/