Live data from Hacker News

Fixing macOS Zsh Terminal History Settings

blog.akatz.org

11–20 of 66 posts

Re: Fixing macOS Zsh Terminal History Settings

#11

OT but the first command I type on a new install of MacOS is $ chsh -s /bin/bash because I have 20 years worth of bash scripts that I've carefully tailored to work on bash in MacOS and Linux and I don't have time to rewrite them all just because Apple decided they don't like GPLv3.

doesn’t mac show a bash deprecation warning or something else that’s obnoxious when you do that?

  export BASH_SILENCE_DEPRECATION_WARNING=1

Re: Fixing macOS Zsh Terminal History Settings

#12

OT but the first command I type on a new install of MacOS is $ chsh -s /bin/bash because I have 20 years worth of bash scripts that I've carefully tailored to work on bash in MacOS and Linux and I don't have time to rewrite them all just because Apple decided they don't like GPLv3.

To each their own, but know that you are stuck with a really old version of bash if you do that, and it has some “interesting” bugs in it.

See something I wrote a little while ago on this topic: https://jmmv.dev/2019/11/macos-bash-baggage.html

Re: Fixing macOS Zsh Terminal History Settings

#13

OT but the first command I type on a new install of MacOS is $ chsh -s /bin/bash because I have 20 years worth of bash scripts that I've carefully tailored to work on bash in MacOS and Linux and I don't have time to rewrite them all just because Apple decided they don't like GPLv3.

You can still run Bash from Zsh. Your terminal shell is irrelevant.

Re: Fixing macOS Zsh Terminal History Settings

#14

I often have multiple concurrent sessions of terminal open, which leads to messed up history interactions. One solution I've encountered (but have not tested yet) is zsh-histdb [0]. It stores sessions' history to a SQLite db instead of a single appended file, with extra metadata about when commands were run, what session, etc. If you've already got your .zshrc file open to mess with the history settings it might be w…

I'd given up on shared history because it never worked the way I like. This looks very promising, thank you.

Re: Fixing macOS Zsh Terminal History Settings

#15

I often have multiple concurrent sessions of terminal open, which leads to messed up history interactions. One solution I've encountered (but have not tested yet) is zsh-histdb [0]. It stores sessions' history to a SQLite db instead of a single appended file, with extra metadata about when commands were run, what session, etc. If you've already got your .zshrc file open to mess with the history settings it might be w…

If somebody is interested in macos app for storing your history (bash,zsh,fish) and syncing it with icloud, I have built an app ShellHistory, v2 is available via TestFlight if you want to try it. https://loshadki.app/blog/2022-09-22-public-beta-shellhistor... (monterey and ventura) And this is a link to v1 https://loshadki.app/shellhistory/ (big sur+)

Been using this for about a year, well worth the $12. Thanks man!

Saves me finding a command I ran but I don't remember when, or in which of my 50+ open and not committed shells. Also the exit code of every command is super helpful.

Re: Fixing macOS Zsh Terminal History Settings

#16

Earlier quoted context omitted.

If somebody is interested in macos app for storing your history (bash,zsh,fish) and syncing it with icloud, I have built an app ShellHistory, v2 is available via TestFlight if you want to try it. https://loshadki.app/blog/2022-09-22-public-beta-shellhistor... (monterey and ventura) And this is a link to v1 https://loshadki.app/shellhistory/ (big sur+)

Been using this for about a year, well worth the $12. Thanks man! Saves me finding a command I ran but I don't remember when, or in which of my 50+ open and not committed shells. Also the exit code of every command is super helpful.

Thank you for feedback! Appreciate to see a user from HN :D

Re: Fixing macOS Zsh Terminal History Settings

#17

OT but the first command I type on a new install of MacOS is $ chsh -s /bin/bash because I have 20 years worth of bash scripts that I've carefully tailored to work on bash in MacOS and Linux and I don't have time to rewrite them all just because Apple decided they don't like GPLv3.

Especially annoying if you have scripts that are meant to be sourced by the shell i.e. the shebang doesn't help you.

Re: Fixing macOS Zsh Terminal History Settings

#18

OT but the first command I type on a new install of MacOS is $ chsh -s /bin/bash because I have 20 years worth of bash scripts that I've carefully tailored to work on bash in MacOS and Linux and I don't have time to rewrite them all just because Apple decided they don't like GPLv3.

I haven’t personally found any system bash scripts that don’t work on system zsh, but I don’t use many bash features because the macOS system bash was so old and outdated. YMMV of course.

Re: Fixing macOS Zsh Terminal History Settings

#19
post #17

OT but the first command I type on a new install of MacOS is $ chsh -s /bin/bash because I have 20 years worth of bash scripts that I've carefully tailored to work on bash in MacOS and Linux and I don't have time to rewrite them all just because Apple decided they don't like GPLv3.

Especially annoying if you have scripts that are meant to be sourced by the shell i.e. the shebang doesn't help you.

I that case you could try to emulate bash before sourcing the script

Re: Fixing macOS Zsh Terminal History Settings

#20
This is zsh specific, but here's something I've been burned by enough times that I specifically wanted to mention it: save your history in a file other than the default one. Why? Because if you increase the history limit, and your profile isn't sourced for any reason, the shell will read your history file and use the default history size, clobbering everything that's there. If you use a non-default history file this rogue shell (missing your settings) will dump its history into the default file and leave your custom file untouched.
Post reply on HN