[feature] rename dict to d
This commit is contained in:
parent
e3b438b2d9
commit
195001e359
|
@ -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)"
|
||||
request
|
||||
if [ -n "$SENTENCE" ]; then
|
||||
request
|
||||
else
|
||||
display
|
||||
fi
|
||||
#pronounce "$@"
|
||||
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user