g

command module
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2024 License: MIT Imports: 11 Imported by: 0

README

g

logo

一个强大的 ls 工具

linux macos windows AUR version

View this document in English

g 是一个 ls 替代品,拥有下面一些功能:

  1. 显示带有类型特定图标和颜色的条目,并且易于更改
  2. 有丰富的输出格式 ( grid/across/byline/zero/comma/table/html/json/markdown/tree )
  3. 用户友好的选项
  4. 支持显示 git status
  5. 丰富且可自定义的排序选项
  6. 跨平台 ( Linux/Windows/MacOS )
  7. 支持使用fzf 算法,像 zoxide 一样模糊匹配路径

截图

image image image image

安装

源码安装

要求 go version >= 1.21

go install -ldflags="-s -w"  github.com/Equationzhao/g@latest

或者 clone 这个仓库 (nightly build)

git clone github.com/Equationzhao/g
cd g
go build -ldflags="-s -w" # use -s -w to shrink size
# then add the executable file to your `PATH`
通过包管理器

archlinux 用户可以通过 AUR 安装 g

yay -S g-ls

homebrew:

brew tap equationzhao/core git@github.com:Equationzhao/homebrew-g.git
brew install g-ls

windows scoop:

scoop install https://raw.githubusercontent.com/Equationzhao/g/master/scoop/g.json
# upgrade
scoop uninstall g # uninstall first
scoop install https://raw.githubusercontent.com/Equationzhao/g/master/scoop/g.json
# error msg like this can be ignored
# Move-Item: 
# Line |
#    2 |  mv g-amd64.exe g.exe
#      |  ~~~~~~~~~~~~~~~~~~~~
# Move-Item: 
# Line |
#    3 |  mv g-amd64.shim g.shim
#      |  ~~~~~~~~~~~~~~~~~~~~~~
二进制文件
deb

release 页下载对应deb文件后安装

sudo dpkg -i g_$version_$arch.deb
tar.gz/zip

release page 下载对应平台的文件, 解压 gzip 并将可执行文件添加到 PATH

推荐使用的终端

macOS:

Windows:

cross-platform:

用法

g path(s)

显示图标

g -icons

显示修改(默认)时间

g -time    

显示 访问/创建/修改 时间

g -time -time-type=access
g -time -ac/cr/mod

显示文件权限

g -permission 
g -octal-perm # show octal permission like 0777

显示用户/群组

g -owner 
g -group 

显示文件大小

g -size 
g -size -recursive-size # show size of dir recursively

显示所有文件,包括隐藏文件

g -sh 
g -show-hidden
g -a  

只显示目录

g -dir 

按行显示

g -1           
g -oneline     
g -single-column 

显示有指定拓展名的文件

g -ext=<target ext(s)> 
# eg:
# g -ext=go,md

递归显示目录

g -R     
g -recurse 

限制在 树/递归 模式下的 递归深度 (默认: 无限制)

g -R -depth=<level> 

模糊搜索

g -f   
g -fuzzy 
# eg: g -f in
# /mnt/e/Project/gverything/index
# pathindex.go

禁用索引更新

g -di            
g -no-update   
g -disable-index 

禁用颜色

g -no-color  
g -colorless 

设置颜色

g -color=always 
g -color=auto    # default
g -color=never   
g -color=16/basic       # 16-color
g -color=256/8bit       # 256-color
g -color=16m/24bit/true-color   # 24-bit

显示校验和 (md5,sha1,sha224,sha256,sha384,sha512,crc32)

g -cs -ca=sha256 

显示 git status

g -git     
g -git-status

表格式输出

g -tb

树状输出

g -tree

以 markdown 格式输出, 并用 glow 渲染 ( 不支持颜色 )

g -md | glow 

image

...

Shell 脚本

生成 shell 脚本

g -init bash/zsh/fish/pwsh
bash
# add the following command to .bashrc
eval "$(g --init bash)"
# then `source ~/.bashrc`
zsh
# add the following command to .zshrc
eval "$(g --init zsh)"
# then `source ~/.zshrc`
fish
#  add to fish config:
g --init fish | source
#  then `source ~/.config/fish/config.fish`
powershell
# add the following line to your profile
Invoke-Expression (& { (g --init powershell | Out-String) })

使用 echo $profile命令查找配置文件路径

nushell
# add the following to your $nu.env-path
^g --init nushell | save -f ~/.g.nu
# then add the following to your $nu.config-path
source ~/.g.nu

# if you want to replace nushell's g command with g
# add the following definition and alias to your $nu.config-path
#
# def nug [arg?] {
#     if ($arg == null) {
#         g $arg
#     } else {
#         g
#     }
# }
# alias g = ^g

更多选项

g.md 或查看 主页

自定义主题

theme

TODO

  • Version sort
  • Git sort
  • Print security context
  • $OLDPWD
  • Color Support for html/markdown
  • Support Scoop

以下是 eza 的新功能,后续计划支持

  • --git-repos: list each directory’s Git status, if tracked
  • --git-repos-no-status: list whether a directory is a Git repository, but not its status (faster)

CONTRIBUTING

查看 CONTRIBUTING

created by bing

其他选择

本项目受到以下项目的启发,你也许想试试

Star History

Star History Chart

查看帖子

Repography logo / Recent activity Time period

Timeline graph Pull request status graph Trending topics Top contributors

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL