atuin icon indicating copy to clipboard operation
atuin copied to clipboard

Feature Request - Allow the option to record -all- history

Open Ciberth opened this issue 1 year ago • 6 comments

Hi, this is a small feature request that could turn atuin in a security tool as well.

Sample use case: "hacker" gets access to a system, performs some actions and deletes the shell history but does not know about atuin ;) That way the administrator can still properly recover history from atuin.

Related: https://github.com/ellie/atuin/issues/114 & https://github.com/ellie/atuin/issues/70

In https://github.com/ellie/atuin/issues/120 it is stated that atuin correcty ignores commands that start with a space. In previous versions everything was recorded and it is nice that this is updated to defaults. However in some cases it might be beneficial to actually do log everything.

Proposal: a method/configuration to actually configure atuin to include every single command entered no matter the configuration of the shells. Any tips to achieve this would be appreciated!

Ciberth avatar Apr 17 '23 08:04 Ciberth

Hey! Thank you for considering other use cases for Atuin :D

Totally makes sense - and should be doable in the current state, albeit it a bit roundabout.

Currently, the server does not actually delete any data. It marks history as deleted, and the client will not decrypt and save it, but once pushed it will exist ~forever

So your example would work! You may also want to set the sync frequency to be 0, for near-realtime sync too. I'm actually wanting to work on actual realtime sync in the fairly near future too

Edit: though you are correct about ignoring spaces. adding a config option to disable this would not be much work. I'll try and get around to it sometime, though I'm happy to provide pointers to anyone wishing to contribute

ellie avatar Apr 17 '23 20:04 ellie

Sounds good, it would be truly awesome and interesting to have it in offline mode also available through a configuration or (maybe other) environmentvariable

Ciberth avatar Apr 18 '23 05:04 Ciberth

I will hijack this thread: I use fish shell, and their philosophy is to remember commands without duplication to make database with history small as possible (opposite to bash or zsh). So, typing:

pwd
ls
ls
htop
htop
pwd
ls

in fish history show as:

htop
pwd
ls

Actually only hishtory let me to bypass this behavior and if I try:

pwd     
ls     
ls     
ls     
ls     
ls     
ls     
pwd    
ls     
ls     
ls     
ls     

it will show me it as:

──────────────────────────────────────────
Timestamp                  Runtime Command
──────────────────────────────────────────
Apr 29 2023 09:15:50 CEST  900ms   pwd     
Apr 29 2023 09:15:52 CEST  909ms   ls     
Apr 29 2023 09:15:53 CEST  784ms   ls     
Apr 29 2023 09:15:54 CEST  356ms   ls     
Apr 29 2023 09:15:54 CEST  888ms   ls     
Apr 29 2023 09:15:55 CEST  415ms   ls     
Apr 29 2023 09:15:56 CEST  414ms   ls     
Apr 29 2023 09:15:57 CEST  212ms   pwd    
Apr 29 2023 09:15:58 CEST  115ms   ls     
Apr 29 2023 09:15:58 CEST  900ms   ls     
Apr 29 2023 09:15:59 CEST  544ms   ls     
Apr 29 2023 09:16:00 CEST  235ms   ls     

I try to do things where command order matters and if something doesn't work, I'm not sure if it's my fault because I messed commands order or problem lie somewhere else. As a person with concentration problem, recording everything is blessing, but I couldn't figure out how to make this with Atuin. I don't even see duplication in bash history using Atuin.

roland-5 avatar Apr 29 '23 07:04 roland-5

We save every command in the database, but in the search UI we remove duplicates because searching for something like "git status" would be horrible.

However, we have plans for a "reveal context" view that lets you go through the invocations to see the surrounding commands as you wrote them

conradludgate avatar Apr 29 '23 07:04 conradludgate

zsh's HIST_IGNORE_SPACE, will be more in line with my intuition:

Remove command lines from the history list when the first character on the line is a space, or when one of the expanded aliases contains a leading space. Only normal aliases (not global or suffix aliases) have this behaviour. Note that the command lingers in the internal history until the next command is entered before it vanishes, allowing you to briefly reuse or edit the line. If you want to make it vanish right away without entering another command, type a space and press return.

When I select a copy with the mouse, I often mistakenly copy one more leading space. Zsh allows me to briefly reedit the line even it's first character is a space, this is really useful in this case.

ryan4yin avatar Feb 19 '24 01:02 ryan4yin

Hi @ellie I would be interested in a configuration which allows atuin to track commands starting with space. Maybe it's just me but when I'm copying from notes/docs, I often have extra spaces from indentation, which leads to that command's history being lost.

I'm not rustacean but I originally just going to fork and comment out https://github.com/atuinsh/atuin/blob/36ddd98b6ef86af9b00d93d28476900b07be34ac/crates/atuin-client/src/history.rs#L338 . But I can try to do a proper configuration if you think it's worth it or might be merged.

Is there an existing setting you think is worth emulating? With a quick skim show_preview is another boolean setting which seems very simply used and I could make a new option similarly.

Personally I have no need to hide bash history from myself, but I guess it is nice to be able to easily not save extra-secret commands. A more complicated option would be a integer-type option where you need at least that # spaces before it becomes a hidden command. Or like forcing it to be (multiple) tab characters not spaces.

JZL avatar Apr 28 '24 01:04 JZL