Re: Seeing command history when using MATE terminal

2020-04-19 Thread David
On Sat, 18 Apr 2020 at 22:15,  wrote:
> On Saturday, April 18, 2020 07:00:53 AM David wrote:
> > On Sat, 18 Apr 2020 at 20:20, Richard Owlett  wrote:

> > > I can see any *ONE* previous commands by using the up-arrow key.
> > > But I need to see the *complete* history. F1 is no "Help".
> > > Obviously its stored in a file. Where?

> > * so if a user runs multiple shells, each shell exit will overwrite the
> > existing history file, the result is that only the last shell to exit will
> > have its history
> > preserved, and the history of the others will be lost.

> But, if you want / need to preserve the history from several terminals, there
> are ways to do it, for example, set a different $HISTFILE for each terminal.

An alternative approach (untested):
https://spin.atomicobject.com/2016/05/28/log-bash-history/



Re: Seeing command history when using MATE terminal

2020-04-18 Thread Keith Bainbridge

On 18/4/20 10:14 pm, rhkra...@gmail.com wrote:

On Saturday, April 18, 2020 07:00:53 AM David wrote:

On Sat, 18 Apr 2020 at 20:20, Richard Owlett  wrote:

I can see any *ONE* previous commands by using the up-arrow key.
But I need to see the *complete* history. F1 is no "Help".
Obviously its stored in a file. Where?



* so if a user runs multiple shells, each shell exit will overwrite the
existing history file, the result is that only the last shell to exit will
have its history
preserved, and the history of the others will be lost.


But, if you want / need to preserve the history from several terminals, there
are ways to do it, for example, set a different $HISTFILE for each terminal.




Or this in .bashrc?


# append to the history file, don't overwrite it
shopt -s histappend
PROMPT_COMMAND="history -a;$PROMPT_COMMAND"


--
Keith Bainbridge

ke1th3...@zoho.com
+61 (0)447 667 468



Re: Seeing command history when using MATE terminal

2020-04-18 Thread David Wright
On Sat 18 Apr 2020 at 09:31:10 (-0400), songbird wrote:
> David wrote:
> > On Sat, 18 Apr 2020 at 20:20, Richard Owlett  wrote:
> >>
> >> I can see any *ONE* previous commands by using the up-arrow key.
> >> But I need to see the *complete* history. F1 is no "Help".
> >> Obviously its stored in a file. Where?
> >
> > Reading https://mywiki.wooledge.org/BashFAQ/088 gives some tips
> > that might be relevant if some history is missing:
> > * bash updates its history only on exit (unless history -a is used)
> > * and it overwrites the existing history file with the new version
> > * so if a user runs multiple shells, each shell exit will overwrite the 
> > existing
> > history file, the result is that only the last shell to exit will have
> > its history
> > preserved, and the history of the others will be lost.
> 
>   yes, that among other fun things made me decide to just
> remove the history file upon exit and then when it starts up
> each sesssion i preload the history stack with a few commands
> i use the most (using history -s "command") in .bashrc .

