2018-11-25 06:45:03 +00:00
|
|
|
set -l uname (uname -s)
|
2005-09-20 13:31:55 +00:00
|
|
|
|
2018-11-25 06:45:03 +00:00
|
|
|
## GNU mv
|
|
|
|
if mv --version >/dev/null 2>/dev/null
|
|
|
|
# --backup requires an argument, -b does not accept an argument
|
|
|
|
complete -c mv -l backup -r -d "Backup each existing destination file" \
|
2019-05-05 10:53:09 +00:00
|
|
|
-x -ka "none\t'Never make backups'
|
2018-11-25 06:45:03 +00:00
|
|
|
off\t'Never make backups'
|
|
|
|
numbered\t'Make numbered backups'
|
|
|
|
t\t'Make numbered backups'
|
|
|
|
existing\t'Numbered backups if any exist, else simple'
|
|
|
|
nil\t'Numbered backups if any exist, else simple'
|
|
|
|
simple\t'Make simple backups'
|
|
|
|
never\t'Make simple backups'"
|
|
|
|
complete -c mv -s b -d "Backup each existing destination file"
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s f -l force -d "Don't prompt to overwrite"
|
|
|
|
complete -c mv -s i -l interactive -d "Prompt to overwrite"
|
|
|
|
complete -c mv -s n -l no-clobber -d "Don't overwrite existing"
|
2018-11-25 06:45:03 +00:00
|
|
|
# --reply has been deprecated for over a decade, and now GNU mv does not accept this option.
|
|
|
|
# Better to use -f instead of --reply=yes.
|
|
|
|
# complete -c mv -l reply -x -a "yes no query" -d "Answer for overwrite questions"
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -l strip-trailing-slashes -d "Remove trailing '/' from source args"
|
2018-11-25 06:45:03 +00:00
|
|
|
complete -c mv -s S -l suffix -x -d "Override default backup suffix"
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s t -l target-directory -d "Move all source args into DIR" \
|
2019-05-05 10:53:09 +00:00
|
|
|
-x -a "(__fish_complete_directories (commandline -ct) 'Directory')"
|
2018-11-25 06:45:03 +00:00
|
|
|
complete -c mv -s T -l no-target-directory -d "Treat DEST as a normal file"
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s u -l update -d "Don't overwrite newer"
|
|
|
|
complete -c mv -s v -l verbose -d "Print filenames as it goes"
|
2018-11-25 06:45:03 +00:00
|
|
|
test "$uname" = Linux
|
2019-05-05 10:53:09 +00:00
|
|
|
and complete -c mv -s Z -l context -d "Set SELinux context to default"
|
2018-11-25 06:45:03 +00:00
|
|
|
|
|
|
|
complete -c mv -l help -d "Print help and exit"
|
|
|
|
complete -c mv -l version -d "Print version and exit"
|
2019-05-05 10:53:09 +00:00
|
|
|
## BSD-ish mv
|
|
|
|
else #[posix][ext]
|
2018-11-25 06:45:03 +00:00
|
|
|
# freebsd: mv [-fi][nvh] src dst
|
|
|
|
# dragonfly: mv [-fi][nvh] src dst
|
|
|
|
# macos: mv [-fi][nv ] src dst
|
|
|
|
# netbsd: mv [-fi][ v ] src dst
|
|
|
|
# openbsd: mv [-fi][ v ] src dst
|
|
|
|
# solaris: mv [-fi][ ] src dst
|
|
|
|
|
|
|
|
# POSIX options
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s f -d "Don't prompt to overwrite"
|
|
|
|
complete -c mv -s i -d "Prompt to overwrite existing"
|
2018-11-25 06:45:03 +00:00
|
|
|
|
|
|
|
test uname = SunOS # -fi
|
2019-05-05 10:53:09 +00:00
|
|
|
and exit 0
|
2018-11-25 06:45:03 +00:00
|
|
|
|
|
|
|
# Extensions
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s v -d "Print filenames as it goes"
|
2018-11-25 06:45:03 +00:00
|
|
|
|
|
|
|
contains "$uname" NetBSD OpenBSD # -fiv
|
2019-05-05 10:53:09 +00:00
|
|
|
and exit 0
|
2018-11-25 06:45:03 +00:00
|
|
|
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s n -d "Don't overwrite existing"
|
2018-11-25 06:45:03 +00:00
|
|
|
|
|
|
|
test "$uname" = Darwin # -fivn
|
2019-05-05 10:53:09 +00:00
|
|
|
and exit 0
|
2018-11-25 06:45:03 +00:00
|
|
|
|
2019-03-09 23:02:25 +00:00
|
|
|
complete -c mv -s h -d "Don't follow target if it links to a dir"
|
2018-11-25 06:45:03 +00:00
|
|
|
end
|