bashechoaliasespeak

Alias for echo function with espeak executed in background


I want to replace the normal echo function in ubuntu bash with a function that additionally uses espeak to say something everytime echo is used.

I came up with an alias for my .bashrc

alias ghostTalk='espeak -v +whisper -s 80 -p 100 "$(myFun)"& /bin/echo $1'

(in my final version I would replace ghostTalk with echo)

But this gives as output:

~$ ghostTalk 123
[2] 5685
123
[1]   Done                    espeak -v +whisper -s 80 -p 100 "$(myFun)"

How can I avoid this and have the normal echo output e.g. only 123 while its talking in the background?


Solution

  • Backgrounding notifications can be suppressed with a double-fork:

    ghostTalk() {
      ( espeak -v +whisper -s 80 -p 100 "$(myFun)" & )
      builtin echo "$@"
    }