With this function one can query a dictionary (dict.cc in this case) from within a shell.
With the parameter '-l
' '(lower case „L“)
' one can change source and destination language; for German to Esperanto use -l deeo
:
dic -l deeo baum Baum {m} arbo
Withouth -l the translation from German to English is used.
Add the following lines to your ~/.bashrc
file
function dic() function dic() { DIC_HIST="$HOME/.local/share/dic_history" if [ "$1" = "-l" ]; then local _lang=$2; shift 2; else local _lang=deen; fi; if [ "$1" = "-h" ]; then cat "${DIC_HIST}" return fi if [ "${_lang}" == "deen" ]; then _lang="" else _lang="${_lang}." fi w3m -dump "http://${_lang}pocket.dict.cc?s=\"$*\"" | sed -r -e '/^([ ]{5,}.*)$/d' -e '1,2d' -e '/^$/d' -e '/^\[/d' echo "$@" >> "${DIC_HIST}" }
dic blumentopf Blumentopf {m} flowerpot plant pot
dic in die Irre führen in die Irre führen to mislead
Create an executable script named dic.sh with the following content:
#!/bin/bash >>>ADD HERE THE SHELL FUNCTION (see above)<<< dic $(xsel) | less
The package xsel
is needed.
Now create a new shortcut in the file ~/.config/openbox/rc.xml (or ~/.config/openbox/lxde-rc.xml for use in LXDE):
<keybind key="W-t"> <action name="Execute"> <command>xterm -geometry 60x40 -e /path/to/dic.sh</command> </action> </keybind>
Now reload your configuration and have fun with it :)
Select a word somewhere, press Win + t and see:<br />