cp completions: Give not-GNU cp the floam treatment

This commit is contained in:
Aaron Gyes 2018-11-25 01:41:00 -08:00
parent 7d79d326b5
commit a4f27bea36

View file

@ -1,4 +1,4 @@
if cp --version 2>/dev/null > /dev/null # GNU
if cp --version 2>/dev/null > /dev/null # GNU cp
complete -c cp -s a -l archive -d "Same as -dpR"
complete -c cp -s b -l backup -d "Make backup of each existing destination file" -a "none off numbered t existing nil simple never"
complete -c cp -l copy-contents -d "Copy contents of special files when recursive"
@ -26,17 +26,51 @@ if cp --version 2>/dev/null > /dev/null # GNU
complete -c cp -s s -l symbolic-link -d "Make symbolic links instead of copying"
complete -c cp -s T -l no-target-directory -d "Treat DEST as a normal file"
complete -c cp -s x -l one-file-system -d "Stay on this file system"
complete -c cp -s X -l context -r -d "Set security context of copy to CONTEXT"
else # OS X
complete -c cp -s a -d "Preserve structure and attributes of files but not directory structure. (-pPR)"
complete -c cp -s f -d "Replace destination file without confirmation"
complete -c cp -s H -d "Follow symlinks on command-link"
complete -c cp -s X -l context -r -d "Set SELinux context of copy to CONTEXT"
else # BSD/macOS
set -l uname (uname -s)
# Solaris: cp [-R | r [H | L | P ]] [-fi ] [-p ]
# openbsd: cp [-R | [H | L | P ]] [-fi ] [-pv ]
# macos: cp [-R | [H | L | P ]] [-fin] [-pva cX ] # -c: clone -X: copy xattrs
# netbsd: cp [-R | [H | L | P ]] [-fi ] [-pval N] # -l: hard link instead of copy -N: don't copy file flags
# dragonfly: cp [-R | [H | L | P ]] [-fin] [-pvalx ] # -x: don't traverse mount points
# freebsd: cp [-R | [H | L | P ]] [-fin] [-pvalxs ] # -s: symlink instead of copy
if [ "$uname" = SunOS ] # annoying
complete -c cp -s r -d "Copy directories recursively"
complete -c cp -s R -d "Like -r, but replicating pipes instead of reading pipes"
else
complete -c cp -s R -d "Copy directories recursively"
end
complete -c cp -s H -d "with -R: Follow symlinks in cp arguments"
complete -c cp -s L -d "with -R: Follow all symlinks"
complete -c cp -s P -d "with -R: Don't follow symlinks (default)"
complete -c cp -s f -d "Replace destination without confirmation"
complete -c cp -s i -d "Prompt before overwrite"
complete -c cp -s L -d "Follow all symlinks"
complete -c cp -s n -d "Do overwrite existing files"
complete -c cp -s P -d "Don't follow symlinks (default)"
not contains "$uname" SunOS OpenBSD NetBSD
and complete -c cp -s n -d "Don't overwrite existing files"
complete -c cp -s p -d "Preserve attributes of source file"
complete -c cp -s R -d "Copy directories recursively"
complete -c cp -s v -d "Verbos output"
complete -c cp -s X -d "Do not copy Extended Attributes (EAs) of resource forks"
end
if [ "$uname" = SunOS ]
exit 0
end
complete -c cp -s v -d "Print file names as files are copied"
if [ "$uname" = OpenBSD ]
exit 0
end
complete -c cp -s a -d "Archive mode (-pPR)"
if [ "$uname" = Darwin ]
complete -c cp -s c -d "Clone using clonefile(2)"
complete -c cp -s X -d "Do not copy xattrs or resource forks"
exit 0
end
complete -c cp -s l -d "Hard link instead of copying"
if [ "$uname" = NetBSD ]
complete -c cp -s N -d "Don't copy file flags"
exit 0
end
complete -c cp -s x -d "Don't traverse file system mount points"
if [ "$uname" = FreeBSD ]
complete -c cp -s s -d "Symlink instead of copying"
end
end