zsh-users
 help / color / mirror / code / Atom feed
* Errors with my youtube-dl function in ~/.zshrc but I am unsure why
@ 2015-08-16  6:32 John
  2015-08-16  6:44 ` Eric Cook
  0 siblings, 1 reply; 9+ messages in thread
From: John @ 2015-08-16  6:32 UTC (permalink / raw)
  To: zsh-users

Why does zsh complain about no matches when I invoke my yt function and how can I correct the code?  Thanks!

>From ~/.zshrc:
 yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1" &; }

Output of command:
 % yt https://www.youtube.com/watch?v=OC1JiAUr3ZU                                                     :(
 zsh: no matches found: https://www.youtube.com/watch?v=OC1JiAUr3ZU

Please note that I am not subscribed to the ML so please cc me in the reply.


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16  6:32 Errors with my youtube-dl function in ~/.zshrc but I am unsure why John
@ 2015-08-16  6:44 ` Eric Cook
  2015-08-16  6:54   ` John
  0 siblings, 1 reply; 9+ messages in thread
From: Eric Cook @ 2015-08-16  6:44 UTC (permalink / raw)
  To: zsh-users; +Cc: da_audiophile

On 08/16/2015 02:32 AM, John wrote:
> Why does zsh complain about no matches when I invoke my yt function and how can I correct the code?  Thanks!
> 
> From ~/.zshrc:
>  yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1" &; }
> 
> Output of command:
>  % yt https://www.youtube.com/watch?v=OC1JiAUr3ZU                                                     :(
>  zsh: no matches found: https://www.youtube.com/watch?v=OC1JiAUr3ZU
> 
> Please note that I am not subscribed to the ML so please cc me in the reply.
> 
You have to call the function with noglob to prevent zsh from thinking ? is a pattern character.

so:
% noglob yt https://www.youtube.com/watch?v=OC1JiAUr3ZU


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16  6:44 ` Eric Cook
@ 2015-08-16  6:54   ` John
  2015-08-16 16:37     ` Bart Schaefer
  2015-08-16 16:43     ` Gowtham M
  0 siblings, 2 replies; 9+ messages in thread
From: John @ 2015-08-16  6:54 UTC (permalink / raw)
  To: Eric Cook, zsh-users





----- Original Message -----
> From: Eric Cook <llua@gmx.com>
> To: zsh-users@zsh.org
> Cc: da_audiophile@yahoo.com
> Sent: Sunday, August 16, 2015 2:44 AM
> Subject: Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
> 
> On 08/16/2015 02:32 AM, John wrote:
>>  Why does zsh complain about no matches when I invoke my yt function and how 
> can I correct the code?  Thanks!
>> 
>>  From ~/.zshrc:
>>   yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1" 
> &; }
>> 
>>  Output of command:
>>   % yt https://www.youtube.com/watch?v=OC1JiAUr3ZU                           
>                           :(
>>   zsh: no matches found: https://www.youtube.com/watch?v=OC1JiAUr3ZU
>> 
>>  Please note that I am not subscribed to the ML so please cc me in the 
> reply.
>> 
> You have to call the function with noglob to prevent zsh from thinking ? is a 
> pattern character.
> 
> so:
> % noglob yt https://www.youtube.com/watch?v=OC1JiAUr3ZU
> 

Thank you for the reply.  In the past (month ago), this function worked as-is calling the command prefixed by noglob as you recommended.  Is there any way I can roll it into the function?


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16  6:54   ` John
@ 2015-08-16 16:37     ` Bart Schaefer
  2015-08-16 16:43       ` John
  2015-08-17 21:58       ` zzapper
  2015-08-16 16:43     ` Gowtham M
  1 sibling, 2 replies; 9+ messages in thread
From: Bart Schaefer @ 2015-08-16 16:37 UTC (permalink / raw)
  To: zsh-users, John

} In the past (month ago), this function worked as-is calling the
} command prefixed by noglob as you recommended. Is there any way I can
} roll it into the function?

Do you mean it previously worked WITHOUT prefixing by noglob?

Has the version of zsh you are using changed during that time?

The easiest thing to do is this:

    yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1" &; }
    alias yt='noglob yt'

Note you want the alias declaration after the function definition.

There's no way to include it inside the function itself because the
glob is attempted before the function is called.


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16 16:37     ` Bart Schaefer
@ 2015-08-16 16:43       ` John
  2015-08-16 17:23         ` Bart Schaefer
  2015-08-17 21:58       ` zzapper
  1 sibling, 1 reply; 9+ messages in thread
From: John @ 2015-08-16 16:43 UTC (permalink / raw)
  To: Bart Schaefer, zsh-users





----- Original Message -----
> From: Bart Schaefer <schaefer@brasslantern.com>
> To: "zsh-users@zsh.org" <zsh-users@zsh.org>; John <da_audiophile@yahoo.com>
> Cc: 
> Sent: Sunday, August 16, 2015 12:37 PM
> Subject: Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
> 
> } In the past (month ago), this function worked as-is calling the
> } command prefixed by noglob as you recommended. Is there any way I can
> } roll it into the function?
> 
> Do you mean it previously worked WITHOUT prefixing by noglob?
> 
> Has the version of zsh you are using changed during that time?
> 
> 
> The easiest thing to do is this:
> 
>     yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1" 
> &; }
>     alias yt='noglob yt'


