mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-23 00:17:59 +00:00
[utility] scp/rsync glob local paths but don't glob remote paths
Adds a function which wraps rsync and scp so that remote paths are not globbed but local paths are globbed. This is because the programs have their own globbing for remote paths. The wrap function globs args starting in / and ./ and doesn't glob paths with : in it as these are interpreted as remote paths by these programs unless the path starts with / or ./ Fixes issue #1125
This commit is contained in:
parent
dbe9a5ea28
commit
a876890afd
@ -41,8 +41,26 @@ alias ftp='noglob ftp'
|
|||||||
alias history='noglob history'
|
alias history='noglob history'
|
||||||
alias locate='noglob locate'
|
alias locate='noglob locate'
|
||||||
alias rake='noglob rake'
|
alias rake='noglob rake'
|
||||||
alias rsync='noglob rsync'
|
alias rsync='noglob rsync_scp_wrap rsync'
|
||||||
alias scp='noglob scp'
|
alias scp='noglob rsync_scp_wrap scp'
|
||||||
|
# This function wraps rsync and scp so that remote paths are not globbed
|
||||||
|
# but local paths are globbed. This is because the programs have their own
|
||||||
|
# globbing for remote paths. The wrap function globs args starting in / and ./
|
||||||
|
# and doesn't glob paths with : in it as these are interpreted as remote paths
|
||||||
|
# by these programs unless the path starts with / or ./
|
||||||
|
function rsync_scp_wrap {
|
||||||
|
local args=( )
|
||||||
|
local cmd="$1"
|
||||||
|
shift
|
||||||
|
local i
|
||||||
|
for i in "$@"; do case $i in
|
||||||
|
( ./* ) args+=( ${~i} ) ;; # glob
|
||||||
|
( /* ) args+=( ${~i} ) ;; # glob
|
||||||
|
( *:* ) args+=( ${i} ) ;; # noglob
|
||||||
|
( * ) args+=( ${~i} ) ;; # glob
|
||||||
|
esac; done
|
||||||
|
command $cmd "${(@)args}"
|
||||||
|
}
|
||||||
alias sftp='noglob sftp'
|
alias sftp='noglob sftp'
|
||||||
|
|
||||||
# Define general aliases.
|
# Define general aliases.
|
||||||
|
Loading…
Reference in New Issue
Block a user