recent terminal commands

This is a question about Konsole or any command line terminal that allows the user to use the arrow pad [left,right,up,down] to recall recently used commands.
I am not exactly sure but I think it stores up to 15 of the most recent commands.
My questions are:
1]Where are these commands stored?
2]Can I get to them and delete/clear the list?
I have poked about in Konsole task bar and settings but have found nothing [that I think] relates to this.

Should I be posting this elsewhere?

thanks

Terminals may do this, but the default shell ‘bash’ definitely does. The
history is, by default, 1000 commands long, but that’s something you can
extend. Using the up arrows, or Ctrl+r, or ‘!’, or a number of other
things, can retrieve commands. The ‘history’ command will also retrieve
all commands in the history, as well as clear the history. They are
stored in ~/.bash_history as I recall. See the ‘bash’ manpage for more.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

:slight_smile:
Whenever I do a live presentation using Konsole and people see me scrolling to see the previous history (it’s almost certainly stored in a memory buffer, not on disk) I always hear a gasp in the audience.

People who are used to working in many other distros do <not> get this feature by default in their terminals, so I generally then pause for a moment and explain a little about the enhanced features provided by Konsole.

TSU

tsu2 wrote:
> :slight_smile:
> Whenever I do a live presentation using Konsole and people see me
> scrolling to see the previous history (it’s almost certainly stored in a
> memory buffer, not on disk) I always hear a gasp in the audience.
>
> People who are used to working in many other distros do <not> get this
> feature by default in their terminals, so I generally then pause for a
> moment and explain a little about the enhanced features provided by
> Konsole.

I don’t use KDE, but what are we talking about here?

In my experience, command history is provided by the shell, not the
terminal. If Konsole has command history using up arrow etc, how does
that work with bash’s history using up arrow etc? A quick google showed
the first hit being somebody confusing the two, so is there a reference
for such a Konsole feature? I don’t see it in the Konsole manual.

In my experience, terminals usually provide history of the whole
session, both input and output. That’s what the Konsole manual
describes, but every terminal since xterm has that feature, AFAIK.

I support this. Command retrieval is a shell feature. It worked already with dumb TTYs, thus it is not a terminal emulator (Konsole, XTerm, …) feature.

Ummm…
Maybe a bit of clarification here.

I was not referring to the “up arrow” that cycles through previous commands but the fact that Konsole supports using the mouse to scroll the window to display previous commands and output. And, AFAIK this is purely a Konsole enhancement of the underlying BASH.

My bad if the Q was about something different.

TSU

This was the first sentence of the OP:

This is a question about Konsole or any command line terminal that allows the user to use the arrow pad [left,right,up,down] to recall recently used commands.

On 2014-01-21 18:10, Dave Howorth wrote:
> In my experience, terminals usually provide history of the whole
> session, both input and output. That’s what the Konsole manual
> describes, but every terminal since xterm has that feature, AFAIK.

Correct.

And if you use, say, 20 terminals of mixed type, and reboot or log out,
on the next terminal you open (even text mode console) you see a mixture
of all the commands you typed on the previous session.

Trick: if you precede your command with an space, it is not saved to the
history, it is lost.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

On 2014-01-21 20:56, tsu2 wrote:
>
> Ummm…
> Maybe a bit of clarification here.
>
> I was not referring to the “up arrow” that cycles through previous
> commands but the fact that Konsole supports using the mouse to scroll
> the window to display previous commands and output. And, AFAIK this is
> purely a Konsole enhancement of the underlying BASH.
>
> My bad if the Q was about something different.

Yes, that’s a different feature, but all terminals have something
similar, too. Even on text mode console, you can use “shift-page-up” to
view it. But it is cleared as soon as you switch consoles.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Every week, I delete all the commands in .bash_history except the ones with complicated arguments that I use regularly. It saves scrolling through lots of trivial commands to find the complex one I really want.

On 2014-01-21 22:56, john hudson wrote:
>
> Every week, I delete all the commands in .bash_history except the ones
> with complicated arguments that I use regularly. It saves scrolling
> through lots of trivial commands to find the complex one I really want.

Trick: you can type “ctrl-r” and some letters, and it searches for lines
containing those letters. Just type more "ctrl-r"s to go through them
till you find the exact command you seek.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Hey, hey! Now that’s something to know!
Thanks for teaching me something!

Bart

On 01/21/2014 07:06 PM, montana suse user wrote:
>
> robin_listas;2618264 Wrote:
>>
>> Trick: if you precede your command with a space, it is not saved to the
>> history, it is lost.
>>
>> –
>> Cheers / Saludos,
>>
>> Carlos E. R.
>> (from 12.3 x86_64 “Dartmouth” at Telcontar)
>
> Hey, hey! Now -that’s- something to know!
> Thanks for teaching me something!

Just be aware that this is not the same in all distros.
RHEL/Fedora/CentOS, for example, does not do this by default. Different
versions of bash, different configurations… I haven’t bothered figuring
out what this is, but it’s consistent and reliable in SUSE-land (openSUSE,
SLES, SLES, etc.).


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

