Skip to content

Commit

Permalink
feat: Print README if present on directory change
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpovel committed Dec 30, 2023
1 parent 1a35237 commit ca2b325
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ install_cli_tools() {
just --completions zsh > "${ZSH_COMPLETIONS_DIR}/_just"

sudo apt install --yes \
bat \
direnv \
dnsutils \
fd-find \
Expand Down
25 changes: 25 additions & 0 deletions home/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,31 @@ plugins=(

export ZSH_COLORIZE_STYLE="dracula"

# =====================================================================================
# Hooks
# =====================================================================================

function print_readme() {
local line_length=10

for readme in README.md README.rst README.txt README; do
if [[ -f "$readme" ]]; then
if command -v batcat >/dev/null 2>&1; then
batcat --line-range=:"$line_length" "$readme"
elif command -v bat >/dev/null 2>&1; then
bat --line-range=:"$line_length" "$readme"
else
head -n "$line_length" "$readme"
fi
break
fi
done
}

autoload -U add-zsh-hook
# Print README on directory change
add-zsh-hook chpwd print_readme

# =====================================================================================
# Custom functions
# =====================================================================================
Expand Down

0 comments on commit ca2b325

Please sign in to comment.