Skip to content

Instantly share code, notes, and snippets.

@ffledgling
Created June 21, 2016 11:25
Show Gist options
  • Select an option

  • Save ffledgling/5d635ad3d7bee766e5d7cc901563d1d5 to your computer and use it in GitHub Desktop.

Select an option

Save ffledgling/5d635ad3d7bee766e5d7cc901563d1d5 to your computer and use it in GitHub Desktop.
Function to pretty prit yaml file groups in a directory
yamlls() {
local f
local t
local _color
declare -A types=()
for f in *.*.yaml; do
t=${f%.yaml}
types[${t##*.}]=1
done
_color=0
for t in "${!types[@]}"; do
tput bold
tput smul
echo ${t}:
tput sgr0
for _file in $(ls -1 "$@" *."$t.yaml")
do
echo "${_file%${t}.yaml}$(tput setaf $((6 - _color%6)) && tput bold)${t}.yaml"
tput sgr0
done
((_color++))
echo
done
tput sgr0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment