[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bash History Behavior Suggestion
From: |
Martin D Kealey |
Subject: |
Re: Bash History Behavior Suggestion |
Date: |
Tue, 20 Aug 2024 14:58:02 +1000 |
The following suggestions, or close approximations, can all be implemented
using the existing facilities.
On Tue, 20 Aug 2024 at 05:52, <support@eggplantsd.com> wrote:
> I would suggest:
>
> 1. Append to history file immediately on each command.
>
Easily done by putting `history -a` into `PROMPT_COMMAND`
2. Restrict up-arrow completion to the history of present session.
>
That's easy. Simply don't use `history -r` in your .bashrc or
/etc/bash/bashrc.
(Unfortunately modifying the latter will require admin access to your host,
so choose a distro that does NOT include `history -r` among its system-wide
shell start-up files.)
3. Add column(s) to the history file to identify the session the command
> came from (pty, pid, etc).
>
I simply write the history for each session into a separate file; I have
HISTFILE=$HOME/.bash_history.d/$EPOCHSECONDS.$TTY.$$
That way I can simply use a pager such as `less` to read the file I'm
interested in. If I want to see the timestamps, I can use:
( HISTTIMEFMT="%F,%T " HISTFILE={other-history-file} ; history -c ;
history -r ; history ) | less
4. Add options to the 'history' command to toggle between session-local
> and global reporting.
>
I simply use separate commands to view the current session's history vs all
sessions.
I generally prefer not to interleave multiple sessions, but on the rare
occasion when I do want this, I can simply use:
( cd $HOME/.bash_history.d ; HISTTIMEFORMAT="%F,%T " ; for HISTFILE in * ;
do ( history -c ; history -r ; history ) ; done ) | sort | less
If I did this often enough to actually care, I'd wrap it in a function.
- Bash History Behavior Suggestion, support, 2024/08/19
- Re: Bash History Behavior Suggestion, Greg Wooledge, 2024/08/19
- Re: Bash History Behavior Suggestion,
Martin D Kealey <=
- Re: Bash History Behavior Suggestion, Martin D Kealey, 2024/08/20
- Message not available
- Re: Bash History Behavior Suggestion, support, 2024/08/20
- Re: Bash History Behavior Suggestion, Lawrence Velázquez, 2024/08/20
- Re: Bash History Behavior Suggestion, support, 2024/08/20
- Re: Bash History Behavior Suggestion, Martin D Kealey, 2024/08/20
- Re: Bash History Behavior Suggestion, support, 2024/08/20
- Re: Bash History Behavior Suggestion, Martin D Kealey, 2024/08/20
- Re: Bash History Behavior Suggestion, support, 2024/08/20
- Re: Bash History Behavior Suggestion, Chet Ramey, 2024/08/28
- Re: Bash History Behavior Suggestion, Chet Ramey, 2024/08/28