2

clear will not work, because that clears your screen. What I am looking to do is just hide, delete, or obfuscate a portion of history on my display in my session, namely a command that I inputted that I do not want the user to see.

So take that as an example; I want to hide what is circled in red, but keep everything above and below it in view.

1
  • 1
    I've edite my answer, and I believe I've found what you need. Obfuscating the portion of terminal without exiting. Please review Sep 29, 2014 at 3:02

2 Answers 2

4

OK, first of I think this is what you need: tput command. Basically it allows user to redraw the screen without closing the session. Look at the screen capture of my terminal window:

enter image description here

Basically, I executed command ls *.c just to fill the screen with something. Then I execute command tput cup 4 0; echo "THIS LINE WILL BE COVERED WITH THIS ALL CAPS TEXT :)" , and that basically places your prompt onto line 4 column 0, and executes echo to cover line 5 row 0. This will stay there even if you scroll back.

Now, suppose you just have executed the command you don't wanna user to see. So for instance, I executed iwconfig, but do not wanna user to see my WI-FI name. I execute command and count which line it is on. In my example the wlan0 ESSID was on line 7, so I execute tput cup 6 4; echo "I DO NOT WANT USER TO SEE THIS PART".

enter image description here

Now pay attention, because this only redraws the screen! The actual command remains in the .bash_history file. After you done with the session, you can re-open the terminal and manually delete the line you do not want. If I execute ls command and scroll back, that part of screen is still obfuscated.

Among other things I've found, tput reset clears screen completely, and if you wanna hide just output, pipe the output into /dev/null. For instance echo "This will never show on screen" > /dev/null

Old answer: In dropdown menu go to Edit -> Profile Preferences -> Scrolling tab.

Change number of Scrollback lines to whatever you desire. The terminal wont scroll back beyond that value of lines you entered in the terminal.

For instance, my terminal window is about 41 lines long, but since I've set it to only 10 lines of scroll back, the terminal does not scroll back at all.

enter image description here

4
  • Thanks for the answer, but I only want to hide what is circled in red, and I'm not using gnome terminal.
    – Anon
    Sep 29, 2014 at 1:36
  • 1
    In that case, please remove the gnome-terminal tag from your question Sep 29, 2014 at 2:25
  • Excellent answer; thanks for taking the time to write a quality post, and figure out the exact issue.
    – Anon
    Sep 29, 2014 at 3:05
  • 1
    My pleasure. I've used tput before, but it kind of escaped my mind at first. In particular , it's been used with while loop and date commands to create a clock in terminal. If you're interested, see my profile for the relevant askubuntu post. Cheers! Sep 29, 2014 at 3:10
-1

First make sure you close all terminal windows and shell sessions.

Then open file ~/.bash_history in gedit ( or anoter GUI editor) and delete the lines you do not want.

6
  • Thanks for your answer, but I want this done for the current session. I clarified my post because you made me realize that I did not make this clear. Thanks.
    – Anon
    Sep 29, 2014 at 1:41
  • 1
    So you want to delete just one command on the screen without closing the terminal session, is that right ? Sep 29, 2014 at 1:49
  • Basically, but also without deleting the inputs/outputs of all the stuff proceeding it.
    – Anon
    Sep 29, 2014 at 1:57
  • 1
    Would you say making an alias to that command , executing, and then clearing that alias or setting it to something else work for you ? The alias will remain on the screen that way, but afterwards user won't be able to execute it Sep 29, 2014 at 1:59
  • 1
    The commands on screen remain until you clear the screen somehow, but that clears everything. That's the visual part. Like smurf mentioned, you can delete command from .bash_history, but the commands don't seem to go into the file until the session is closed. Also are interested in hiding just output or command AND output ? Sep 29, 2014 at 2:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .