Skip to content

Commit

Permalink
fix(utils): support wait_for_input
Browse files Browse the repository at this point in the history
  • Loading branch information
Avivbens committed May 19, 2024
1 parent bb18080 commit 8780aea
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions zsh/.utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@ function performance_mark() {
fi
}

# Usage: wait_for_input "key"
# Usage: wait_for_input "key" "custom message to display"
function wait_for_input() {
local TRIGGER_KEY=$1
local CUSTOM_MESSAGE=$2
local MESSAGE="Press $TRIGGER_KEY to continue ✨"

if [ -n "$CUSTOM_MESSAGE" ]; then
MESSAGE=$CUSTOM_MESSAGE
fi

printf "\x1b[31m$MESSAGE\x1b[0m\n"

while read line; do
if [[ "$line" == $TRIGGER_KEY ]]; then
break
fi
done
}

function sourceIf() {
if [ -f "$1" ]; then
source $1
Expand Down

0 comments on commit 8780aea

Please sign in to comment.