Skip to content

Commit

Permalink
Added color to shfmt output (#927)
Browse files Browse the repository at this point in the history
Add color to shfmt output using bat.
  • Loading branch information
freemanjp authored Sep 17, 2023
1 parent 25f6c51 commit b970fa5
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions provisioning/roles/zsh/files/custom.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ if (( $+commands[bat] )) || (( $+commands[batcat] )); then
}
compdef less_or_bat=less
alias less=less_or_bat

if (( $+commands[shfmt] )); then
shfmt_with_bat() {
if [[ $# -ne 1 ]] || [[ "${1:-}" == '-'* ]] || [[ ! -e "${1:-}" ]]; then
shfmt "$@"
else
if (( $+commands[bat] )); then
shfmt "$@" | bat --plain --language bash
else
shfmt "$@" | batcat --plain --language bash
fi
fi
}
# shfmt doesn't currently have Zsh tab-completion
# compdef shfmt_with_bat=shfmt
alias shfmt=shfmt_with_bat
fi
fi

if (( $+commands[lsd] )); then
Expand Down

0 comments on commit b970fa5

Please sign in to comment.