Skip to content

Instantly share code, notes, and snippets.

@hjst
Created June 23, 2015 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hjst/2d69419d1ab65e01e670 to your computer and use it in GitHub Desktop.
Save hjst/2d69419d1ab65e01e670 to your computer and use it in GitHub Desktop.
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