zsh-users
 help / color / mirror / code / Atom feed
* Undoing mv foo.txt{,_}
@ 2016-09-06 17:04 René Wilhelm
  2016-09-06 17:17 ` Lawrence Velázquez
  2016-09-07  4:54 ` Vincent Bernat
  0 siblings, 2 replies; 4+ messages in thread
From: René Wilhelm @ 2016-09-06 17:04 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 411 bytes --]

Hello,

what would be a convenient way to remove specified trailing characters of a
string in ZLE?

For example, when I quickly want to add a suffix to a string/filename, I
usually do

mv file.txt{,_}

What's a good way to move file.txt_ back to file.txt, or more general: how
to remove the suffix of a string, without putting it in a variable first
(e.g. a=foo.txt; mv $a $a:r)?

Thanks,
René

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Undoing mv foo.txt{,_}
  2016-09-06 17:04 Undoing mv foo.txt{,_} René Wilhelm
@ 2016-09-06 17:17 ` Lawrence Velázquez
  2016-09-06 17:32   ` René Wilhelm
  2016-09-07  4:54 ` Vincent Bernat
  1 sibling, 1 reply; 4+ messages in thread
From: Lawrence Velázquez @ 2016-09-06 17:17 UTC (permalink / raw)
  To: René Wilhelm; +Cc: zsh-users

> On Sep 6, 2016, at 1:04 PM, René Wilhelm <rene.wilhelm@gmail.com> wrote:
> 
> For example, when I quickly want to add a suffix to a string/filename, I
> usually do
> 
> mv file.txt{,_}
> 
> What's a good way to move file.txt_ back to file.txt

mv file.txt{_,}    ...?

vq


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Undoing mv foo.txt{,_}
  2016-09-06 17:17 ` Lawrence Velázquez
@ 2016-09-06 17:32   ` René Wilhelm
  0 siblings, 0 replies; 4+ messages in thread
From: René Wilhelm @ 2016-09-06 17:32 UTC (permalink / raw)
  To: Lawrence Velázquez; +Cc: Zsh Users

[-- Attachment #1: Type: text/plain, Size: 429 bytes --]

​​
That's it! So obvious, thank you.

On 6 September 2016 at 19:17, Lawrence Velázquez <vq@larryv.me> wrote:

> > On Sep 6, 2016, at 1:04 PM, René Wilhelm <rene.wilhelm@gmail.com> wrote:
> >
> > For example, when I quickly want to add a suffix to a string/filename, I
> > usually do
> >
> > mv file.txt{,_}
> >
> > What's a good way to move file.txt_ back to file.txt
>
> mv file.txt{_,}    ...?
>
> vq
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Undoing mv foo.txt{,_}
  2016-09-06 17:04 Undoing mv foo.txt{,_} René Wilhelm
  2016-09-06 17:17 ` Lawrence Velázquez
@ 2016-09-07  4:54 ` Vincent Bernat
  1 sibling, 0 replies; 4+ messages in thread
From: Vincent Bernat @ 2016-09-07  4:54 UTC (permalink / raw)
  To: René Wilhelm; +Cc: Zsh Users

 ❦  6 septembre 2016 19:04 CEST, René Wilhelm <rene.wilhelm@gmail.com> :

> What's a good way to move file.txt_ back to file.txt, or more general: how
> to remove the suffix of a string, without putting it in a variable first
> (e.g. a=foo.txt; mv $a $a:r)?

About not using a variable, there is the ${:-...} pattern:

echo ${${:-foo.txt}:r}
-- 
Make sure all variables are initialised before use.
            - The Elements of Programming Style (Kernighan & Plauger)


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-07  5:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-06 17:04 Undoing mv foo.txt{,_} René Wilhelm
2016-09-06 17:17 ` Lawrence Velázquez
2016-09-06 17:32   ` René Wilhelm
2016-09-07  4:54 ` Vincent Bernat

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).