Can someone explain bashub to me? I don't get it at all. Bash history is already searchable (history | grep "foo"). Is the benefit just to be able to easily see what you ran on some other device?
the pitch is "Never lose another command again" but you can increase the size of your history file to be pretty enormous. Is being able to find a command you ran 2 years ago really a valuable thing?
I always find my history not complete when using tmux. I started using these functions in my profile to collect everything. I don't remember the source of the functions.
log_bash_persistent_history()
{
[[
$(history 1) =~ ^\ *[0-9]+\ +([^\ ]+\ [^\ ]+)\ +(.*)$
]]
local date_part="${BASH_REMATCH[1]}"
local command_part="${BASH_REMATCH[2]}"
if [ "$command_part" != "$PERSISTENT_HISTORY_LAST" ]
then
echo $date_part "|" "$command_part" >> ~/.persistent_history
export PERSISTENT_HISTORY_LAST="$command_part"
fi
}
run_on_prompt_command()
{
log_bash_persistent_history
}
alias phgrep='cat ~/.persistent_history|grep --color'
I like the idea of a hub, as I do a lot of work inside docker containers and vms -- so this could be tailored to help me collect all my history.
not sure if this is your problem but i think most shells (like bash) don't add the history in their buffer to the common history until you close the session. thus recent history in one window is different than another. That _may_ be what you're dealing with. I believe there are ways to tweak it to always write everything to the common history immediately.
Yes, the big benefit, to me at least, is being able to access bash or zsh history on multiple machines. I'll spin up a server for testing or to add workers to some job and it's really quick and convenient to install bashhub the new machine. I just wasn't comfortable using the open-source client to send all my shell history to a closed-source backend and wanted better command querying so I wrote the bashhub-server.
If you're primarily working on one machine I'm not sure how beneficial it is if at all, but if you find yourself using ssh somewhat frequently it's really nice.
I use the following found zsh function to log each each command to file by date. I've definitely found value in looking up less frequently used or complex commands.
HN pro-tip: When pasting code in comments, indent each line with two spaces for pre-formatted/fixed-width/monospaced (whatever you wanna call it) text (e.g., for code).
for me, yeah it is. for example i do various one offs for bid and proposal work; these probably should get nicely written up but they often get stuck if the B&P doesn't get accepted, but then a similar one comes up in 6 months, etc.
being able to see what directories i was in to run various analyses etc. is really invaluable. or even just how RESTful APIs were used (is it POST or PUT /api/v1/predict?) in various poorly documented stuff.
i also work across various machines, local laptop to powerful GPU node for training etc. so helps to have all that history in a nice central form. i'm just using zsh-histdb though which so far is fine for my needs.
Pretty cool! I’m not a big public cloud guy (but do run/manage many systems) but will try this out. Fwiw, I currently have almost all of my systems sending my command history to a syslog server (splunk) via constant VPNs (.bashrc and logger) , it works surprisingly well and consistently for the amount of issues I read about when searching for how to implement this online
Thanks for this! I was working on a private server for BashHub to be used at work, but this is better than what I've got so far! It's sad that the creator of BashHub has sat on releasing the server for awhile since it was a very requested thing.
Is bashhub itself secure? The FAQ says "You need an access token associated with your user account to retrieve them." Wondering if anyone has any other color on this.
To this point, is there an open source, encrypted data sync server? Some encrypted database I can connect to and query for data, that will also do deduplication, etc?
I'm imagining something like a shell history client storing the history on this database, with the server having no knowledge of any of the data, but the client still being able to easily sync it between devices.
Maybe filter out repeats of anything with an exit code other than 0 or 130, but still log the command itself? Sometimes I will run a command a few times since I know we've either hit an API limit, or I'm testing incremental changes.
the pitch is "Never lose another command again" but you can increase the size of your history file to be pretty enormous. Is being able to find a command you ran 2 years ago really a valuable thing?