5 ms·
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
by masukomi 7y ago
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?
- ndrake 7y agoI 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. # Custom history logging # From: http://blog.andrewhays.net/love-your-terminal http://blog.andrewhays.net/love-your-terminal # https://web.archive.org/web/20130525150720/http://blog.andrewhays.net/love-your-terminal https://web.archive.org/web/20130525150720/http://blog.andre... function precmd() { if [ "$(id -u)" -ne 0 ]; then FULL_CMD_LOG="$HOME/.shlogs/zsh-history-$(date -u "+%Y-%m-%d").log" echo "$USER@`hostname`:`pwd` [$(date)] `\history -1`" >> ${FULL_CMD_LOG} fi }
- jlgaddis 7y agoHN 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).
- krab 7y agoI guess it's for people accessing multiple systems (perhaps ephemeral virtual machines) to have shared shell history.
- ajphdiv 7y agoI 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.
- masukomi 7y agonot 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.
- jdevera 7y agoI also use those. They came from here: https://eli.thegreenplace.net/2013/06/11/keeping-persistent-history-in-bash/ https://eli.thegreenplace.net/2013/06/11/keeping-persistent-...
- nicksherron 7y agoYes, 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.
- maximente 7y agofor 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.