Jump to last prompt in terminal (or tmux)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite
1












In a terminal, are there any shortcuts to jump to a previous/next prompt? Scrolling up and trying to find the start of a log slows down my workflow.



I'm using iTerm on OSX, but this should be applicable to any Unix terminals. A solution in Tmux would help as well.










share|improve this question























  • If your hostname is in your prompt, you could reverse search to cycle back that way...
    – jasonwryan
    Feb 13 '16 at 22:08










  • Pipe to less.
    – Kusalananda
    Jul 30 '16 at 10:10














up vote
7
down vote

favorite
1












In a terminal, are there any shortcuts to jump to a previous/next prompt? Scrolling up and trying to find the start of a log slows down my workflow.



I'm using iTerm on OSX, but this should be applicable to any Unix terminals. A solution in Tmux would help as well.










share|improve this question























  • If your hostname is in your prompt, you could reverse search to cycle back that way...
    – jasonwryan
    Feb 13 '16 at 22:08










  • Pipe to less.
    – Kusalananda
    Jul 30 '16 at 10:10












up vote
7
down vote

favorite
1









up vote
7
down vote

favorite
1






1





In a terminal, are there any shortcuts to jump to a previous/next prompt? Scrolling up and trying to find the start of a log slows down my workflow.



I'm using iTerm on OSX, but this should be applicable to any Unix terminals. A solution in Tmux would help as well.










share|improve this question















In a terminal, are there any shortcuts to jump to a previous/next prompt? Scrolling up and trying to find the start of a log slows down my workflow.



I'm using iTerm on OSX, but this should be applicable to any Unix terminals. A solution in Tmux would help as well.







terminal tmux scrolling






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 13 '16 at 21:53









sendmoreinfo

1,7391130




1,7391130










asked Sep 1 '15 at 6:31









domi91c

21927




21927











  • If your hostname is in your prompt, you could reverse search to cycle back that way...
    – jasonwryan
    Feb 13 '16 at 22:08










  • Pipe to less.
    – Kusalananda
    Jul 30 '16 at 10:10
















  • If your hostname is in your prompt, you could reverse search to cycle back that way...
    – jasonwryan
    Feb 13 '16 at 22:08










  • Pipe to less.
    – Kusalananda
    Jul 30 '16 at 10:10















If your hostname is in your prompt, you could reverse search to cycle back that way...
– jasonwryan
Feb 13 '16 at 22:08




If your hostname is in your prompt, you could reverse search to cycle back that way...
– jasonwryan
Feb 13 '16 at 22:08












Pipe to less.
– Kusalananda
Jul 30 '16 at 10:10




Pipe to less.
– Kusalananda
Jul 30 '16 at 10:10










2 Answers
2






active

oldest

votes

















up vote
3
down vote













Inside tmux v2.4+
(relevant commit), you can define a binding to jump to the last prompts with acceptable reliability:



bind-key b copy-mode;
send-keys -X start-of-line;
send-keys -X search-backward " "


Where the " " is a non-breaking space and a corresponding change is made to have you shell prompt contain it ($PS1 or $PROMPT_COMMAND in bash).



It may require special care to set it in the shell prompt and the tmux configuration, as it could be changed to regular space during copy-paste operations (see method with vim in the comments).



Alternatively, you can try your favorite alternative unicode space character or anything that occurs rarely in command outputs and that you're ready to accept seeing in your prompt (🍌?).



This could also be a combination of several characters for even less false positives. It's probably better to pick something at the very end of the prompt, though, for easier navigation.



Credit:




  • https://github.com/salcode/ironcode-tmux/issues/21 for the use of the non-breaking space and the binding. I first thought this could be a use case of the zero-width space but it did not seem to work.


  • robenk for pointing out that copy-pasting weird character spaces is not always reliable





share|improve this answer


















  • 1




    Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
    – robenk
    Dec 5 at 23:58


















up vote
0
down vote













