Hey Alain,
I modified you command as follows:
#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes" require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/config_helper.rb"
symbols = Config.load['symbols'] word = STDIN.read
if symbols.has_key? word and not ENV['TM_SCOPE'].match(/math/) print "\$#{symbols[word]}$0\$" else TextMate.exit_discard end
If you have any questions about the semantics feel free to ask.
—Alex