The behaviour of my bash is to read the current version of
.bash_history at startup into its internals (tomás's "belly"),
then to add new commands to its belly during the session.
Upon exiting, only these new commands are appended to the
version of the .bash_history file as it now exists (which
can be different at this later time).¹

I find that too confusing, with multiple bash sessions open
in X, and odd ones coming in over ssh, so my approach (of
about twenty years) is also to have a fixed history at startup,
(currently just under 200 lines) which is set readonly, and
then to throw any new typing away.

-r--r--r-- 13202 Apr  9 14:15 .bash_history
-rw-r--r-- 13202 Apr  9 14:15 .bash-edit-history

I maintain it by editing the second file here, and then
executing the following (which, obviously, is itself in
the history file):

chmod u+w ~/.bash_history; cp -ip ~/.bash-edit-history ~/.bash_history; chmod 
a-w ~/.bash_history

Many of the commands are designed for editing before they're
actually used, but the history file remembers the basic syntax.
Not surprisingly, find is one of the prime candidates:

find . -type f -mmin -1440 -printf '%Ta%TH:%TM:%.5TS%11s  %P\n' | sort -n -k 2 
| less # one day
find . -type f -size "$( stat -c '%sc' xxx )" -printf '%s 
%TY-%Tm-%Td+%TH:%TM:%.5TS\t%P\n' | sort -k 3 # same size
find ~/newscores \( -name \*.ly -o -name \*.ily -o -name \*.lily \) -exec grep 
-Z -l -i 'x' {} \; | sort -z | xargs -0 less # display files

¹ Full disclosure: my own observations presuppose:

braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor:noclobber
is the value of SHELLOPTS, and I set these in .bashrc:
set -o noclobber
export HISTCONTROL=ignoreboth
Also, I don't type any actual history commands.

Cheers,
David.



Re: Seeing command history when using MATE terminal

2020-04-18 Thread songbird
David wrote:
> On Sat, 18 Apr 2020 at 20:20, Richard Owlett  wrote:
>>
>> I can see any *ONE* previous commands by using the up-arrow key.
>> But I need to see the *complete* history. F1 is no "Help".
>> Obviously its stored in a file. Where?
>
> Reading https://mywiki.wooledge.org/BashFAQ/088 gives some tips
> that might be relevant if some history is missing:
> * bash updates its history only on exit (unless history -a is used)
> * and it overwrites the existing history file with the new version
> * so if a user runs multiple shells, each shell exit will overwrite the 
> existing
> history file, the result is that only the last shell to exit will have
> its history
> preserved, and the history of the others will be lost.

  yes, that among other fun things made me decide to just
remove the history file upon exit and then when it starts up
each sesssion i preload the history stack with a few commands
i use the most (using history -s "command") in .bashrc .


  songbird



Re: [Thanks all] - Re: Seeing command history when using MATE terminal

2020-04-18 Thread rhkramer
On Saturday, April 18, 2020 07:52:23 AM Richard Owlett wrote:
> On 04/18/2020 05:19 AM, Richard Owlett wrote:
> > I can see any *ONE* previous commands by using the up-arrow key.
> > But I need to see the *complete* history. F1 is no "Help".
> > Obviously its stored in a file. Where?
> > TIA
> 
> Using 'cat ~/.bash_history' gives desired format (i.e. without the line
> numbers prepended by the 'history' command).
> 
> There's one thing I don't understand - erasure of previous history.
> 
>   https://mywiki.wooledge.org/BashFAQ/088 states it as:
> > ... it overwrites the existing history with the new version.
> 
> What I actually see goes back over several uses of the MATE terminal
> including multiple power off/on cycles. Not that I object, it is my
> desired result.

I believe that is because when a terminal starts it loads the existing 
contents of the $HISTFILE.  (Then, as stated in other posts, it is saved when 
the terminal is closed.  

But there is a limit to the number of command lines saved in any instance of 
bash (any terminal), and when commands exceed that limit, the oldest are 
dropped.

$HISTSIZE is the limit in within a terminal, the default is 500 -- setting it 
to a negative number makes it unlimited

$HISTFILESIZE is a limit on the size of the command history file (in lines)



Re: Seeing command history when using MATE terminal

2020-04-18 Thread rhkramer
On Saturday, April 18, 2020 07:00:53 AM David wrote:
> On Sat, 18 Apr 2020 at 20:20, Richard Owlett  wrote:
> > I can see any *ONE* previous commands by using the up-arrow key.
> > But I need to see the *complete* history. F1 is no "Help".
> > Obviously its stored in a file. Where?

> * so if a user runs multiple shells, each shell exit will overwrite the
> existing history file, the result is that only the last shell to exit will
> have its history
> preserved, and the history of the others will be lost.

But, if you want / need to preserve the history from several terminals, there 
are ways to do it, for example, set a different $HISTFILE for each terminal.



Re: [Thanks all] - Re: Seeing command history when using MATE terminal

2020-04-18 Thread tomas
On Sat, Apr 18, 2020 at 06:52:23AM -0500, Richard Owlett wrote:

[...]

> There's one thing I don't understand - erasure of previous history.
>  https://mywiki.wooledge.org/BashFAQ/088 states it as:
> >... it overwrites the existing history with the new version.

That's because it reads the history file at start. Concatenation
happens, so to speak, in bash's belly.

Cheers
-- t


signature.asc
Description: Digital signature


[Thanks all] - Re: Seeing command history when using MATE terminal

2020-04-18 Thread Richard Owlett

On 04/18/2020 05:19 AM, Richard Owlett wrote:

I can see any *ONE* previous commands by using the up-arrow key.
But I need to see the *complete* history. F1 is no "Help".
Obviously its stored in a file. Where?
TIA



Using 'cat ~/.bash_history' gives desired format (i.e. without the line 
numbers prepended by the 'history' command).


There's one thing I don't understand - erasure of previous history.
 https://mywiki.wooledge.org/BashFAQ/088 states it as:

... it overwrites the existing history with the new version.


What I actually see goes back over several uses of the MATE terminal 
including multiple power off/on cycles. Not that I object, it is my 
desired result.










Re: Seeing command history when using MATE terminal

2020-04-18 Thread David
On Sat, 18 Apr 2020 at 20:20, Richard Owlett  wrote:
>
> I can see any *ONE* previous commands by using the up-arrow key.
> But I need to see the *complete* history. F1 is no "Help".
> Obviously its stored in a file. Where?

Reading https://mywiki.wooledge.org/BashFAQ/088 gives some tips
that might be relevant if some history is missing:
* bash updates its history only on exit (unless history -a is used)
* and it overwrites the existing history file with the new version
* so if a user runs multiple shells, each shell exit will overwrite the existing
history file, the result is that only the last shell to exit will have
its history
preserved, and the history of the others will be lost.



Re: Seeing command history when using MATE terminal

2020-04-18 Thread Tony van der Hoff




On 18/04/2020 11:19, Richard Owlett wrote:

I can see any *ONE* previous commands by using the up-arrow key.
But I need to see the *complete* history. F1 is no "Help".
Obviously its stored in a file. Where?
TIA





Well, for Bash, the file is at ~/.bash_history (as set in $HISTFILE), 
but, beware, it is only updated when the terminal is closed.


Bash provides the 'history' command, which shows the entire history.

--
Tony van der Hoff| mailto:t...@vanderhoff.org
Buckinghamshire, England |



Re: Seeing command history when using MATE terminal

2020-04-18 Thread Liam O'Toole
On Sat, 18 Apr, 2020 at 05:19:40 -0500, Richard Owlett wrote:
> I can see any *ONE* previous commands by using the up-arrow key.
> But I need to see the *complete* history. F1 is no "Help".
> Obviously its stored in a file. Where?
> TIA

Use the 'history' command, or 'cat ~/.bash_history'. Assumes you are
using bash, the default user shell.