Can anyone post some examples of how to setup bash configuration
files to capture the maximum amount of command history.
When, even
though it is a single user host, often, multiple shells come into
play.
On 22.03.2022 16:25, hput wrote:
Can anyone post some examples of how to setup bash configuration
files to capture the maximum amount of command history.
Since the history will be stored in a file (or maybe temporarily in
memory depending on shell), the limit is basically a runtime limit,
depending on your (available and used) system resources.
multiple shells come intoWhen, even though it is a single user host, often,
play.
For example I defined a separate
HISTFILE for every shell instance; for me that makes sense because I
usually have a few windows for compiling stuff, some for testing, some
for playing, some for specific projects, one for managing web content
and servers, etc.
It may make sense to increase the default value for HISTSIZE (which
is typically around 500 lines), but often other additional approaches
might also serve one's needs. For example I defined a separate HISTFILE
for every shell instance; for me that makes sense because I usually
have a few windows for compiling stuff, some for testing, some for
playing, some for specific projects, one for managing web content and servers, etc.
Can anyone post some examples of how to setup bash configuration files
to capture the maximum amount of command history. When, even though
it is a single user host, often, multiple shells come into play.
In comp.unix.shell, Janis Papanagnou <janis_papanagnou@hotmail.com> wrote:
In bash I've seen this trick:
PROMPT_COMMAND='history -a >(logger -t "user $(id -u); at $(date +%s); in ${PWD}"'
Then ensure logs are sent off-system.
Since the history will be stored in a file (or maybe temporarily in
memory depending on shell), the limit is basically a runtime limit,
depending on your (available and used) system resources.
That's why you write to system logs an use network logging.
On 22.03.2022 18:39, Eli the Bearded wrote:
PROMPT_COMMAND='history -a >(logger -t "user $(id -u); at $(date +%s); in ${PWD}"'
Then ensure logs are sent off-system.
I'm not sure whether that's a solution for the history, typed commands
to be easily retrieved for re-running them or re-running them edited.
A logger's purpose is different to a shell history's purpose, isn't
it?
On 22.03.2022 16:25, hput wrote:
Can anyone post some examples of how to setup bash configuration
files to capture the maximum amount of command history.
What do you mean by that?
Capture the actual contents? Then use: fc -l 1
Or make history memory for shell windows as large as possible?
You can define any size by setting the HISTSIZE variable, as in
HISTSIZE=1000000
Since the history will be stored in a file (or maybe temporarily in
memory depending on shell), the limit is basically a runtime limit,
depending on your (available and used) system resources.
When, even
though it is a single user host, often, multiple shells come into
play.
TTY=$( tty )
TTY=${TTY#/dev/}
TTY=${TTY//\//_}
export HISTFILE=${HOME}/.sh_history_${TTY}
export HISTSIZE=1000
to create history files named individually for each shell window.
I'm not sure how to set up the PROMPT_COMMAND line. Somewhere in this
thread has been suggested adding the -r flag to PROMPT_COMMAND. What
effect does that have?
... if you have multiple shelks writing to the same history file.
(That is not my usual style.)
Elijah
------
one history file per tty
Eli the Bearded <*@eli.users.panix.com> wrote:
one history file per ttyWhat is your implementation for that?
In comp.unix.shell, Kenny McCormack <gazelle@shell.xmission.com> wrote:
Eli the Bearded <*@eli.users.panix.com> wrote:
one history file per ttyWhat is your implementation for that?
tty=`tty || :`
...
HISTFILE=$HOME/.kshrc_history.${tty##*/}
Obviously from that, ksh is my preferred shell. I don't think I've
edited those lines in fifteen years. $() is my usual notation now.
Elijah
------
probably did something causing 'not a tty' errors for that first part
Not sure what is supposed to happen to its accumulated history if an
xterm running bash is killed or crashes somehow.
Can anyone post some examples of how to setup bash configuration
files to capture the maximum amount of command history. When, even
though it is a single user host, often, multiple shells come into
play.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 498 |
Nodes: | 16 (2 / 14) |
Uptime: | 45:49:12 |
Calls: | 9,800 |
Calls today: | 2 |
Files: | 13,752 |
Messages: | 6,189,887 |