From bd89f38fb79d6229d6c44f06cb1c1c4fd02556ed Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 17 Aug 2015 20:22:20 +0100 Subject: unposted: use of $f in zmv --- ChangeLog | 4 ++++ Doc/Zsh/contrib.yo | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e44a4267c..f3cccbb65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-08-17 Peter Stephenson + + * unposted: Doc/Zsh/contrib.yo: use of $f in zmv. + 2015-08-17 Oliver Kiddle * 36165: Completion/Unix/Type/_files: simplify file-patterns diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 63efaf923..4e87d4116 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -3834,7 +3834,12 @@ The pattern is always treated as an tt(EXTENDED_GLOB) pattern. Any file whose name is not changed by the substitution is simply ignored. Any error (a substitution resulted in an empty string, two substitutions gave the same result, the destination was an existing regular file and tt(-f) -was not given) causes the entire function to abort without doing anything. +was not given) causes the entire function to abort without doing +anything. + +In addition to pattern replacement, the variable tt($f) can be referrred +to in the second (replacement) argument. This makes it possible to +use variable substitution to alter the argument; see examples below. Options: @@ -3883,6 +3888,10 @@ example(zmv -v '(* *)' '${1// /_}') For any file in the current directory with at least one space in the name, replace every space by an underscore and display the commands executed. +example(zmv -v '* *' '${f// /_}') + +This does exactly the same by referring to the file name stored in tt($f). + For more complete examples and other implementation details, see the tt(zmv) source file, usually located in one of the directories named in your tt(fpath), or in tt(Functions/Misc/zmv) in the zsh distribution. -- cgit 1.4.1