Skip to content

Commit be8681a

Browse files
committed
better colors management and docs
1 parent 7f54be8 commit be8681a

File tree

3 files changed

+110
-7
lines changed

3 files changed

+110
-7
lines changed

README.md

Lines changed: 101 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,115 @@ gitfetch/
185185

186186
Configuration file location: `~/.config/gitfetch/gitfetch.conf`
187187

188-
Example configuration:
188+
The configuration file is automatically created on first run and contains two main sections:
189+
190+
### [DEFAULT] Section
189191

190192
```ini
191193
[DEFAULT]
192194
username = yourusername
193-
cache_expiry_hours = 6
195+
cache_expiry_hours = 24
196+
```
197+
198+
- `username`: Your default GitHub username (automatically set from authenticated GitHub CLI user)
199+
- `cache_expiry_hours`: How long to keep cached data (default: 24 hours)
200+
201+
### [COLORS] Section
202+
203+
gitfetch supports extensive color customization. All colors use ANSI escape codes.
204+
205+
```ini
206+
[COLORS]
207+
reset = \033[0m
208+
bold = \033[1m
209+
dim = \033[2m
210+
red = \033[91m
211+
green = \033[92m
212+
yellow = \033[93m
213+
blue = \033[94m
214+
magenta = \033[95m
215+
cyan = \033[96m
216+
white = \033[97m
217+
orange = \033[38;2;255;165;0m
218+
accent = \033[1m
219+
header = \033[38;2;118;215;161m
220+
muted = \033[2m
221+
0 = \033[48;5;238m
222+
1 = \033[48;5;28m
223+
2 = \033[48;5;34m
224+
3 = \033[48;5;40m
225+
4 = \033[48;5;82m
226+
```
227+
228+
#### Color Reference
229+
230+
- **Text Styles**:
231+
232+
- `reset`: Reset all formatting
233+
- `bold`: Bold text
234+
- `dim`: Dimmed text
235+
- `accent`: Accent styling (bold)
236+
237+
- **Basic Colors**:
238+
239+
- `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`: Standard ANSI colors
240+
- `orange`: Custom orange color
241+
242+
- **UI Elements**:
243+
244+
- `header`: Section headers and main display text
245+
- `muted`: Separators and underlines
246+
247+
- **Contribution Graph**:
248+
- `0`: No contributions (lightest)
249+
- `1`: 1-2 contributions
250+
- `2`: 3-6 contributions
251+
- `3`: 7-12 contributions
252+
- `4`: 13+ contributions (darkest)
253+
254+
#### Customizing Colors
255+
256+
To change colors, edit `~/.config/gitfetch/gitfetch.conf` and modify the ANSI escape codes:
257+
258+
**Example: Change header color to blue**
259+
260+
```ini
261+
header = \033[94m
262+
```
263+
264+
**Example: Change contribution graph colors to a purple theme**
265+
266+
```ini
267+
0 = \033[48;5;235m # Dark gray for no contributions
268+
1 = \033[48;5;60m # Dark purple
269+
2 = \033[48;5;62m # Medium purple
270+
3 = \033[48;5;64m # Light purple
271+
4 = \033[48;5;66m # Bright purple
194272
```
195273

274+
**Common ANSI Color Codes**:
275+
276+
- `\033[91m` = Bright Red
277+
- `\033[92m` = Bright Green
278+
- `\033[93m` = Bright Yellow
279+
- `\033[94m` = Bright Blue
280+
- `\033[95m` = Bright Magenta
281+
- `\033[96m` = Bright Cyan
282+
- `\033[97m` = Bright White
283+
284+
**Background Colors** (for contribution blocks):
285+
286+
- `\033[48;5;{color_code}m` where color_code is 0-255 (256-color palette)
287+
288+
Changes take effect immediately - no restart required.
289+
290+
## Caching
291+
196292
Cache database location: `~/.config/gitfetch/cache.db`
197293

294+
This will be moved in the future to a more standard location based on OS conventions.
295+
This will also come with a gitfetch --migrate-cache command to migrate existing cache to the new location.
296+
198297
## Why GitHub CLI?
199298

200299
Using the GitHub CLI (gh) instead of direct API calls provides several benefits:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gitfetch"
7-
version = "1.0.16"
7+
version = "1.0.17"
88
description = "A neofetch-style CLI tool for GitHub statistics"
99
readme = "README.md"
1010
requires-python = ">=3.8"

src/gitfetch/config.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def _load_config(self) -> None:
4949
if self.CONFIG_FILE.exists():
5050
self.config.read(self.CONFIG_FILE)
5151
if "COLORS" in self.config:
52-
self.config._sections['COLORS'] = {**default_colors, **self.config._sections['COLORS']}
52+
self.config._sections['COLORS'] = {
53+
**default_colors, **self.config._sections['COLORS']}
5354
else:
5455
self.config._sections['COLORS'] = default_colors
5556
else:
@@ -58,9 +59,12 @@ def _load_config(self) -> None:
5859
'username': '',
5960
'cache_expiry_hours': '24'
6061
}
61-
self.config._sections['COLORS'] = default_colors
62-
for k,v in self.config._sections['COLORS'].items():
63-
self.config._sections['COLORS'][k] = v.encode('utf-8').decode('unicode_escape')
62+
self.config.add_section('COLORS')
63+
for key, value in default_colors.items():
64+
self.config.set('COLORS', key, value)
65+
for k, v in self.config._sections['COLORS'].items():
66+
self.config._sections['COLORS'][k] = v.encode(
67+
'utf-8').decode('unicode_escape')
6468

6569
def get_default_username(self) -> Optional[str]:
6670
"""

0 commit comments

Comments
 (0)