Skip to content

Commit

Permalink
starship: put chezmoi diff status in the prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
yacoob committed Dec 7, 2024
1 parent ea2c9bf commit 2826244
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion home/dot_config/starship.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"$schema" = 'https://starship.rs/config-schema.json'

format = '$time$line_break$all$line_break$character'
format = '$time$custom$line_break$all$line_break$character'

[cmd_duration]
show_milliseconds = true
Expand Down Expand Up @@ -60,6 +60,13 @@ style = 'yellow'
threshold = 66
style = 'dimmed green'

[custom.chezmoi_diff]
description = 'Size of the current "chezmoi diff" output'
command = 'cat ~/.cache/chezmoi-diff-count'
when = 'test -s ~/.cache/chezmoi-diff-count'
symbol = ''
disabled = false

# The symbols below were produced by `starship preset nerd-font-symbols`, then moved to sections above, as needed.
[aws]
symbol = ""
Expand Down
6 changes: 6 additions & 0 deletions home/dot_config/systemd/user/chezmoi-diff.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Record size of 'chezmoi diff' output

[Service]
Type=oneshot
ExecStart=/bin/sh -c 'chezmoi diff | wc -l > ~/.cache/chezmoi-diff-count'
9 changes: 9 additions & 0 deletions home/dot_config/systemd/user/chezmoi-diff.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Periodically count chezmoi differences

[Timer]
OnBootSec=5m
OnUnitInactiveSec=5m

[Install]
WantedBy=timers.target
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../chezmoi-diff.timer

0 comments on commit 2826244

Please sign in to comment.