0

I would like to mark a vertical position in bash shell.

For example, when I run a programm, I would like to set a mark in the first lines printed, so that when I worked (still under the shell), I just have to press several keys to see the first results of my programm. Think about it the VIM way, you set a mark above the current line (pressing ma), and when you worked a little bit, when you want to see what you previously do you just type 'a.

To be more specific, I run a programm under gdb who gives results over numerous lines. Then I run tests, still in gdb, and I want to check regularly if what I get during debug is still corresponding to the first printed results I got, but I'm not really fond of scrolling up indefinitely.

Is that even possible ?

3
  • Do you mean in the terminal history or in the Bash history?
    – l0b0
    Dec 20, 2013 at 9:57
  • I mean the stdout output, what is printed out in your terminal. To be more specific, I run a programm under gdb who gives results. Then I run tests, still in gdb, and I want to check regularly if what I get during debug is still corresponding to the first lines I got.
    – Bamban
    Dec 20, 2013 at 9:58
  • Please update the question to reflect this information.
    – l0b0
    Dec 20, 2013 at 10:01

2 Answers 2

1

If you want to compare two runs of the same command, make sure you save the first to a file:

$ command > command.log

Then pipe the output of the second command to tee to show and save it at the same time:

$ command | tee command2.log

Now you can diff the two while the second command is running:

$ diff command.log command2.log

(You may want to pipe the diff output to for example head to cut off the possibly large diff resulting from the second command not yet having finished.)

If you're trying to get back to something printed in the terminal history while it's still open, then in several terminals you can press Ctrl-Shift-f to find text.

If you want to find your Bash commands later in time, you can use comments to add tags:

$ my_complicated_remote_command # ssh server thingie

Now you can search with Ctrl-r for "ssh" or "thingie", and the old command comes up.

1
  • Thanks for the answer. Ctrl-Shift-f would have done the trick but I don't have such feature.
    – Bamban
    Dec 20, 2013 at 10:03
0

You can run TMUX and set mode-keys to vi:

set-window-option -g mode-keys vi

Thereafter when you enter copy mode (default is: Ctrl + B) you can use vi bindings to jump around. You can definitely jump to a specific line number and search text but I haven't seen vi mark's working just yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.