Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: removing spaces from a file name
- X-seq: zsh-users 12504
- From: "Mikael Magnusson" <mikachu@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: removing spaces from a file name
- Date: Wed, 30 Jan 2008 12:56:05 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=o45VgzDtnObSA7ZppULJp5bU5w/D0xuKdxRlFvG9K3Q=; b=oAlbqgzoevsUUDhbVWV280RfDmaB3nPPcLv436f5tBpcpTr2Wlmx8FeCgEHfEVy8JiTYkzQ/WoedOozy7o17wPnpX+jBStmtzOBXcVKKl7r5Dx/TsveJkfEKWR0+ZhlbyuE7Me8FqzwVHFC0DlP5ngV2rYeJqLACQ3C/HeL06xo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=itGhz5iFjwag1PF8nxr7jO6A5/QcAL9YBCfAXBMztJ8vIJLxAKBcjZ9xdw2IdcDinmrNf0svpfEqO0Lj05ctdwvECYui0iYZTD3WhbJ6B3xJwZmCU3hITGRryx7p8tEs3LQo5BI8KLl8NWIn+ZuDCHVXMxfZbyQsSQaQqPq7r+c=
- In-reply-to: <237967ef0801300341u1af07b2l1a4aece5614e09dd@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <Xns9A3574A71769Dzzappergmailcom@xxxxxxxxxxxx> <237967ef0801300341u1af07b2l1a4aece5614e09dd@xxxxxxxxxxxxxx>
On 30/01/2008, Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> On 30/01/2008, zzapper <david@xxxxxxxxxx> wrote:
> > Hi
> > I still dislike spaces in file names:-
> >
> > mv Licence\ to\ Print\ Money.pdf !#^:gs/ //
> >
> > Is there a better/other way?
>
> You could define a function in your .zshrc (or make a script in your
> ~/bin or something) that does it for you
> function renamespaces() { for a ($@) {mv $a ${a// } } }
If you're the kind of person who likes keybinds, I guess this works
too, if you have copy-earlier-word bound somewhere too.
autoload -U modify-current-argument
function _stripspaces() { modify-current-argument '${ARG//\\ }' }
zle -N _stripspaces
bindkey 'somekey' _stripspaces
bindkey 'anotherkey' copy-earlier-word
To use it you just type mv file\ with\ spaces as usual, then press
anotherkey and somekey, and you should end up with mv file\ with\
spaces filewithspaces
an obvious weakness of this solution is it depends on the type of
quoting used in the previous word. Maybe better to change to
${(q)${(Q)ARG// }}
The only good thing about this solution is it isn't specific to moving
files, you can use it for cp, ln -s, or whatever you want. That isn't
so hard to achieve with the function now that i think about it:
function nospace() {
cmd=$1
shift
for a ($@) {$cmd $a ${a// } } }
}
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author