-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
history should be customizable by the end user (HN thread summary) #320
Comments
Good resources, I will look at FZF. I had not heard of it. |
OK thanks! The thread helped clarify what I'd want in Oil for history: https://news.ycombinator.com/item?id=20057323 Basically it should be a structured text file. Coincidentally I wrote this the other day because @drwilly is working on xargs, which also needs structured data: https://github.com/oilshell/oil/wiki/Structured-Data-in-Oil The point is that you probably want history in SQL for two reasons:
I think what'ss weird about bash history is this:
That's why it's so weird between "sessions"! At least I think so. This thread also points to the benefit of having a real programming language in shell. Instead of a
|
Pretty much agree.
The other thing I would add is making history more robust in the presence
of events which kill the shell before it has a chance to save its history.
Either a function hook or a trap.
At least one comment hints at how controversial this sort of thing will be
:P
…On Fri, May 31, 2019, 10:03 andychu ***@***.***> wrote:
OK thanks!
The thread helped clarify what I'd want in Oil for history:
https://news.ycombinator.com/item?id=20057323
And coincidentally I wrote this the other day because @drwilly
<https://github.com/drwilly> is working on xargs, which also needs
structured data:
https://github.com/oilshell/oil/wiki/Structured-Data-in-Oil
Anyway, the point is that you probably want history in SQL for two reasons:
- because you want fields without parsing them (usually done
incorrectly). That can be done with the simple TSV2 proposal. Oil will
parse that so you don't have to, but you can also grep the file if you want.
- for concurrency. I don't think this is a problem for append only
files (although admittedly I wonder how HISTCONTROL=erasedups is
implemented).
I think what is weird about bash is this:
- history is kept in a buffer in memory
- on shell's exit, the whole thing is appended to a file.
That's why it's so weird between sessions! At least I think so.
This thread also points to the benefit of having a real programming
language in shell. Instead of a PROMPT_COMMAND string to evaluate, we
could have a hook:
func whenCommandFinished(command_string, evaluated_argv, timestamp, status, elapsed_time, ...) {
# do something yourself with history, like put it in a sqlite database, or upload it to your own server, etc.
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#320>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAC3WYTRSOL56T32ZVLJTLPYFK4XANCNFSM4HRPANDQ>
.
|
I'm designing a history extension/replacement for bash and zsh and instead of having awkward two-level history I have a daemon-client type situation. Maybe oilshell could do something similar. |
@curusarn I'd be interested in seeing what you've done for bash and zsh! It would be interesting for Oil to support some kind of external protocol so people can plug in their own logic. Although one limitation is that we use |
@andychu Sorry for the long silence. Readline is pretty difficult to work with. The idea behind my project is to provide context-based history enhancement for zsh and bash. There are multiple ways I need to integrate with the shell:
To collect the history I run custom functions before/after each command using bash-preexec. It uses Executing custom commands through readline bindings is problematic. There is I didn't implement the binding for Ctrl+R yet but I want it to open an app similar to hstr except my app will use all the extra data for searching. There should be no problem to do this since All of the above is much easier to do in zsh then in bash. Link to my project for more context and more info. I'm not sure exactly how much of the difficulties I encountered were caused by readline itself and how much I can blame bash. My intuition is that the biggest problem are the bindings because anything else than native readline history functions takes the performance hit when redrawing. |
I've also been picking at a bash-specific history module (opinionated; uses sqlite, also stays compatible with the underlying history functionality). I'm not promoting it for others to use, yet, but it's been in my shell for close to a year now, I guess. Don't have time for a longer comment atm, but I'll get notifications, and you'll know I have opinions. :) |
@abathur What interface are you using to glue bash together with sqlite? Is it That seems like a fragile interface but I suppose it's already there and a lot of people are using it. I'm more interested in providing a good interface for Oil than developing this myself. Though it already implements |
Yep. Indirectly, though--I've abstracted most messy implementation parts into a shell library (to keep them away from the history module itself, minimize duplicated work in other parts of my profile, and make it possible to share the PROMPT_COMMAND). I do think Oil can do better, though I'm not sure it's incompatible with supporting PROMPT_COMMAND. Can probably discuss on zulip sometime soon. |
Oil could support
|
Yeah I think those hooks are a good idea, and the different versions of the command are what I wanted to sort out:
pre- and post- alias expansion is another possibility, and probably not hard, although I'm not sure how useful it is. (Almost all aliases can simply be shell functions.) This distinction appears to be missing from bash's history mechanism on the "output side". I would also favor something like Just like bash has This also relates to |
related:
|
https://news.ycombinator.com/item?id=25946055 Good comment here
|
This is a summary of Better Bash History discussion on HN
@emdash There is lots of interesting feedback here about history, including someone putting their history in an sqlite DB! Bash is crufty yet it's pretty amazing what people manage to hack on to it!
Some takeaways:
$PROMPT_COMMAND
because lot of people are using it!Things people are doing:
cd
'd into. Thus, all of thecd
commands that get written to my history use absolute paths and are re-usable no matter where I amcd
.*argv
array as well as the raw text?History:
Other interesting quotes, not about history:
The text was updated successfully, but these errors were encountered: