Add subdir and help options to putwww, add completion
This commit is contained in:
parent
d2d2a166df
commit
08d5e15e18
7
.config/zsh/completions/_putwww
Normal file
7
.config/zsh/completions/_putwww
Normal file
|
@ -0,0 +1,7 @@
|
|||
#compdef putwww
|
||||
|
||||
_arguments '-d[remote subdirectory]:directory' '-h[short help text]' '*:file:_files'
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# End:
|
|
@ -3,9 +3,17 @@
|
|||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
|
||||
|
||||
autoload -U die
|
||||
|
||||
[[ ${ARGC} -eq 0 ]] && die 1 "Usage: ${0} <file> …"
|
||||
zmodload zsh/zutil
|
||||
local -a o_dir=(-d "")
|
||||
local -a o_help=()
|
||||
zparseopts -D -K -- d:=o_dir h=o_help
|
||||
if [[ ${#o_help} -ne 0 || ! -v 1 ]]; then
|
||||
ret=$(( ${#o_help} ^ 1 ))
|
||||
print -u $(( 1 + ${ret} )) "usage: ${0} [-h] [-d REMOTE SUBDIR] <FILE> …"
|
||||
return ${ret}
|
||||
fi
|
||||
local dir=""
|
||||
[[ -n ${o_dir[2]} ]] && dir=${o_dir[2]}/
|
||||
|
||||
local -a putcmds
|
||||
for file in "${@}"; do
|
||||
|
@ -13,10 +21,10 @@ for file in "${@}"; do
|
|||
done
|
||||
|
||||
sftp tastytea.de <<EOF
|
||||
cd /var/www/tastytea.de/files/
|
||||
cd /var/www/tastytea.de/files/${dir}
|
||||
$(print -l ${putcmds})
|
||||
EOF
|
||||
|
||||
for file in "${@}"; do
|
||||
print '\e[1;95m→\e[0m' https://tastytea.de/files/"${file##*/}"
|
||||
print '\e[1;95m→\e[0m' https://tastytea.de/files/${dir}"${file##*/}"
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue
Block a user