dict.cc.py
dict.cc.py copied to clipboard
Configurable default languages
It would be great if we could avoid having to type the source and target language all the time. Instead of doing:
$ dict.cc.py en de body
We could let users configure which languages they would like to be the default, so they could avoid having to type en de all the time (although they can type it if they want non-default options):
$ dict.cc.py body
Two ideas for handling this config:
- Config file in the user's home dir (e.g.:
~/.dict.cc.py.yaml) - Environment variables (e.g.:
DICT_CC_PY_LANGS="en de")
I tend to favor the first approach, but at this complexity level it's a matter of personal taste 🙂
Alternatively, I created some little scripts for this:
#!/bin/sh
set -eu
if [ $# -le 0 ]; then
echo "Provide argument to be translated!"
exit 1
fi
/usr/lib/python3.6/site-packages/dict.cc/dict.cc.py en de "$@"
``
For zsh I use
function join_by { local IFS="$1"; shift; echo "$*"; }
function dict { dict.cc.py --max-results 12 en de "$*" | grep --color -Ei "$(join_by \| $*)|$"; }
