Skip to content

Instantly share code, notes, and snippets.

@azat
Created May 5, 2014 19:59
Show Gist options
  • Save azat/a3067998f77b58afad5d to your computer and use it in GitHub Desktop.
Save azat/a3067998f77b58afad5d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Translate with google-translate into X server OR tmux
# Bind it to shortcut
#
# @link http://habrahabr.ru/blogs/linux/137215/
#
if [ -z $TMUX ]; then
notify-send -u critical "$(xsel -o)" "$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=$(xsel -o | sed "s/[\"'<>]//g")&sl=auto&tl=ru" | sed 's/\[\[\[\"//' | cut -d \" -f 1)"
else
tmux display-message "$(wget -U "Mozilla/5.0" -qO - "http://translate.google.com/translate_a/t?client=t&text=$*&sl=auto&tl=ru" | sed 's/\[\[\[\"//' | cut -d \" -f 1)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment