[feature] rename dict to d

This commit is contained in:
Klesh Wong 2020-11-04 23:31:25 +08:00
parent e3b438b2d9
commit 195001e359
2 changed files with 8 additions and 23 deletions

View File

@ -1,5 +1,7 @@
#!/bin/sh
# shellcheck disable=2086
set -e
DIR="$(readlink -f "$(dirname "$0")")"
DMENU_OPTS='-i -c -fn monospace:13 -nb #626262 -nf #bbbbbb -sb #5b97f7 -sf #eeeeee -l 20'
@ -34,7 +36,7 @@ display() {
fi
display
elif echo "$INPUT" | grep -P '^ '; then
echo -n $INPUT | sed 's/^\s+//' | xsel -b
printf "%s" "$INPUT" | sed 's/^\s+//' | xsel -b
else
SENTENCE="$INPUT"
request
@ -44,7 +46,10 @@ display() {
SENTENCE="$*"
[ -z "$SENTENCE" ] && SENTENCE="$(xsel -o)"
if [ -n "$SENTENCE" ]; then
request
else
display
fi
#pronounce "$@"

View File

@ -5,26 +5,6 @@ function dt
date "+%Y%m%d-%H%M%S"
end
# translation
function d
set meta (
curl -SsLG "http://cn.bing.com/dict/search" --data-urlencode "q=$argv" | \
string match -r '<meta name="description" content="必应词典为您提供.+的释义,(.+?)" />'
)
set trans (string replace -ra '\W(?=(\w+\.|网络释义:))' \n $meta[2])
string join \n $trans
end
# pronounciation
function dp
set play afplay
if not which $play 2>/dev/null
set play ffplay -nodisp -autoexit
end
wget -O /tmp/sound.mp3 "http://dict.youdao.com/dictvoice?audio=$argv[1]&type=1" &>/dev/null
and eval $play /tmp/sound.mp3 1>/dev/null 2>/dev/null
end
function clean-taobao-link
echo "$argv" | sed 's/^\(.*\)?\(.*&\)\?\(id=[^&]\+\).*$/\1?\3/g' | xsel -sb
end