If you use less to view the contents of the log file, you have the ability to scroll back and forth using the Space and b keys (see the less manual). You may also perform searches in the output with / (and ? for backward search).



To view the output from a program in less, simply pipe the output to it:



$ ./myprogram | less


To additionally save the output in a file:



$ ./myprogram | tee myprogram.out | less


If you press F while reading a file that's being written to, less will behave like tail -f. To interrupt this, press Ctrl+c.






share|improve this answer




















    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',
    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%2f226731%2fjump-to-last-prompt-in-terminal-or-tmux%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    3
    down vote













    Inside tmux v2.4+
    (relevant commit), you can define a binding to jump to the last prompts with acceptable reliability:



    bind-key b copy-mode;
    send-keys -X start-of-line;
    send-keys -X search-backward " "


    Where the " " is a non-breaking space and a corresponding change is made to have you shell prompt contain it ($PS1 or $PROMPT_COMMAND in bash).



    It may require special care to set it in the shell prompt and the tmux configuration, as it could be changed to regular space during copy-paste operations (see method with vim in the comments).



    Alternatively, you can try your favorite alternative unicode space character or anything that occurs rarely in command outputs and that you're ready to accept seeing in your prompt (🍌?).



    This could also be a combination of several characters for even less false positives. It's probably better to pick something at the very end of the prompt, though, for easier navigation.



    Credit:




    • https://github.com/salcode/ironcode-tmux/issues/21 for the use of the non-breaking space and the binding. I first thought this could be a use case of the zero-width space but it did not seem to work.


    • robenk for pointing out that copy-pasting weird character spaces is not always reliable





    share|improve this answer


















    • 1




      Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
      – robenk
      Dec 5 at 23:58















    up vote
    3
    down vote













    Inside tmux v2.4+
    (relevant commit), you can define a binding to jump to the last prompts with acceptable reliability:



    bind-key b copy-mode;
    send-keys -X start-of-line;
    send-keys -X search-backward " "


    Where the " " is a non-breaking space and a corresponding change is made to have you shell prompt contain it ($PS1 or $PROMPT_COMMAND in bash).



    It may require special care to set it in the shell prompt and the tmux configuration, as it could be changed to regular space during copy-paste operations (see method with vim in the comments).



    Alternatively, you can try your favorite alternative unicode space character or anything that occurs rarely in command outputs and that you're ready to accept seeing in your prompt (🍌?).



    This could also be a combination of several characters for even less false positives. It's probably better to pick something at the very end of the prompt, though, for easier navigation.



    Credit:




    • https://github.com/salcode/ironcode-tmux/issues/21 for the use of the non-breaking space and the binding. I first thought this could be a use case of the zero-width space but it did not seem to work.


    • robenk for pointing out that copy-pasting weird character spaces is not always reliable





    share|improve this answer


















    • 1




      Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
      – robenk
      Dec 5 at 23:58













    up vote
    3
    down vote










    up vote
    3
    down vote









    Inside tmux v2.4+
    (relevant commit), you can define a binding to jump to the last prompts with acceptable reliability:



    bind-key b copy-mode;
    send-keys -X start-of-line;
    send-keys -X search-backward " "


    Where the " " is a non-breaking space and a corresponding change is made to have you shell prompt contain it ($PS1 or $PROMPT_COMMAND in bash).



    It may require special care to set it in the shell prompt and the tmux configuration, as it could be changed to regular space during copy-paste operations (see method with vim in the comments).



    Alternatively, you can try your favorite alternative unicode space character or anything that occurs rarely in command outputs and that you're ready to accept seeing in your prompt (🍌?).



    This could also be a combination of several characters for even less false positives. It's probably better to pick something at the very end of the prompt, though, for easier navigation.



    Credit:




    • https://github.com/salcode/ironcode-tmux/issues/21 for the use of the non-breaking space and the binding. I first thought this could be a use case of the zero-width space but it did not seem to work.


    • robenk for pointing out that copy-pasting weird character spaces is not always reliable





    share|improve this answer














    Inside tmux v2.4+
    (relevant commit), you can define a binding to jump to the last prompts with acceptable reliability:



    bind-key b copy-mode;
    send-keys -X start-of-line;
    send-keys -X search-backward " "


    Where the " " is a non-breaking space and a corresponding change is made to have you shell prompt contain it ($PS1 or $PROMPT_COMMAND in bash).



    It may require special care to set it in the shell prompt and the tmux configuration, as it could be changed to regular space during copy-paste operations (see method with vim in the comments).



    Alternatively, you can try your favorite alternative unicode space character or anything that occurs rarely in command outputs and that you're ready to accept seeing in your prompt (🍌?).



    This could also be a combination of several characters for even less false positives. It's probably better to pick something at the very end of the prompt, though, for easier navigation.



    Credit:




    • https://github.com/salcode/ironcode-tmux/issues/21 for the use of the non-breaking space and the binding. I first thought this could be a use case of the zero-width space but it did not seem to work.


    • robenk for pointing out that copy-pasting weird character spaces is not always reliable






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 6 at 11:10

























    answered Mar 23 '17 at 20:09









    lbonn

    1336




    1336







    • 1




      Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
      – robenk
      Dec 5 at 23:58













    • 1




      Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
      – robenk
      Dec 5 at 23:58








    1




    1




    Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
    – robenk
    Dec 5 at 23:58





    Cutting and pasting would not get the non-breaking space character to work for me, but I was able to get it to work using Vim. In insert mode, use CTRL-k <space><space> to insert the non-breaking space. Then afterwords, in normal mode, the ga command prints the ASCII value of the character under the cursor which can be used to confirm this character is different from other spaces.
    – robenk
    Dec 5 at 23:58













    up vote
    0
    down vote













    If you use less to view the contents of the log file, you have the ability to scroll back and forth using the Space and b keys (see the less manual). You may also perform searches in the output with / (and ? for backward search).



    To view the output from a program in less, simply pipe the output to it:



    $ ./myprogram | less


    To additionally save the output in a file:



    $ ./myprogram | tee myprogram.out | less


    If you press F while reading a file that's being written to, less will behave like tail -f. To interrupt this, press Ctrl+c.






    share|improve this answer
























      up vote
      0
      down vote













      If you use less to view the contents of the log file, you have the ability to scroll back and forth using the Space and b keys (see the less manual). You may also perform searches in the output with / (and ? for backward search).



      To view the output from a program in less, simply pipe the output to it:



      $ ./myprogram | less


      To additionally save the output in a file:



      $ ./myprogram | tee myprogram.out | less


      If you press F while reading a file that's being written to, less will behave like tail -f. To interrupt this, press Ctrl+c.






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        If you use less to view the contents of the log file, you have the ability to scroll back and forth using the Space and b keys (see the less manual). You may also perform searches in the output with / (and ? for backward search).



        To view the output from a program in less, simply pipe the output to it:



        $ ./myprogram | less


        To additionally save the output in a file:



        $ ./myprogram | tee myprogram.out | less


        If you press F while reading a file that's being written to, less will behave like tail -f. To interrupt this, press Ctrl+c.






        share|improve this answer












        If you use less to view the contents of the log file, you have the ability to scroll back and forth using the Space and b keys (see the less manual). You may also perform searches in the output with / (and ? for backward search).



        To view the output from a program in less, simply pipe the output to it:



        $ ./myprogram | less


        To additionally save the output in a file:



        $ ./myprogram | tee myprogram.out | less


        If you press F while reading a file that's being written to, less will behave like tail -f. To interrupt this, press Ctrl+c.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 29 '16 at 16:41









        Kusalananda

        120k16225369




        120k16225369



























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f226731%2fjump-to-last-prompt-in-terminal-or-tmux%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

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?