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 b8d3a4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 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
20 changes: 15 additions & 5 deletions config/fish/conf.d/onefetch.fish → config/fish/conf.d/pwd.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
# 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_onefetch --on-variable PWD
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
# onefetch
hub log -10 --reverse \
--pretty=format:'* %Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' \
--abbrev-commit --decorate --date=short --color \
# readme file
if test -f README.md
awk '/^##/{exit} 1' README.md | head -20 | string trim \
| glow -s dark -w 120 | grep -v 'Image: image' 2>&1 | 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

# local changes
echo "## Status" | glow -s dark -w 120
hub st
end
end

0 comments on commit b8d3a4d

Please sign in to comment.