Excellent, thank you.  Yes, it did work as the function only some months ago (I rarely use it but found that it wasn't working now).  Zsh on my distro has updated since then (now running 5.08).  Minor note, I removed the noglob in the function so the relevant lines read:

 yt() { [[ -z "$1" ]] || youtube-dl -q "$1" &; }
 alias yt='noglob yt'


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16  6:54   ` John
  2015-08-16 16:37     ` Bart Schaefer
@ 2015-08-16 16:43     ` Gowtham M
  2015-08-16 21:54       ` Mikael Magnusson
  1 sibling, 1 reply; 9+ messages in thread
From: Gowtham M @ 2015-08-16 16:43 UTC (permalink / raw)
  To: zsh-users; +Cc: John

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

Not a direct answer, but youtube-dl works with the video id also, like:
% yt OC1JiAUr3ZU

You may also "setopt nonomatch" to make zsh leave the argument unchanged if
no files match. Although, be warned that it might have some side effects.

Hope this helps.

- Gowtham

On Sun, Aug 16, 2015 at 12:24 PM, John <da_audiophile@yahoo.com> wrote:

>
>
>
>
> ----- Original Message -----
> > From: Eric Cook <llua@gmx.com>
> > To: zsh-users@zsh.org
> > Cc: da_audiophile@yahoo.com
> > Sent: Sunday, August 16, 2015 2:44 AM
> > Subject: Re: Errors with my youtube-dl function in ~/.zshrc but I am
> unsure why
> >
> > On 08/16/2015 02:32 AM, John wrote:
> >>  Why does zsh complain about no matches when I invoke my yt function
> and how
> > can I correct the code?  Thanks!
> >>
> >>  From ~/.zshrc:
> >>   yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1"
> > &; }
> >>
> >>  Output of command:
> >>   % yt https://www.youtube.com/watch?v=OC1JiAUr3ZU
> >                           :(
> >>   zsh: no matches found: https://www.youtube.com/watch?v=OC1JiAUr3ZU
> >>
> >>  Please note that I am not subscribed to the ML so please cc me in the
> > reply.
> >>
> > You have to call the function with noglob to prevent zsh from thinking ?
> is a
> > pattern character.
> >
> > so:
> > % noglob yt https://www.youtube.com/watch?v=OC1JiAUr3ZU
> >
>
> Thank you for the reply.  In the past (month ago), this function worked
> as-is calling the command prefixed by noglob as you recommended.  Is there
> any way I can roll it into the function?
>

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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16 16:43       ` John
@ 2015-08-16 17:23         ` Bart Schaefer
  0 siblings, 0 replies; 9+ messages in thread
From: Bart Schaefer @ 2015-08-16 17:23 UTC (permalink / raw)
  To: John, zsh-users@zsh.org 

On Aug 16,  4:43pm, John wrote:
}
} Yes, it did work as the function only some months ago [...] Zsh on my
} distro has updated since then (now running 5.08).

Is there a possibility that (a) you copy-pasted the URL into the command
line (b) you have self-insert bound to the url-quote-magic function and
(c) your distro version of zsh is using a recent development snapshot
that has the bracketed-paste widgets enabled, so url-quote-magic doesn't
work for pasted text any more?

} Minor note, I removed the noglob in the function

Yes, that's fine.  I just copied the function without editing it when I
wrote my previous reply, didn't even notice you had noglob in there.


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16 16:43     ` Gowtham M
@ 2015-08-16 21:54       ` Mikael Magnusson
  0 siblings, 0 replies; 9+ messages in thread
From: Mikael Magnusson @ 2015-08-16 21:54 UTC (permalink / raw)
  To: Gowtham M; +Cc: zsh-users, John

On Sun, Aug 16, 2015 at 6:43 PM, Gowtham M <gowthamgowtham@gmail.com> wrote:
> Not a direct answer, but youtube-dl works with the video id also, like:
> % yt OC1JiAUr3ZU
>
> You may also "setopt nonomatch" to make zsh leave the argument unchanged if
> no files match. Although, be warned that it might have some side effects.

A sidenote to this sidenote, the above doesn't work if the id starts
with a - :).

-- 
Mikael Magnusson


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

* Re: Errors with my youtube-dl function in ~/.zshrc but I am unsure why
  2015-08-16 16:37     ` Bart Schaefer
  2015-08-16 16:43       ` John
@ 2015-08-17 21:58       ` zzapper
  1 sibling, 0 replies; 9+ messages in thread
From: zzapper @ 2015-08-17 21:58 UTC (permalink / raw)
  To: zsh-users

Bart Schaefer <schaefer@brasslantern.com> wrote in 
news:150816093722.ZM12415@torch.brasslantern.com:


> 
> The easiest thing to do is this:
> 
>     yt() { [[ -z "$1" ]] || noglob youtube-dl -q "$1" &; }
>     alias yt='noglob yt'
> 
BTW for those like me that had never heard of youtube-dl

https://rg3.github.io/youtube-dl/


-- 
zzapper
https://twitter.com/dailyzshtip

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



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

end of thread, other threads:[~2015-08-17 21:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-16  6:32 Errors with my youtube-dl function in ~/.zshrc but I am unsure why John
2015-08-16  6:44 ` Eric Cook
2015-08-16  6:54   ` John
2015-08-16 16:37     ` Bart Schaefer
2015-08-16 16:43       ` John
2015-08-16 17:23         ` Bart Schaefer
2015-08-17 21:58       ` zzapper
2015-08-16 16:43     ` Gowtham M
2015-08-16 21:54       ` Mikael Magnusson

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).