Quantcast
Channel: Debian User Forums
Viewing all articles
Browse latest Browse all 3474

list bash history of current session only?

$
0
0
Hi,

it seems to be inordinately difficult to persuade the history (or fc) commands to list only the commands evaluated in the current session (ie, the contents of the in-memory history buffer).

something like:

Code:

echo '' >| junk ; history -a junk ; cat junk
gets some way there, but it also requires manually appending history to .bash_history, since the manual append seems to disable the append on exit. So, maybe...

Code:

echo '' >| junk ; history -a junk ; cat junk ; history -a
But this means the in memory history is appended to $HISTFILE whenever the command is used, so the commands are appended multiple times.

To sum up, listing the history of the current session seems like something a user might want to do. A search online reveals plenty of advice about executing the second to last command starting with 'cc' (something I can't imagine myself ever wanting to do) but absolutely nothing to answer this question.

Am I missing something?

Cheers,
bitrat

Statistics: Posted by bitrat — 2024-07-02 23:28 — Replies 0 — Views 29



Viewing all articles
Browse latest Browse all 3474

Trending Articles