summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolai Weibull <pcppopper@users.sourceforge.net>2011-08-20 07:44:39 +0000
committerNikolai Weibull <pcppopper@users.sourceforge.net>2011-08-20 07:44:39 +0000
commitcfdb417a6b91364706a8fd5ba319eac086d0d568 (patch)
tree929733dba7ec01fbb573039706218fbb395954e1
parentcf845a396ed6a9793711c15750b86326c440b483 (diff)
downloadzsh-cfdb417a6b91364706a8fd5ba319eac086d0d568.tar.gz
zsh-cfdb417a6b91364706a8fd5ba319eac086d0d568.zip
29707: Completion/Unix/Command/_ln: New _ln completer
-rw-r--r--ChangeLog7
-rw-r--r--Completion/Unix/Command/.distfiles1
-rw-r--r--Completion/Unix/Command/_ln76
3 files changed, 83 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ff7d8d384..a7d2c0bac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-08-20 Nikolai Weibull <now@bitwi.se>
+
+ * 29707: Completion/Unix/Command/.distfiles,
+ Completion/Unix/Command/_ln: New _ln completer.
+
2011-08-18 Mikael Magnusson <mikachu@gmail.com>
* unposted: Completion/Linux/Command/.distfiles,
@@ -15318,5 +15323,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5442 $
+* $Revision: 1.5443 $
*****************************************************
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index 696faea88..22e0a4fbe 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -111,6 +111,7 @@ _last
_ldd
_less
_links
+_ln
_loadkeys
_locate
_look
diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln
new file mode 100644
index 000000000..89b7177ab
--- /dev/null
+++ b/Completion/Unix/Command/_ln
@@ -0,0 +1,76 @@
+#compdef ln gln
+
+local curcontext="$curcontext" state line ret=1
+local -A opt_args
+
+local -a args
+args=(
+ '-f[remove existing destination files]'
+ '-s[create symbolic links instead of hard links]')
+
+local -a opts
+
+local variant
+_pick_variant -r variant gnu=gnu unix --help
+if [[ $variant == gnu ]]; then
+ opts=(-S)
+ args=(
+ '(-b --backup)-b[create a backup of each existing destination file]' \
+ '(-b --backup)--backup=[create a backup of each existing destination file]::method:((
+ none\:"never create backups"
+ off\:"never create backups"
+ numbered\:"create numbered backup"
+ t\:"create numbered backup"
+ existing\:"same as numbered if numbered backups exist, otherwise same as simple"
+ nil\:"same as numbered if numbered backups exist, otherwise same as simple"
+ simple\:"always create simple backups"
+ never\:"always create simple backups"))'
+ '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]'
+ '(-f --force)'{-f,--force}'[remove existing destination files]'
+ '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]'
+ '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]'
+ '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]'
+ '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]'
+ '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]'
+ '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix'
+ '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories'
+ '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]'
+ '(-v --verbose)'{-v,--verbose}'[print name of each linked file]'
+ '--help[display usage information and exit]'
+ '--version[display version information and exit]')
+elif (( ${+builtins[ln]} )); then
+ args+=(
+ '-d[attempt to hard link directories]'
+ {-h,-n}'[do not dereference destination]'
+ '-i[prompt before removing destination files]')
+elif [[ $OSTYPE == darwin* ]]; then
+ args+=(
+ '-F[remove existing destination directories]'
+ {-h,-n}'[do not dereference destination]'
+ '-i[prompt before removing destination files]'
+ '-v[print name of each linked file]')
+fi
+
+_arguments -s $opts \
+ $args \
+ ':link target:_files' \
+ '*:: :->files' && ret=0
+
+case $state in
+ (files)
+ if [[ $variant == gnu && -n ${opt_args[(I)-t|--target-directory]} ]]; then
+ _wanted files expl 'link target' _files && ret=0
+ else
+ if (( CURRENT == 2 )); then
+ local expl
+ _wanted files expl 'additional link target or link name' _files && ret=0
+ else
+ _alternative \
+ 'link-targets:additional link target:_files' \
+ 'target-directories:target directory:_directories' && ret=0
+ fi
+ fi
+ ;;
+esac
+
+return ret