Skip to content

Instantly share code, notes, and snippets.

@hjst
Created Jun 23, 2015
Embed
What would you like to do?
Makes reading stardict dictionary searches in a terminal more bearable.
#!/bin/bash
# A wrapper script for sdcv which provides line spacing and wrapping to improve
# readability.
#
# Please note: sdcv(1) relies on dictionary files being in
# /usr/share/stardict/dic
# $(HOME)/.stardict/dic
usage() {
echo "Usage: $0 [-l] <string>" 1>&2
echo " (See the sdcv manpage for search string modifiers)" 1>&2
exit 1
}
while getopts ":l" opt; do
case $opt in
l)
LESS=1
shift
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
if [ -z $1 ]; then
usage
else
if [ $LESS -eq 1 ]; then
sdcv $1 | sed G | fold -s | less
else
sdcv $1 | sed G | fold -s
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment