You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.4 KiB
Bash
61 lines
1.4 KiB
Bash
#ft=sh
|
|
|
|
alias slugify="sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z"
|
|
|
|
source_env_file () {
|
|
if [ ! -f "${1}" ]; then
|
|
return
|
|
fi
|
|
eval "$(
|
|
grep -v '^\s*\#' "${1}" |
|
|
grep -v '^\s*$' |
|
|
sed 's/^\s*export//g' |
|
|
sed 's/^/export /g'
|
|
)"
|
|
}
|
|
|
|
add_date_prefix () (
|
|
DIR=$(dirname "$1")
|
|
FILE=$(basename "$1")
|
|
DATE=$(date -r "$1" +"%F")
|
|
if [ ! -f "$1" ] ; then
|
|
echo "unknown file: $1"
|
|
exit 1
|
|
fi
|
|
mv "$1" "$DIR/${DATE}_${FILE}"
|
|
)
|
|
|
|
get_bitrate () (
|
|
if [ ! -f "$1" ] ; then
|
|
echo "[ERROR] unknown file: $1"
|
|
exit 1
|
|
fi
|
|
if ! command -v exiftool > /dev/null ; then
|
|
echo "[ERROR] exiftool not installed"
|
|
exit 1
|
|
fi
|
|
exiftool -AudioBitrate "$1" | awk '{print $4}'
|
|
)
|
|
|
|
json_to_yaml () (
|
|
ARG=${1:-}
|
|
if [ -z "${ARG}" ] ; then
|
|
dasel --read json --write yaml | bat --language yaml
|
|
elif [ -f "${ARG}" ] ; then
|
|
dasel --read json --write yaml --file "${ARG}" | bat --language yaml
|
|
else
|
|
echo "${ARG}" | dasel --read json --write yaml | bat --language yaml
|
|
fi
|
|
)
|
|
|
|
yaml_to_json () (
|
|
ARG=${1:-}
|
|
if [ -z "${ARG}" ] ; then
|
|
dasel --read yaml --write json | bat --language json
|
|
elif [ -f "${ARG}" ] ; then
|
|
dasel --read yaml --write json --file "${ARG}" | bat --language json
|
|
else
|
|
echo "${ARG}" | dasel --read yaml --write json | bat --language json
|
|
fi
|
|
)
|