Add matrix_image_url
This commit is contained in:
parent
bfd9efb569
commit
87c389eb39
7
.config/zsh/completions/_matrix_image_url
Normal file
7
.config/zsh/completions/_matrix_image_url
Normal file
@ -0,0 +1,7 @@
|
||||
#compdef matrix_image_url
|
||||
|
||||
_arguments '-h[short help text]' '*:url:_urls'
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# End:
|
21
.config/zsh/functions/matrix_image_url
Normal file
21
.config/zsh/functions/matrix_image_url
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env zsh
|
||||
# Converts mxc:// URLs into https:// URLs
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
zmodload zsh/zutil
|
||||
local -a o_help=()
|
||||
zparseopts -D -K -- h=o_help
|
||||
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
||||
ret=$(( ${#o_help} ^ 1 ))
|
||||
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] <URL> …"
|
||||
return ${ret}
|
||||
fi
|
||||
local -a urls=(${@})
|
||||
|
||||
for url in ${urls}; do
|
||||
local domain=${${url%/*}##*/}
|
||||
local id=${url##*/}
|
||||
print '\e[1;95m→\e[0m' \
|
||||
"https://${domain}/_matrix/media/r0/download/${domain}/${id}"
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user