Oh! It never occurred to me that there were other distributions! rotfl!

Bart

There aren’t. SUSE is it.

/me waving hands in the air, changing: This IS the distro you’re looking
for, because it’s the only one.


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below…

On 2014-01-22 04:13, ab wrote:

> Just be aware that this is not the same in all distros.
> RHEL/Fedora/CentOS, for example, does not do this by default. Different
> versions of bash, different configurations… I haven’t bothered figuring
> out what this is, but it’s consistent and reliable in SUSE-land (openSUSE,
> SLES, SLES, etc.).

Curious!


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Well, I guess this is what happens when you ask a question and you don’t know what you are talking about. me]
Thank you all so much, for the information. I think my bad was not realizing that “shell” and “terminal” were two different things.

Shell being a program and terminal being the window in which you see the program operating
, as a google search has since told me. This may be an oversimplified explanation of the differences.

So, in view of that, was I asking about ‘shell’ ? Is that what stores the recent commands that show when I push the up arrow?
Is shell the only program like this? are there others?

Is Konsole just a terminal? A software type terminal? How many different terminals are there?

Where does bash fit in here?

Well, apparently there are more questions created as I get into this.

delete all the commands in .bash_history

where is this file found? I have done a search[Find] through Dolphin file manager but it .bash_history] was not found.

Thanks

On 2014-01-22 23:16, LaQuirrELL wrote:

> So, in view of that, was I asking about ‘shell’ ? Is that what stores
> the recent commands that show when I push the up arrow?
> Is shell the only program like this? are there others?

There are other shells.

> Is Konsole just a terminal? A software type terminal? How many different
> terminals are there?

Yes, there are more terminals. Each desktop has its own one, and there
are other independent ones, like xterm.

There are also terminals in Windows, created to connect to Linux/Unix
machines, like putty.

There are things similar to terminals, like minicom, that run inside a
terminal, made to connect to other machines via serial port, and there
it can run a shell which you view on your machine. Or the traditional
kermit.

Basically a “terminal” program emulates the text only old console of old
computers. With additions.

> Where does bash fit in here?

Basically it interprets what you type, and does the things you tell it
to do, like starting another program.

> Well, apparently there are more questions created as I get into this.
>
>> delete all the commands in .bash_history
> where is this file found?

On your home.

> I have done a search[Find] through Dolphin
> file manager but it .bash_history] was not found.

Because it is a hidden file. That’s what the dot means :slight_smile:

Also, deleting the file deletes what you did on the previous session,
which has probably be already read into memory into the current session,
and thus will be written again to the history file.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

A terminal is what the word says, an endpoint. It is the endpoint connected to a computer using some datacommunication protocol. The terminals mostly connected to Unix systems were the TTY (see: http://en.wikipedia.org/wiki/Teletypewriter), either real (ink on paper) or glass.

Unix computers normaly had at least one connected by a direct cable, placed ajacent to the system in the computer room, for system managers/operators. Others were connected through telephone lines (using modems at sometimes the immense speed of 9600 Bd) to be used by the end-users.

When Unix like systems (e.g. Linux) emerged on PC hardware, it was of course logical to use the keyboard/screen combination as terminal and software emulating the hardware terminals was designed (you can still see this after pressing Ctrl-Alt-F1). But connection of old hardware through cables with or without modems) to the COM ports (later USB) was/is also possible.

With the emergence of the X-windows system, one of the first things that was build was an application to emulate such a terminal in a window, the infamous Xterm program (still available). Later newer (better?) implementations were made, often more integrated in the environment of a particular Desktop (e.g. Konsole).

So what you use is not realy a terminal, but an emulator. But because an emulator is designed to emulate what it should emulate, we should not be surprised that everybody calls the emulator with the name of what it emulates: terminal.

And yes, Konsole has the feature of buffering what you see in the window, a sort of large virtyual screen with many lines, where you can scroll through. Something the original TTY was not able to offer you.

And that virtual screen is not the same as the command history most shells have. And yes, there are more programs having it. Of course it should be programs that have a command line interface. I remember mysql, the program with which you manage MySQL/MariaDB. There may be more, but it is of course the program designer that puts it in a program.

On 2014-01-23, hcvv <hcvv@no-mx.forums.opensuse.org> wrote:
> And that virtual screen is not the same as the command history most
> shells have. And yes, there are more programs having it. Of course it
> should be programs that have a command line interface. I remember mysql,
> the program with which you manage MySQL/MariaDB. There may be more, but
> it is of course the program designer that puts it in a program.

Just a quick question! Is there a terminal environment that doesn’t ignore what you’ve just typed and completes what you
type (after pressing up-arrow) based on the recent command history?

For example, consider the following:


sh-4.2$ rm bar
sh-4.2$ cp foo bar
sh-4.2$ rm_ # (your cursor is at _)

If you now press up-arrow, bash will ignore the rm' you've just typed and replace entire line with the line above (beginning cp’). This behaviour is undesirable; it would be much more efficient if it completed your command with the
first line since this would preserve what you’ve just typed. The MATLAB console has this feature correctly implemented
AFAIK. But can it be done in bash?