Created
February 24, 2025 02:24
-
-
Save tkuriyama/ef28d12e496b8670d5bee74f787f4f9a to your computer and use it in GitHub Desktop.
mistral_llm_output_voicemode_1.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Initialize the toggle variable | |
| typeset -g VMODE_ENABLED=false | |
| # Define a function to wrap command execution | |
| function speak_output() { | |
| # Capture the output of the command | |
| local output=$(eval "$@" 2>&1) | |
| # Print the output to the terminal | |
| echo "$output" | |
| # Speak the output aloud | |
| echo "$output" | say -r 300 | |
| # Return the exit status of the command | |
| return ${PIPESTATUS[0]} | |
| } | |
| # Override the default command execution to use the speak_output function | |
| function preexec() { | |
| # Check if the command is not empty and VMODE is enabled | |
| if [[ -n "$1" && $VMODE_ENABLED == true ]]; then | |
| # Wrap the command execution with speak_output | |
| speak_output "$1" | |
| # Prevent the original command from being executed | |
| return 1 | |
| fi | |
| } | |
| # Add the preexec function to the preexec_functions array | |
| preexec_functions+=(preexec) | |
| # Define the vmode on command | |
| function vmode_on() { | |
| VMODE_ENABLED=true | |
| echo "Voice mode enabled." | |
| } | |
| # Define the vmode off command | |
| function vmode_off() { | |
| VMODE_ENABLED=false | |
| echo "Voice mode disabled." | |
| } | |
| # Make vmode commands available | |
| alias vmode='noglob vmode' | |
| function vmode() { | |
| if [[ "$1" == "on" ]]; then | |
| vmode_on | |
| elif [[ "$1" == "off" ]]; then | |
| vmode_off | |
| else | |
| echo "Usage: vmode {on|off}" | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment