Using wildcards in commands with zsh












34















Using commands such as rsync and scp with ZSH I've run into trouble. Instead of the (normal) behaviour of giving me all matching files, it won't run and returns:



➜  ~  rsync -azP user@server:~/* ~/
zsh: no matches found: user@server:~/*


How can I fix this?



My .zshrc



ZSH=$HOME/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git brew)
source $ZSH/oh-my-zsh.sh
export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/sbin









share|improve this question



























    34















    Using commands such as rsync and scp with ZSH I've run into trouble. Instead of the (normal) behaviour of giving me all matching files, it won't run and returns:



    ➜  ~  rsync -azP user@server:~/* ~/
    zsh: no matches found: user@server:~/*


    How can I fix this?



    My .zshrc



    ZSH=$HOME/.oh-my-zsh
    ZSH_THEME="robbyrussell"
    plugins=(git brew)
    source $ZSH/oh-my-zsh.sh
    export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/sbin









    share|improve this question

























      34












      34








      34


      15






      Using commands such as rsync and scp with ZSH I've run into trouble. Instead of the (normal) behaviour of giving me all matching files, it won't run and returns:



      ➜  ~  rsync -azP user@server:~/* ~/
      zsh: no matches found: user@server:~/*


      How can I fix this?



      My .zshrc



      ZSH=$HOME/.oh-my-zsh
      ZSH_THEME="robbyrussell"
      plugins=(git brew)
      source $ZSH/oh-my-zsh.sh
      export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/sbin









      share|improve this question














      Using commands such as rsync and scp with ZSH I've run into trouble. Instead of the (normal) behaviour of giving me all matching files, it won't run and returns:



      ➜  ~  rsync -azP user@server:~/* ~/
      zsh: no matches found: user@server:~/*


      How can I fix this?



      My .zshrc



      ZSH=$HOME/.oh-my-zsh
      ZSH_THEME="robbyrussell"
      plugins=(git brew)
      source $ZSH/oh-my-zsh.sh
      export PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/local/sbin






      macos terminal shell zsh oh-my-zsh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Apr 17 '13 at 20:50









      MorganMorgan

      326159




      326159






















          3 Answers
          3






          active

          oldest

          votes


















          47














          This is related with how ZSH manage globbing characters to generate filenames. By default, ZSH will generate the filenames and throw an error before executing the command if it founds no matches.



          There are many ways to bypass this behavior, here are some of them:




          • The quickest is to enclose the globbing characters with quotes.


          $ rsync -azP "user@server:~/*" ~/



          • For a permanent change, you'll have to add the following in your .zshrc file:


          unsetopt nomatch


          This will prevent ZSH to print an error when no match can be found.




          • Another possibility is to disable globbing for a particular command by using the noglob command modifier. By setting an alias in .zshrc for example:


          alias scp='noglob scp'





          share|improve this answer


























          • Thanks! Never had to do that with bash.

            – Morgan
            Apr 18 '13 at 6:36











          • @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

            – slhck
            Apr 18 '13 at 6:52











          • @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

            – Spack
            Apr 18 '13 at 7:30






          • 1





            @sa125 I've edited my answer.

            – Spack
            Apr 18 '13 at 18:09






          • 1





            @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

            – chepner
            Apr 22 '13 at 18:08





















          5














          I have been using zpretzo for quite a few months and also experienced this issue.
          I came across a neat and useful solution if you don't want to make any changes: simply prepend backslash to the command.



          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          *.*: No such file or directory

          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          jquery.min.js 100% 93KB 92.6KB/s 00:00
          json2.min.js 100% 3377 3.3KB/s 00:00


          I hope this helps!






          share|improve this answer
























          • Great solution!!

            – yorch
            Mar 28 '17 at 0:59











          • Perfect, this worked great for me on OSX!

            – sMyles
            Nov 30 '17 at 19:33



















          2














          This solves your problem without having to manually quote the URLs



          autoload -U url-quote-magic  
          zle -N self-insert url-quote-magic

          # sort it out for SCP
          some_remote_commands=(scp rsync)
          zstyle -e :urlglobber url-other-schema
          '[[ $some_remote_commands[(i)$words[1]] -le ${#some_remote_commands} ]] && reply=("*") || reply=(http https ftp)'





          share|improve this answer
























          • And this goes in .zshrc?

            – Morgan
            Apr 18 '13 at 15:31











          • yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

            – Francisco
            Apr 19 '13 at 11:33













          • you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

            – Francisco
            Apr 19 '13 at 13:28











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f584249%2fusing-wildcards-in-commands-with-zsh%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          47














          This is related with how ZSH manage globbing characters to generate filenames. By default, ZSH will generate the filenames and throw an error before executing the command if it founds no matches.



          There are many ways to bypass this behavior, here are some of them:




          • The quickest is to enclose the globbing characters with quotes.


          $ rsync -azP "user@server:~/*" ~/



          • For a permanent change, you'll have to add the following in your .zshrc file:


          unsetopt nomatch


          This will prevent ZSH to print an error when no match can be found.




          • Another possibility is to disable globbing for a particular command by using the noglob command modifier. By setting an alias in .zshrc for example:


          alias scp='noglob scp'





          share|improve this answer


























          • Thanks! Never had to do that with bash.

            – Morgan
            Apr 18 '13 at 6:36











          • @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

            – slhck
            Apr 18 '13 at 6:52











          • @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

            – Spack
            Apr 18 '13 at 7:30






          • 1





            @sa125 I've edited my answer.

            – Spack
            Apr 18 '13 at 18:09






          • 1





            @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

            – chepner
            Apr 22 '13 at 18:08


















          47














          This is related with how ZSH manage globbing characters to generate filenames. By default, ZSH will generate the filenames and throw an error before executing the command if it founds no matches.



          There are many ways to bypass this behavior, here are some of them:




          • The quickest is to enclose the globbing characters with quotes.


          $ rsync -azP "user@server:~/*" ~/



          • For a permanent change, you'll have to add the following in your .zshrc file:


          unsetopt nomatch


          This will prevent ZSH to print an error when no match can be found.




          • Another possibility is to disable globbing for a particular command by using the noglob command modifier. By setting an alias in .zshrc for example:


          alias scp='noglob scp'





          share|improve this answer


























          • Thanks! Never had to do that with bash.

            – Morgan
            Apr 18 '13 at 6:36











          • @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

            – slhck
            Apr 18 '13 at 6:52











          • @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

            – Spack
            Apr 18 '13 at 7:30






          • 1





            @sa125 I've edited my answer.

            – Spack
            Apr 18 '13 at 18:09






          • 1





            @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

            – chepner
            Apr 22 '13 at 18:08
















          47












          47








          47







          This is related with how ZSH manage globbing characters to generate filenames. By default, ZSH will generate the filenames and throw an error before executing the command if it founds no matches.



          There are many ways to bypass this behavior, here are some of them:




          • The quickest is to enclose the globbing characters with quotes.


          $ rsync -azP "user@server:~/*" ~/



          • For a permanent change, you'll have to add the following in your .zshrc file:


          unsetopt nomatch


          This will prevent ZSH to print an error when no match can be found.




          • Another possibility is to disable globbing for a particular command by using the noglob command modifier. By setting an alias in .zshrc for example:


          alias scp='noglob scp'





          share|improve this answer















          This is related with how ZSH manage globbing characters to generate filenames. By default, ZSH will generate the filenames and throw an error before executing the command if it founds no matches.



          There are many ways to bypass this behavior, here are some of them:




          • The quickest is to enclose the globbing characters with quotes.


          $ rsync -azP "user@server:~/*" ~/



          • For a permanent change, you'll have to add the following in your .zshrc file:


          unsetopt nomatch


          This will prevent ZSH to print an error when no match can be found.




          • Another possibility is to disable globbing for a particular command by using the noglob command modifier. By setting an alias in .zshrc for example:


          alias scp='noglob scp'






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 18 '13 at 18:08

























          answered Apr 17 '13 at 21:07









          SpackSpack

          1,1141010




          1,1141010













          • Thanks! Never had to do that with bash.

            – Morgan
            Apr 18 '13 at 6:36











          • @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

            – slhck
            Apr 18 '13 at 6:52











          • @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

            – Spack
            Apr 18 '13 at 7:30






          • 1





            @sa125 I've edited my answer.

            – Spack
            Apr 18 '13 at 18:09






          • 1





            @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

            – chepner
            Apr 22 '13 at 18:08





















          • Thanks! Never had to do that with bash.

            – Morgan
            Apr 18 '13 at 6:36











          • @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

            – slhck
            Apr 18 '13 at 6:52











          • @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

            – Spack
            Apr 18 '13 at 7:30






          • 1





            @sa125 I've edited my answer.

            – Spack
            Apr 18 '13 at 18:09






          • 1





            @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

            – chepner
            Apr 22 '13 at 18:08



















          Thanks! Never had to do that with bash.

          – Morgan
          Apr 18 '13 at 6:36





          Thanks! Never had to do that with bash.

          – Morgan
          Apr 18 '13 at 6:36













          @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

          – slhck
          Apr 18 '13 at 6:52





          @Morgan That's weird, actually. Without the quotes, Bash should expand the tilde before rsync ever sees it. Could it be that you were just using the same path for the home directory on both servers?

          – slhck
          Apr 18 '13 at 6:52













          @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

          – Spack
          Apr 18 '13 at 7:30





          @slhck No, he's right. zsh has some more options to configure wildcards so this behavior can be changed in the zshrc.

          – Spack
          Apr 18 '13 at 7:30




          1




          1





          @sa125 I've edited my answer.

          – Spack
          Apr 18 '13 at 18:09





          @sa125 I've edited my answer.

          – Spack
          Apr 18 '13 at 18:09




          1




          1





          @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

          – chepner
          Apr 22 '13 at 18:08







          @slhck: bash only expands a tilde when it begins a word, or is the first character following a : or the first = in a variable assignment. Otherwise, it is treated literally.

          – chepner
          Apr 22 '13 at 18:08















          5














          I have been using zpretzo for quite a few months and also experienced this issue.
          I came across a neat and useful solution if you don't want to make any changes: simply prepend backslash to the command.



          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          *.*: No such file or directory

          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          jquery.min.js 100% 93KB 92.6KB/s 00:00
          json2.min.js 100% 3377 3.3KB/s 00:00


          I hope this helps!






          share|improve this answer
























          • Great solution!!

            – yorch
            Mar 28 '17 at 0:59











          • Perfect, this worked great for me on OSX!

            – sMyles
            Nov 30 '17 at 19:33
















          5














          I have been using zpretzo for quite a few months and also experienced this issue.
          I came across a neat and useful solution if you don't want to make any changes: simply prepend backslash to the command.



          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          *.*: No such file or directory

          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          jquery.min.js 100% 93KB 92.6KB/s 00:00
          json2.min.js 100% 3377 3.3KB/s 00:00


          I hope this helps!






          share|improve this answer
























          • Great solution!!

            – yorch
            Mar 28 '17 at 0:59











          • Perfect, this worked great for me on OSX!

            – sMyles
            Nov 30 '17 at 19:33














          5












          5








          5







          I have been using zpretzo for quite a few months and also experienced this issue.
          I came across a neat and useful solution if you don't want to make any changes: simply prepend backslash to the command.



          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          *.*: No such file or directory

          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          jquery.min.js 100% 93KB 92.6KB/s 00:00
          json2.min.js 100% 3377 3.3KB/s 00:00


          I hope this helps!






          share|improve this answer













          I have been using zpretzo for quite a few months and also experienced this issue.
          I came across a neat and useful solution if you don't want to make any changes: simply prepend backslash to the command.



          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          *.*: No such file or directory

          ~/p/b/a/files ❯❯❯ scp *.* myserver@host:~/
          jquery.min.js 100% 93KB 92.6KB/s 00:00
          json2.min.js 100% 3377 3.3KB/s 00:00


          I hope this helps!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 11 '14 at 19:39









          superuseroisuperuseroi

          20127




          20127













          • Great solution!!

            – yorch
            Mar 28 '17 at 0:59











          • Perfect, this worked great for me on OSX!

            – sMyles
            Nov 30 '17 at 19:33



















          • Great solution!!

            – yorch
            Mar 28 '17 at 0:59











          • Perfect, this worked great for me on OSX!

            – sMyles
            Nov 30 '17 at 19:33

















          Great solution!!

          – yorch
          Mar 28 '17 at 0:59





          Great solution!!

          – yorch
          Mar 28 '17 at 0:59













          Perfect, this worked great for me on OSX!

          – sMyles
          Nov 30 '17 at 19:33





          Perfect, this worked great for me on OSX!

          – sMyles
          Nov 30 '17 at 19:33











          2














          This solves your problem without having to manually quote the URLs



          autoload -U url-quote-magic  
          zle -N self-insert url-quote-magic

          # sort it out for SCP
          some_remote_commands=(scp rsync)
          zstyle -e :urlglobber url-other-schema
          '[[ $some_remote_commands[(i)$words[1]] -le ${#some_remote_commands} ]] && reply=("*") || reply=(http https ftp)'





          share|improve this answer
























          • And this goes in .zshrc?

            – Morgan
            Apr 18 '13 at 15:31











          • yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

            – Francisco
            Apr 19 '13 at 11:33













          • you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

            – Francisco
            Apr 19 '13 at 13:28
















          2














          This solves your problem without having to manually quote the URLs



          autoload -U url-quote-magic  
          zle -N self-insert url-quote-magic

          # sort it out for SCP
          some_remote_commands=(scp rsync)
          zstyle -e :urlglobber url-other-schema
          '[[ $some_remote_commands[(i)$words[1]] -le ${#some_remote_commands} ]] && reply=("*") || reply=(http https ftp)'





          share|improve this answer
























          • And this goes in .zshrc?

            – Morgan
            Apr 18 '13 at 15:31











          • yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

            – Francisco
            Apr 19 '13 at 11:33













          • you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

            – Francisco
            Apr 19 '13 at 13:28














          2












          2








          2







          This solves your problem without having to manually quote the URLs



          autoload -U url-quote-magic  
          zle -N self-insert url-quote-magic

          # sort it out for SCP
          some_remote_commands=(scp rsync)
          zstyle -e :urlglobber url-other-schema
          '[[ $some_remote_commands[(i)$words[1]] -le ${#some_remote_commands} ]] && reply=("*") || reply=(http https ftp)'





          share|improve this answer













          This solves your problem without having to manually quote the URLs



          autoload -U url-quote-magic  
          zle -N self-insert url-quote-magic

          # sort it out for SCP
          some_remote_commands=(scp rsync)
          zstyle -e :urlglobber url-other-schema
          '[[ $some_remote_commands[(i)$words[1]] -le ${#some_remote_commands} ]] && reply=("*") || reply=(http https ftp)'






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Apr 18 '13 at 9:40









          FranciscoFrancisco

          1,120815




          1,120815













          • And this goes in .zshrc?

            – Morgan
            Apr 18 '13 at 15:31











          • yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

            – Francisco
            Apr 19 '13 at 11:33













          • you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

            – Francisco
            Apr 19 '13 at 13:28



















          • And this goes in .zshrc?

            – Morgan
            Apr 18 '13 at 15:31











          • yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

            – Francisco
            Apr 19 '13 at 11:33













          • you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

            – Francisco
            Apr 19 '13 at 13:28

















          And this goes in .zshrc?

          – Morgan
          Apr 18 '13 at 15:31





          And this goes in .zshrc?

          – Morgan
          Apr 18 '13 at 15:31













          yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

          – Francisco
          Apr 19 '13 at 11:33







          yes, this goes into your zsh configuration. FWIW, just start a new shell (zsh -f for a canonical shell conf), copy&paste the commands in your shell, and type (or paste) your rsync command. You'll see the magic at work ;-) (special chars at the URL will get automatically quoted)

          – Francisco
          Apr 19 '13 at 11:33















          you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

          – Francisco
          Apr 19 '13 at 13:28





          you should accept my answer :-P this is a lot better than quoting or turning off globing for whole command.

          – Francisco
          Apr 19 '13 at 13:28


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f584249%2fusing-wildcards-in-commands-with-zsh%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Сан-Квентин

          Алькесар

          Josef Freinademetz