-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathg_streamlit.py
491 lines (398 loc) Β· 15 KB
/
g_streamlit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
import pandas as pd
import streamlit as st
st.set_page_config(
page_title="g - Advanced ls Command Alternative",
page_icon="π",
# layout="wide",
initial_sidebar_state="expanded"
)
st.markdown("""
<style>
/* Base styles */
body {
font-family: 'Inter', sans-serif;
line-height: 1.6;
}
/* Title and headers */
.main-title {
font-size: 3.5rem;
font-weight: 800;
color: #1E88E5;
margin-bottom: 1.5rem;
text-align: center;
text-shadow: 0px 2px 3px rgba(0,0,0,0.1);
}
.section-header {
font-size: 2.2rem;
font-weight: 700;
color: #0D47A1;
border-bottom: 3px solid #90CAF9;
padding-bottom: 0.7rem;
margin-top: 2.5rem;
margin-bottom: 1.5rem;
}
/* Cards and containers */
.feature-title {
font-weight: 700;
font-size: 1.35rem;
color: #1565C0;
margin-bottom: 12px;
}
/* Code elements */
.code-header {
font-weight: 600;
margin-top: 1.2rem;
margin-bottom: 0.5rem;
font-size: 1.1rem;
color: #333;
}
.stCodeBlock {
border-radius: 8px !important;
margin-bottom: 1.5rem !important;
}
/* Images */
.screenshot {
border-radius: 12px;
box-shadow: 0 8px 16px rgba(0,0,0,0.15);
margin-bottom: 2rem;
}
/* Badges */
.badge-container {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 25px;
padding: 10px;
background: rgba(240,240,240,0.5);
border-radius: 8px;
}
.badge-container img {
height: 28px;
transition: transform 0.15s;
}
.badge-container img:hover {
transform: scale(1.05);
}
/* Tables */
.dataframe {
font-size: 0.95rem !important;
}
.dataframe th {
background-color: #E3F2FD !important;
color: #0D47A1 !important;
}
/* Custom tabs styling */
.stTabs [data-baseweb="tab-list"] {
gap: 10px;
}
.stTabs [data-baseweb="tab"] {
border-radius: 4px 4px 0 0;
padding: 10px 16px;
font-weight: 500;
}
/* Sidebar improvements */
[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] a {
color: #1E88E5;
text-decoration: none;
transition: color 0.2s;
}
[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] a:hover {
color: #0D47A1;
text-decoration: underline;
}
/* Footer */
.footer {
margin-top: 3rem;
text-align: center;
padding: 1.5rem;
background-color: #f5f7f9;
border-radius: 8px;
color: #555;
}
/* Expander refinements */
.streamlit-expanderHeader {
font-weight: 600;
font-size: 1.1rem;
color: #1565C0;
}
/* Info block */
.info-block {
background-color: #E3F2FD;
padding: 15px;
border-radius: 8px;
border-left: 5px solid #1E88E5;
margin-bottom: 20px;
}
</style>
""", unsafe_allow_html=True)
with st.sidebar:
st.title("π Navigation")
st.markdown("---")
st.markdown("### π Content")
st.markdown("- [Key Features](#key-features)")
st.markdown("- [Screenshots](#screenshots)")
st.markdown("- [Usage](#usage)")
st.markdown("- [Installation Guide](#installation-guide)")
st.markdown("- [Shell Integration](#shell-integration)")
st.markdown("- [Project Comparison](#project-comparison)")
st.markdown("---")
st.markdown("### π Quick Links")
st.markdown("- [GitHub Repository](https://github.com/Equationzhao/g)")
st.markdown("- [Report Issues](https://github.com/Equationzhao/g/issues)")
st.markdown("- [Theme Documentation](https://github.com/Equationzhao/g/blob/master/docs/Theme.md)")
st.markdown("- [Manual](https://github.com/Equationzhao/g/blob/master/docs/man.md)")
st.markdown("---")
st.caption("G - Version 0.30.0")
st.markdown('<div class="main-title">π g </div>', unsafe_allow_html=True)
st.markdown('<div class="badge-container">'
'<img src="https://img.shields.io/github/stars/Equationzhao/g" alt="Stars">'
'<img src="https://img.shields.io/github/forks/Equationzhao/g" alt="Forks">'
'<img src="https://img.shields.io/github/issues/Equationzhao/g" alt="Issues">'
'<img src="https://img.shields.io/github/license/Equationzhao/g" alt="License">'
'</div>', unsafe_allow_html=True)
st.markdown("""
**g** is a feature-rich, customizable, and cross-platform `ls` alternative. It provides enhanced visuals with type-specific icons, various layout options, and Git status integration.
""")
st.markdown('<div class="section-header" id="key-features">Key Features</div>', unsafe_allow_html=True)
col1, col2 = st.columns(2)
with col1:
with st.container():
st.markdown('<div class="feature-title">π¨ Customizable Display</div>', unsafe_allow_html=True)
st.markdown("Icons and colors specific to file types, easy to customize")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown("") # Spacing
with st.container():
st.markdown('<div class="feature-title">π Multiple Layouts</div>', unsafe_allow_html=True)
st.markdown("Choose from grid, across, byline, zero, comma, table, json, markdown, and tree layouts")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown("") # Spacing
with st.container():
st.markdown('<div class="feature-title">π Git Integration</div>', unsafe_allow_html=True)
st.markdown("View file git-status/repo-status/repo-branch directly in your listings")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
with col2:
with st.container():
st.markdown('<div class="feature-title">π Advanced Sorting</div>', unsafe_allow_html=True)
st.markdown("Highly customizable sorting options like version-sort")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown("") # Spacing
with st.container():
st.markdown('<div class="feature-title">π» Cross-Platform</div>', unsafe_allow_html=True)
st.markdown("Works seamlessly on Linux, Windows, and MacOS")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown("") # Spacing
with st.container():
st.markdown('<div class="feature-title">π Fuzzy Path Matching</div>', unsafe_allow_html=True)
st.markdown("zoxide and fzf like fuzzy path matching")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('<div class="section-header" id="screenshots">Screenshots</div>', unsafe_allow_html=True)
st.markdown('<div class="screenshot-container">', unsafe_allow_html=True)
st.image("https://raw.githubusercontent.com/Equationzhao/g/master/asset/screenshot_3.png",
caption="g command interface with icons and features visible",
use_column_width=True,
output_format="PNG")
st.markdown('</div>', unsafe_allow_html=True)
st.markdown('<div class="section-header" id="usage">Usage</div>', unsafe_allow_html=True)
st.markdown('<div class="code-header">Basic usage:</div>', unsafe_allow_html=True)
st.code("g path(s)", language="bash")
st.markdown('<div class="code-header">Display icons and long format:</div>', unsafe_allow_html=True)
st.code("g --icon --long path(s)", language="bash")
st.markdown('<div class="code-header">Tree layout:</div>', unsafe_allow_html=True)
st.code("g --tree --long path(s)", language="bash")
more_options = st.expander("View more options")
with more_options:
st.markdown("""
### Layout Options
- `--grid`: Grid layout (default)
- `--tree`: Tree layout
- `--across`: Across layout
- `--oneline`: One line per entry
- `--table`: Table layout
- `--json`: JSON output
- `--markdown`: Markdown table
### Display Options
- `--icon`: Show file type icons
- `--long`, `-l`: Long format with details
- `--all`, `-a`: Show hidden files
- `--git`: Show git status
- `--mime`: Show MIME types
- `--hyperlink`: Enable file hyperlinks
For all options, see the [manual](https://github.com/Equationzhao/g/blob/master/docs/man.md)
""")
theme = st.expander("Custom Themes", expanded=False)
with theme:
st.markdown("""
g supports rich theme customization.
For detailed information, see the [Theme Documentation](https://github.com/Equationzhao/g/blob/master/docs/Theme.md).
Basic usage:
```bash
g --theme mytheme.json # Use custom theme
```
""")
st.markdown('<div class="section-header" id="installation-guide">Installation Guide</div>', unsafe_allow_html=True)
install_tabs = st.tabs(["π¦ Package Managers", "β¬οΈ Pre-built Binaries", "π οΈ Build from Source"])
with install_tabs[0]:
col1, col2 = st.columns(2)
with col1:
st.subheader("Arch Linux")
st.code("yay -S g-ls", language="bash")
st.subheader("Homebrew")
st.code("brew install g-ls", language="bash")
st.subheader("MacPort")
st.code("sudo port install g-ls", language="bash")
with col2:
st.subheader("Windows (Scoop)")
st.code("scoop install https://raw.githubusercontent.com/Equationzhao/g/master/scoop/g.json", language="powershell")
st.subheader("WinGet")
st.info("In development, see [#119](https://github.com/Equationzhao/g/issues/119)")
with install_tabs[1]:
col1, col2 = st.columns(2)
with col1:
st.subheader("Install Script")
st.code('bash -c "$(curl -fsSLk https://raw.githubusercontent.com/Equationzhao/g/master/script/install.sh)"', language="bash")
st.subheader("Uninstall")
st.code('curl -fsSLk https://raw.githubusercontent.com/Equationzhao/g/master/script/install.sh | bash /dev/stdin -r', language="bash")
with col2:
st.subheader("Download Packages")
st.markdown("""
1. Download from [GitHub releases page](https://github.com/Equationzhao/g/releases)
2. Extract and add the executable to your PATH
#### Debian/Ubuntu
```bash
sudo dpkg -i g_$version_$arch.deb
```
""")
with install_tabs[2]:
st.markdown("""
### Requirements
- Go version >= 1.24
### Install Latest Version
```bash
go install -ldflags="-s -w" github.com/Equationzhao/g@latest
```
### Build from Source
```bash
git clone github.com/Equationzhao/g
cd g
go build -ldflags="-s -w"
# then add the executable file to your PATH
```
""")
st.markdown("### Recommended Terminals")
term_cols = st.columns(3)
with term_cols[0]:
st.markdown("#### macOS")
st.markdown("- [Iterm2](https://iterm2.com/)")
st.markdown("- [Warp](https://www.warp.dev)")
with term_cols[1]:
st.markdown("#### Windows")
st.markdown("- [Windows Terminal](https://github.com/microsoft/terminal)")
with term_cols[2]:
st.markdown("#### Cross-platform")
st.markdown("- [Hyper](https://hyper.is/)")
st.markdown("- [WezTerm](https://wezfurlong.org/wezterm/)")
st.markdown('<div class="section-header" id="shell-integration">Shell Integration</div>', unsafe_allow_html=True)
shell_tabs = st.tabs(["π Command Completion", "π Shell Aliases"])
with shell_tabs[0]:
st.markdown('<div class="info-block">', unsafe_allow_html=True)
st.info("If you install `g` through brew or the install script, the completion is usually installed already.")
st.markdown('</div>', unsafe_allow_html=True)
completion_tabs = st.tabs(["zsh", "bash", "fish"])
with completion_tabs[0]:
st.code("""
# 1. Download completion script
wget https://raw.githubusercontent.com/Equationzhao/g/master/completions/zsh/_g
# 2. Install to completion directory
mv _g ~/.zsh/completions # or any directory in your $FPATH
# 3. Make sure these commands are in your .zshrc
autoload -Uz compinit
compinit
""", language="bash")
with completion_tabs[1]:
st.code("""
# 1. Download completion script
wget https://raw.githubusercontent.com/Equationzhao/g/master/completions/bash/g-completion.bash
# 2. Add to .bashrc
echo "source /path/to/g-completion.bash" >> ~/.bashrc
# 3. Reload configuration
source ~/.bashrc
""", language="bash")
with completion_tabs[2]:
st.code("""
# 1. Download completion script
wget https://raw.githubusercontent.com/Equationzhao/g/master/completions/fish/g.fish
# 2. Install to completion directory
mv g.fish ~/.config/fish/completions
# 3. Reload configuration
source ~/.config/fish/config.fish
""", language="fish")
with shell_tabs[1]:
alias_tabs = st.tabs(["bash", "zsh", "fish", "powershell", "nushell"])
with alias_tabs[0]:
st.code("""
# Add to .bashrc
eval "$(g --init bash)"
# Reload configuration
source ~/.bashrc
""", language="bash")
with alias_tabs[1]:
st.code("""
# Add to .zshrc
eval "$(g --init zsh)"
# Reload configuration
source ~/.zshrc
""", language="zsh")
with alias_tabs[2]:
st.code("""
# Add to fish configuration
g --init fish | source
# Reload configuration
source ~/.config/fish/config.fish
""", language="fish")
with alias_tabs[3]:
st.code("""
# Add to your profile
Invoke-Expression (& { (g --init powershell | Out-String) })
# Find your profile path
echo $profile
""", language="powershell")
with alias_tabs[4]:
st.code("""
# Add to $nu.env-path
^g --init nushell | save -f ~/.g.nu
# Add to $nu.config-path
source ~/.g.nu
""", language="nu")
st.markdown('<div class="section-header" id="project-comparison">Project Comparison</div>', unsafe_allow_html=True)
st.markdown("""
g is highly inspired by the following excellent projects:
- [exa](https://github.com/ogham/exa) / [eza](https://github.com/eza-community/eza)
- [lsd](https://github.com/lsd-rs/lsd)
- [ls-go](https://github.com/acarl005/ls-go)
""")
comparison_data = {
"Feature": ["Display Modes", "Unique Features", "Performance"],
"eza": ["oneline, grid, across, tree, recurse",
"-Z: list security context, -@: list extended attributes and sizes",
"better"],
"g": ["oneline, grid, across, zero, comma, table, json, markdown, tree, recurse",
"--mime: list mime types, --charset: list character sets",
"slower"]
}
df = pd.DataFrame(comparison_data)
st.table(df)
st.markdown("---")
st.markdown("""
<div class="footer">
<p>g is an open-source project with MIT license</p>
<p>Β© 2023-2025 Equationzhao</p>
<p><a href="https://github.com/Equationzhao/g/stargazers">β Star on GitHub</a> if you find this project useful!</p>
</div>
""", unsafe_allow_html=True)