Skip to content

Commit 69ccf0b

Browse files
authored
Merge pull request #32 from simono/tv-enhancements
Television enhancements
2 parents 7d2217a + cef640e commit 69ccf0b

File tree

8 files changed

+92
-1
lines changed

8 files changed

+92
-1
lines changed

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ brew "rnr"
2323
brew "rustup"
2424
brew "sd"
2525
brew "television"
26+
brew "uv"
2627
brew "vivid"
2728
brew "xh"
2829
brew "zoxide"

dotbot-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@
4646
- shell:
4747
- fish -c 'fisher update'
4848
- bat cache --build
49-
- tv update-channels
49+
- tv update-channels --force
50+
- for f in television/cable-overrides/*.toml; do ./television/merge-toml.py ~/.config/television/cable/"$(basename "$f")" "$f"; done
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Override for tv dirs channel.
2+
#
3+
# Simon Olofsson <simon@olofsson.de>
4+
#
5+
6+
[preview]
7+
command = "eza --group-directories-first --all --icons=always --color=always --oneline '{}'"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Override for tv files channel.
2+
#
3+
# Simon Olofsson <simon@olofsson.de>
4+
#
5+
6+
[preview]
7+
env = "__DELETE__"
8+
9+
[keybindings]
10+
ctrl-x = "actions:edit"
11+
ctrl-b = "actions:goto_parent_dir"
12+
13+
[actions.edit]
14+
mode = "fork"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Override for tv fish-history channel.
2+
#
3+
# Simon Olofsson <simon@olofsson.de>
4+
#
5+
6+
# Keep chronological order (newest first) when searching.
7+
# TODO: Remove once tv releases with this as default.
8+
[source]
9+
sort_results = false
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Override for tv git-log channel.
2+
#
3+
# Simon Olofsson <simon@olofsson.de>
4+
#
5+
6+
# Keep chronological order (newest first) when searching.
7+
# TODO: Remove once tv releases with this as default.
8+
[source]
9+
sort_results = false
10+
11+
[preview]
12+
command = "git show -p --stat --pretty=fuller '{strip_ansi|split: :1}' | delta --color-only"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Override for tv text channel.
2+
#
3+
# Simon Olofsson <simon@olofsson.de>
4+
#
5+
6+
[preview]
7+
env = "__DELETE__"
8+
9+
[keybindings]
10+
ctrl-x = "actions:edit"
11+
12+
[actions.edit]
13+
command = "vim '+{strip_ansi|split:\\::1}' '{strip_ansi|split:\\::0}'"
14+
mode = "fork"

television/merge-toml.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env -S uv run
2+
# /// script
3+
# dependencies = ["tomli-w"]
4+
# ///
5+
# Merges override into base TOML file in-place.
6+
#
7+
# Usage: merge-toml.py base.toml override.toml
8+
9+
import sys
10+
import tomllib
11+
import tomli_w
12+
from pathlib import Path
13+
14+
15+
def merge(base, override):
16+
for k, v in override.items():
17+
if v == "__DELETE__":
18+
base.pop(k, None)
19+
elif k in base and isinstance(base[k], dict) and isinstance(v, dict) and v:
20+
merge(base[k], v)
21+
else:
22+
base[k] = v
23+
return base
24+
25+
26+
if __name__ == "__main__":
27+
base_path = Path(sys.argv[1])
28+
override_path = Path(sys.argv[2])
29+
30+
base = tomllib.loads(base_path.read_text())
31+
override = tomllib.loads(override_path.read_text())
32+
33+
base_path.write_text(tomli_w.dumps(merge(base, override)))

0 commit comments

Comments
 (0)