What does (arg: n) in the command prompt mean?












10















On Codecademy's Command Line Course, when trying to use the keyboard shortcut Alt+Shift+# (which is supposed to comment the current line) in the command prompt, it switches the prompt from $ to (arg: 3) instead of adding a dash at the beginning of the line. Alt+Shift+@ will make it display (arg: 2) instead, etc.
See the last line in the screenshot below. Before I hit Alt+Shift+# it was just $.



screenshot



The shortcut works fine on my machine.




  1. What is this (arg: n) thing?

  2. What do keyboard shortcuts depend on to work? Keyboard layout? OS distro? Terminal emulator? Default CLI? What?










share|improve this question





























    10















    On Codecademy's Command Line Course, when trying to use the keyboard shortcut Alt+Shift+# (which is supposed to comment the current line) in the command prompt, it switches the prompt from $ to (arg: 3) instead of adding a dash at the beginning of the line. Alt+Shift+@ will make it display (arg: 2) instead, etc.
    See the last line in the screenshot below. Before I hit Alt+Shift+# it was just $.



    screenshot



    The shortcut works fine on my machine.




    1. What is this (arg: n) thing?

    2. What do keyboard shortcuts depend on to work? Keyboard layout? OS distro? Terminal emulator? Default CLI? What?










    share|improve this question



























      10












      10








      10


      1






      On Codecademy's Command Line Course, when trying to use the keyboard shortcut Alt+Shift+# (which is supposed to comment the current line) in the command prompt, it switches the prompt from $ to (arg: 3) instead of adding a dash at the beginning of the line. Alt+Shift+@ will make it display (arg: 2) instead, etc.
      See the last line in the screenshot below. Before I hit Alt+Shift+# it was just $.



      screenshot



      The shortcut works fine on my machine.




      1. What is this (arg: n) thing?

      2. What do keyboard shortcuts depend on to work? Keyboard layout? OS distro? Terminal emulator? Default CLI? What?










      share|improve this question
















      On Codecademy's Command Line Course, when trying to use the keyboard shortcut Alt+Shift+# (which is supposed to comment the current line) in the command prompt, it switches the prompt from $ to (arg: 3) instead of adding a dash at the beginning of the line. Alt+Shift+@ will make it display (arg: 2) instead, etc.
      See the last line in the screenshot below. Before I hit Alt+Shift+# it was just $.



      screenshot



      The shortcut works fine on my machine.




      1. What is this (arg: n) thing?

      2. What do keyboard shortcuts depend on to work? Keyboard layout? OS distro? Terminal emulator? Default CLI? What?







      keyboard-shortcuts block-comment






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 14 at 9:38







      user331380

















      asked Jan 14 at 9:30









      user331380user331380

      535




      535






















          1 Answer
          1






          active

          oldest

          votes


















          15














          This is the readline library’s prompt when you’re inputting a numeric argument. By typing AltShift@ on your keyboard, you’re apparently entering Alt2 which maps to M-2, which runs digit-argument in readline by default, and starts entering a numeric argument. If you then press Alt3 (which AltShift# maps to in your case) you’ll see the prompt change to (arg: 23); you can continue with any Alt-digit combination.



          These arguments are used for certain readline functions, for example yank-nth-arg. To see this in action, run



          echo Hello my friend


          then press Alt2 followed by CtrlAltY; you’ll see the (arg: 2) prompt appear, then disappear, and the second argument of the previous command (“my”) will be appended to your current command line.



          See the linked documentation above for details. Bash uses readline to handle its input; other shells won’t show the same behaviour.



          Some terminal emulators use some of these key combinations for their own purposes; for example in GNOME Terminal, Alt-digit switches to the nth tab. You’ll need to disable these combinations to use the readline functions.



          In your case, the Codecademy web-based terminal emulator doesn’t seem to handle AltShift combinations very well. If you don’t need the numeric argument shortcuts, you can repurpose them by running



          bind Meta-3:insert-comment


          In theory you should be able to store this permanently by adding



          Meta-3: insert-comment


          to an ~/.inputrc file, but I couldn’t get that to work on Codecademy.






          share|improve this answer





















          • 1





            Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

            – user331380
            Jan 14 at 10:17











          • What terminal emulator are you using?

            – Stephen Kitt
            Jan 14 at 10:39











          • I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

            – user331380
            Jan 14 at 10:47






          • 1





            @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

            – Sergiy Kolodyazhnyy
            Jan 14 at 17:08











          • Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

            – JoL
            Jan 14 at 18:31













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f494378%2fwhat-does-arg-n-in-the-command-prompt-mean%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          15














          This is the readline library’s prompt when you’re inputting a numeric argument. By typing AltShift@ on your keyboard, you’re apparently entering Alt2 which maps to M-2, which runs digit-argument in readline by default, and starts entering a numeric argument. If you then press Alt3 (which AltShift# maps to in your case) you’ll see the prompt change to (arg: 23); you can continue with any Alt-digit combination.



          These arguments are used for certain readline functions, for example yank-nth-arg. To see this in action, run



          echo Hello my friend


          then press Alt2 followed by CtrlAltY; you’ll see the (arg: 2) prompt appear, then disappear, and the second argument of the previous command (“my”) will be appended to your current command line.



          See the linked documentation above for details. Bash uses readline to handle its input; other shells won’t show the same behaviour.



          Some terminal emulators use some of these key combinations for their own purposes; for example in GNOME Terminal, Alt-digit switches to the nth tab. You’ll need to disable these combinations to use the readline functions.



          In your case, the Codecademy web-based terminal emulator doesn’t seem to handle AltShift combinations very well. If you don’t need the numeric argument shortcuts, you can repurpose them by running



          bind Meta-3:insert-comment


          In theory you should be able to store this permanently by adding



          Meta-3: insert-comment


          to an ~/.inputrc file, but I couldn’t get that to work on Codecademy.






          share|improve this answer





















          • 1





            Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

            – user331380
            Jan 14 at 10:17











          • What terminal emulator are you using?

            – Stephen Kitt
            Jan 14 at 10:39











          • I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

            – user331380
            Jan 14 at 10:47






          • 1





            @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

            – Sergiy Kolodyazhnyy
            Jan 14 at 17:08











          • Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

            – JoL
            Jan 14 at 18:31


















          15














          This is the readline library’s prompt when you’re inputting a numeric argument. By typing AltShift@ on your keyboard, you’re apparently entering Alt2 which maps to M-2, which runs digit-argument in readline by default, and starts entering a numeric argument. If you then press Alt3 (which AltShift# maps to in your case) you’ll see the prompt change to (arg: 23); you can continue with any Alt-digit combination.



          These arguments are used for certain readline functions, for example yank-nth-arg. To see this in action, run



          echo Hello my friend


          then press Alt2 followed by CtrlAltY; you’ll see the (arg: 2) prompt appear, then disappear, and the second argument of the previous command (“my”) will be appended to your current command line.



          See the linked documentation above for details. Bash uses readline to handle its input; other shells won’t show the same behaviour.



          Some terminal emulators use some of these key combinations for their own purposes; for example in GNOME Terminal, Alt-digit switches to the nth tab. You’ll need to disable these combinations to use the readline functions.



          In your case, the Codecademy web-based terminal emulator doesn’t seem to handle AltShift combinations very well. If you don’t need the numeric argument shortcuts, you can repurpose them by running



          bind Meta-3:insert-comment


          In theory you should be able to store this permanently by adding



          Meta-3: insert-comment


          to an ~/.inputrc file, but I couldn’t get that to work on Codecademy.






          share|improve this answer





















          • 1





            Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

            – user331380
            Jan 14 at 10:17











          • What terminal emulator are you using?

            – Stephen Kitt
            Jan 14 at 10:39











          • I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

            – user331380
            Jan 14 at 10:47






          • 1





            @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

            – Sergiy Kolodyazhnyy
            Jan 14 at 17:08











          • Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

            – JoL
            Jan 14 at 18:31
















          15












          15








          15







          This is the readline library’s prompt when you’re inputting a numeric argument. By typing AltShift@ on your keyboard, you’re apparently entering Alt2 which maps to M-2, which runs digit-argument in readline by default, and starts entering a numeric argument. If you then press Alt3 (which AltShift# maps to in your case) you’ll see the prompt change to (arg: 23); you can continue with any Alt-digit combination.



          These arguments are used for certain readline functions, for example yank-nth-arg. To see this in action, run



          echo Hello my friend


          then press Alt2 followed by CtrlAltY; you’ll see the (arg: 2) prompt appear, then disappear, and the second argument of the previous command (“my”) will be appended to your current command line.



          See the linked documentation above for details. Bash uses readline to handle its input; other shells won’t show the same behaviour.



          Some terminal emulators use some of these key combinations for their own purposes; for example in GNOME Terminal, Alt-digit switches to the nth tab. You’ll need to disable these combinations to use the readline functions.



          In your case, the Codecademy web-based terminal emulator doesn’t seem to handle AltShift combinations very well. If you don’t need the numeric argument shortcuts, you can repurpose them by running



          bind Meta-3:insert-comment


          In theory you should be able to store this permanently by adding



          Meta-3: insert-comment


          to an ~/.inputrc file, but I couldn’t get that to work on Codecademy.






          share|improve this answer















          This is the readline library’s prompt when you’re inputting a numeric argument. By typing AltShift@ on your keyboard, you’re apparently entering Alt2 which maps to M-2, which runs digit-argument in readline by default, and starts entering a numeric argument. If you then press Alt3 (which AltShift# maps to in your case) you’ll see the prompt change to (arg: 23); you can continue with any Alt-digit combination.



          These arguments are used for certain readline functions, for example yank-nth-arg. To see this in action, run



          echo Hello my friend


          then press Alt2 followed by CtrlAltY; you’ll see the (arg: 2) prompt appear, then disappear, and the second argument of the previous command (“my”) will be appended to your current command line.



          See the linked documentation above for details. Bash uses readline to handle its input; other shells won’t show the same behaviour.



          Some terminal emulators use some of these key combinations for their own purposes; for example in GNOME Terminal, Alt-digit switches to the nth tab. You’ll need to disable these combinations to use the readline functions.



          In your case, the Codecademy web-based terminal emulator doesn’t seem to handle AltShift combinations very well. If you don’t need the numeric argument shortcuts, you can repurpose them by running



          bind Meta-3:insert-comment


          In theory you should be able to store this permanently by adding



          Meta-3: insert-comment


          to an ~/.inputrc file, but I couldn’t get that to work on Codecademy.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 14 at 11:04

























          answered Jan 14 at 10:01









          Stephen KittStephen Kitt

          168k24378456




          168k24378456








          • 1





            Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

            – user331380
            Jan 14 at 10:17











          • What terminal emulator are you using?

            – Stephen Kitt
            Jan 14 at 10:39











          • I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

            – user331380
            Jan 14 at 10:47






          • 1





            @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

            – Sergiy Kolodyazhnyy
            Jan 14 at 17:08











          • Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

            – JoL
            Jan 14 at 18:31
















          • 1





            Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

            – user331380
            Jan 14 at 10:17











          • What terminal emulator are you using?

            – Stephen Kitt
            Jan 14 at 10:39











          • I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

            – user331380
            Jan 14 at 10:47






          • 1





            @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

            – Sergiy Kolodyazhnyy
            Jan 14 at 17:08











          • Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

            – JoL
            Jan 14 at 18:31










          1




          1





          Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

          – user331380
          Jan 14 at 10:17





          Thank you. How do I disable readline or otherwise just use a keyboard shortcut to comment the current command line?

          – user331380
          Jan 14 at 10:17













          What terminal emulator are you using?

          – Stephen Kitt
          Jan 14 at 10:39





          What terminal emulator are you using?

          – Stephen Kitt
          Jan 14 at 10:39













          I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

          – user331380
          Jan 14 at 10:47





          I want to know how to do it on Codecademy, I don't have a way to right-click and find out. ps -o 'cmd=' -p $(ps -o 'ppid=' -p $$) outputs /usr/local/bin/ein -service-port 4006 -http-port 4007. Does this help?

          – user331380
          Jan 14 at 10:47




          1




          1





          @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

          – Sergiy Kolodyazhnyy
          Jan 14 at 17:08





          @user331380 Likely you are using bash shell on Codeacademy there. In interactive shell, you could start a new instance with bash --noediting. That will disable readline, but keep in mind that readline library is responsible for a lot of line editing features, which may make interactive use of shell slightly more uncomfortable

          – Sergiy Kolodyazhnyy
          Jan 14 at 17:08













          Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

          – JoL
          Jan 14 at 18:31







          Might be worth mentioning that it also happens on vi-keybindings when you simply type the number in normal-mode to represent the numeric argument to the next normal-mode command you type.

          – JoL
          Jan 14 at 18:31




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f494378%2fwhat-does-arg-n-in-the-command-prompt-mean%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

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?