Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] add randomizer option #15

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion cutefetch
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ get_res_mac() {
# --------------------------- Handle Args --------------------------- #

# parse CLI arguments
OPTSTRING=":e:s:hv"
OPTSTRING=":e:s:hrv"
while getopts ${OPTSTRING} opt; do
case ${opt} in
v)
Expand All @@ -225,6 +225,9 @@ while getopts ${OPTSTRING} opt; do
e)
EYES_CHOICE="${OPTARG}"
;;
r)
RAND_CHOICE=true
;;
:)
echo "Option -${OPTARG} requires an argument."
echo ""
Expand All @@ -238,6 +241,27 @@ while getopts ${OPTSTRING} opt; do
esac
done

# randomization
if [[ "${RAND_CHOICE}" = true ]]; then
if [[ -z "${EYES_CHOICE}" ]]; then
EYES_LIST="$(seq -s "," 0 15)"
EYES_LIST="${EYES_LIST::-1}"
else
EYES_LIST="${EYES_CHOICE}"
fi
if [[ -z "${MODE_CHOICE}" ]]; then
MODE_LIST="cat catfull bunny dog penguin none"
else
MODE_LIST="${MODE_CHOICE}"
fi

EYES_LIST="${EYES_LIST//,/ }"
MODE_LIST="${MODE_LIST//,/ }"

EYES_CHOICE="$(shuf -e -n 1 ${EYES_LIST})"
MODE_CHOICE="$(shuf -e -n 1 ${MODE_LIST})"
fi

# print the fetch info, kitty by default
main() {
init
Expand Down