atuinsh/atuin

Associate shell commands to used files

tycho-kirchner opened this issue ยท 2 comments

Hi,
a friend of mine has just shared a link to this project which is closely related to my own (a bit less popular and sophisticated ๐Ÿ™‚) shournal, but lacks a feature important for researchers: tracing of files (see our paper Bashing irreproducibility with shournal). shournal allows you to ask for a specific file, with what particular command it was created or how it was used based on tracing deep down in the Linux kernel. So I kindly wanted to ask you to whether you are interested in adding such a feature to Atuin. For instance the kernel module backend is controllable via a single c-header file that you may want to integrate for that purpose.

In any case regarding bash, you may consider replacing bash-preexec by PS0 (search here for _shournal_ps0 for an example).

Thanks and kind regards
Tycho

shournal allows you to ask for a specific file, with what particular command it was created or how it was used based on tracing deep down in the Linux kernel.

Couldn't both Atuin and shournal be independently configured?

In any case regarding bash, you may consider replacing bash-preexec by PS0 (search here for _shournal_ps0 for an example).

Atuin wants to leave a change in the main shell environment, but command substitutions in PS0 cannot do that. Also, PS0 is only supported in bash >= 4.4. I expect Bash 5.3's function substitutions to enable leaving changes, but it hasn't yet been released. Anyway, Atuin doesn't try to implement preexec/precmd but is just using an external framework.

Couldn't both Atuin and shournal be independently configured?

Sure! However, shournal hash no sync infrastructure for its history at all and I supposed it might be easier, adding file-tracing to Atuin than adding the sync infrastructure to shournal ๐Ÿ˜‰.

Atuin wants to leave a change in the main shell environment, but command substitutions in PS0 cannot do that.

It is possible to set variables in the main shell environment from PS0 using nifty parameter expansion tricks, i.e. incrementing a counter using

${existing_var:((++counter)):0}

Similarly, one can utilize $? from an own function and use the variable in PROMPT_COMMAND, e.g.

existing_var=foo
PS0='$(exit 42)${existing_var:((preexec_ret=$?)):0}'
# .. but in PROMPT_COMMAND preexec_ret has to be emptied
PROMPT_COMMAND='echo preexec_ret: $preexec_ret; preexec_ret="";'

Finally, any code can be executed in the main shell using signals, has I've shown here