It's stored in ~/Library/Application Support. Whether that's safer than your shell's own history depends on your personal threat model. You can turn off "Prefs>General>Save copy/paste and command history to disk" to disable this if your mac is untrusted.