Skip to content

Commit ca2b325

Browse files
committed
feat: Print README if present on directory change
1 parent 1a35237 commit ca2b325

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

debian.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ install_cli_tools() {
140140
just --completions zsh > "${ZSH_COMPLETIONS_DIR}/_just"
141141

142142
sudo apt install --yes \
143+
bat \
143144
direnv \
144145
dnsutils \
145146
fd-find \

home/.zshrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ plugins=(
2727

2828
export ZSH_COLORIZE_STYLE="dracula"
2929

30+
# =====================================================================================
31+
# Hooks
32+
# =====================================================================================
33+
34+
function print_readme() {
35+
local line_length=10
36+
37+
for readme in README.md README.rst README.txt README; do
38+
if [[ -f "$readme" ]]; then
39+
if command -v batcat >/dev/null 2>&1; then
40+
batcat --line-range=:"$line_length" "$readme"
41+
elif command -v bat >/dev/null 2>&1; then
42+
bat --line-range=:"$line_length" "$readme"
43+
else
44+
head -n "$line_length" "$readme"
45+
fi
46+
break
47+
fi
48+
done
49+
}
50+
51+
autoload -U add-zsh-hook
52+
# Print README on directory change
53+
add-zsh-hook chpwd print_readme
54+
3055
# =====================================================================================
3156
# Custom functions
3257
# =====================================================================================

0 commit comments

Comments
 (0)