mirror of
https://github.com/jessebot/dot_files.git
synced 2025-10-01 01:48:43 +00:00
catch any errors we might get from yq trying to render gotemplated files
This commit is contained in:
parent
0b75198c3f
commit
8523842837
1 changed files with 5 additions and 4 deletions
|
@ -75,16 +75,17 @@ bat cache --build > /dev/null || batcat cache --build > /dev/null
|
|||
function dog {
|
||||
# if this is a csv file, ALWAYS use rich to print the data
|
||||
if [[ "$1" == *".csv" ]]; then
|
||||
rich $1
|
||||
rich "$1"
|
||||
# if this is a json file, always use jq to pretty print it
|
||||
elif [[ "$1" == *".json" ]]; then
|
||||
env cat $1 | jq
|
||||
env cat "$1" | jq
|
||||
# if this is a YAML file, always use yq to pretty print and validate it
|
||||
# if using yq fails, fall back to bat & redirect errors to the shadow realm
|
||||
elif [[ "$1" == *".yaml" ]] || [[ "$1" == *".yml" ]]; then
|
||||
env cat $1 | yq
|
||||
env cat "$1" | yq 2> /dev/null || bat --plain --theme=spacechalk --pager=never "$1"
|
||||
else
|
||||
# use batcat - syntax highlighting + git support
|
||||
bat --plain --theme=spacechalk --pager=never $1 || batcat --pager=never --theme=spacechalk --plain $1
|
||||
bat --plain --theme=spacechalk --pager=never "$1" || batcat --pager=never --theme=spacechalk --plain "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue