Created
June 23, 2015 04:35
-
-
Save hjst/2d69419d1ab65e01e670 to your computer and use it in GitHub Desktop.
Makes reading stardict dictionary searches in a terminal more bearable.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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