I just found hstr to filter the bash history. It’s kind of like using CTRL+R to search through the bash history for past command lines. But instead of doing it blindly, you get a list that gets filtered live as you type (kinda what Clipdinger does with its latest version for the clipboard history).
Anyway, it seems very nice, but I haven’t yet managed to actually execute the selected line. Pressing RETURN will just insert it in the shell, but doesn’t execute it. What do I miss?
I don’t think that it is possible. Apparently, there’s no filtering of commands that could possibly damage the system so it wouldn’t be safe. I’d say that’s intended and if this behaviour allows users to edit the line, it mainly gives them another chance to think about what they are doing.
Maybe I’ve been not totally clear. I’d be happy if the selected line were inserted at cursor position, then could be edited and executed with RETURN. But as it is, the selected line gets just “echo’ed” out and my prompt returns below it.
Difficult to describe, here I opened hstr (aliased to “hh”) with the string “ssh”, from the filtered history list (not shown below, ofc) I picked “ssh root@libre-a”, which is the inserted, but not executed, and I’m sitting there with the empty blinking prompt:
~/Desktop> hh ssh
ssh root@libre-a
~/Desktop>
Anyone using hstr outside of Haiku and can confirm this is expected behaviour and not a bug in our port or some failure on my side?
Nope, and it would be a huge bother if that were the way, and how would it if you just called “hstr” without an initial filtering string?
“hstr” is in HaikuDepot, everyone can give it a spin before guessing into the blue.
Tried it on nightly x64, and got same behaviour. It’s indeed not very helpful. I guess that the recipe was tested before being pushed so perhaps, it’s something that changed in nightlies or a problem with the arch.
I updated the recipe before trying to find why it behaves like this on Haiku. I’ve used hstr for years on Linux, and I would love to have it working correctly on Haiku.
But as it is usual… I’m way out of my league trying to debug stuff, so… don’t wait for me! If anyone else wants to have a look at it, that would be awesome!
Edit: I mean, the original recipe behaved the same as what @humdinger sees with the updated one. I just figured it was better to have the latest code available before digging into the issue.
It seems the patchset is not complete. Lacking TIOCSTI, the same workaround as cygwin uses is included, but the change to the shell binding function was forgotten.
Confirmed that declaring that function in bash and binding it to a key, works.
The update I’ll propose, will only change what’s shown in the config instructions. So it should work same as it does right now.
So happy to have hstr working! Thanks again @madmax!
Edit: Just in case I misread your question (my “English” is poorly self-taught, sorry). The update will still need the above function defined in profile.
I did the original port, but i don’t recall it ever executed the commands. I haven’t spent too much time and had nochance to test it on other system (running only Haiku here), so i assumed it just doesn’t do that.
To expand on @BiPolar’s answer: the current workaround in hstr is to just spit the command to stderr. It’s the bash function that reads that and inserts it into the current readline buffer, and it seems it needs to be bound to a key to access readline. You can use a different key combo, of course.