Skip to content

Commit

Permalink
feat: show git overview when cd'ing in a git dir
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 16, 2024
1 parent f8874a5 commit ab8eba1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion config/.gitconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ co = checkout
c = commit --short
ci = commit --short
p = push
l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --decorate --date=short
l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --decorate --date=short --color --decorate

[core]
pager = delta
Expand Down
16 changes: 0 additions & 16 deletions config/fish/conf.d/onefetch.fish

This file was deleted.

26 changes: 26 additions & 0 deletions config/fish/conf.d/pwd.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# the following functions are here instead of in the functions directory
# because they utilize event handlers which autoloading does not support

# auto run onefetch if inside git repo
# --on-variable is a fish builtin that changes whenever the directory changes
# so this function will run whenever the directory changes
function auto_pwd --on-variable PWD
# check if .git/ exists and is a git repo and if onefetch is installed
if test -d .git && git rev-parse --git-dir >/dev/null 2>&1
# readme file
if test -f README.md
awk '/^##/{exit} 1' README.md | string trim \
| glow -s dark -w 120 | grep -v 'Image: image' 2>&1 | head -20 | string trim -l -r
end

# recent commits
echo "## Recent Activity" | glow -s dark -w 120 | string trim
hub l -10 \
--since='1 week ago' \
| devmoji --log --color \
| sed 's/^/ /'
# local changes
echo "## Status" | glow -s dark -w 120
hub -c color.ui=always st | sed 's/^/ /'
end
end

0 comments on commit ab8eba1

Please sign in to comment.