Hacker News new | past | comments | ask | show | jobs | submit login

im pretty sure bash does shared history if you desire it, the configuration is just not as directly obvious.

I prefer a long histfile (unlimited really, i. think i have it set to a million lines, but im at about 70 000. i even keep it backed up regularly because its fairly easy to trash the histfile if you are opening subshells and do the wrongthing. timestamped, too, which i find really handy.

that said, i do use and like zsh on my primary workstation, love it.. but i dont bother priming every other remote box with it, my bash config is simple and tweaked up just rightfor remote servers, and bash is there by default (dealing with older systems, etc.....i know zsh is installed by default often too)




Bash configuration for shared history:

  # Append to ~/.bash_history instead of overwriting it -- this stops terminals
  # from overwriting one another's histories.
  shopt -s histappend
  # Only load the last 1000 lines from your ~/.bash_history -- if you need an
  # older entry, just grep that file.
  HISTSIZE=1000
  # Don't truncate ~/.bash_history -- keep all your history, ever.
  unset HISTFILESIZE
  # Add a timestamp to each history entry.
  HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S  "
  # Don't remember trivial 1- and 2-letter commands.
  HISTIGNORE=?:??
  # What it says.
  HISTCONTROL=ignoredups
  # Save each history entry immediately (protects against terminal crashes/
  # disconnections, and interleaves commands from multiple terminals in correct
  # chronological order).
  PROMPT_COMMAND="history -a; $PROMPT_COMMAND"


Sorry for being off-topic, but do you know how the ZSH history file gets trashed? It's happened so often to me that I wrote a script to reconstruct my history file by combining the last handful of backups. I still haven't figured out how the history file gets trashed though :-(

Edit: Since I'm in ZSH company, here's the script: https://gist.github.com/1713414


guessing, but could you be invoking zsh in such a way occasionally that it is not reading your .zshrc? sudo or su come to mind..... this is what got me in bash a few times - exiting a shell that had just the wrong ssettings so it ioverwrote my history.


I like a long history too. I actually automatically rotate my history file every quarter (copying over the 500 most recent entries) and keep around my old history files. It's actually come in really handy when I want to do something I last did two years ago.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: