-
-
Save benwei/4153486 to your computer and use it in GitHub Desktop.
yd script is a simple wrapper while cache read word for ydict
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/sh | |
YD_HIST_DIR="${HOME}/.ydict_history" | |
mkdir -p "$YD_HIST_DIR/_relation/" | |
echo "$@" >> "${YD_HIST_DIR}"/_words.txt | |
WordCacheFile="${YD_HIST_DIR}"/"$@".txt | |
WordRelationFile="${YD_HIST_DIR}"/_relation/"$@".txt | |
if [ ! -f "$WordCacheFile" ]; then | |
ydict -u -w "$@" | sed -e "s/'/'/g" -e "s/\(.\[36m\)[ ]*/\1 /g" > "$WordCacheFile" | |
fi | |
cat "$WordCacheFile" | |
wc -l "$WordCacheFile" | ( read size file ; | |
if [ $size -eq 2 ]; then | |
echo "remove $file with 2 line " | |
rm "$file" | |
fi | |
) | |
if [ -f "$WordRelationFile" ]; then | |
echo "=== Relation ===" | |
cat "$WordRelationFile" | |
fi | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment