- I'm using bash on Ubuntu. When I type "kill <tab>" I get a list of process numbers, not the list of files in my current directory as you imply.
- shared history sounds like a bug, not a feature. I have long lived terminals open, each dedicated to a specific purpose. Shared history would intermingle them.
- typing `gut` in bash gives me:
No command 'gut' found, did you mean:
Command 'cut' from package 'coreutils' (main)
Command 'get' from package 'code-aster-run' (universe)
Command 'gout' from package 'scotch' (universe)
Command 'git' from package 'git' (main)
Command 'gpt' from package 'gpt' (universe)
Command 'gst' from package 'gnu-smalltalk' (universe)
You're batting 0/3. Certainly there must be some advantages to ZSH, but you haven't listed any yet.
(Note that I didn't have to configure any of this. Ubuntu probably did, but I didn't).
2. More importantly, in ZSH if the correction is accepted by the user the command gets executed (with the fix) without any manual redoing. The correction can even be made permanent for frequent typos.
(and while I like ZSH a lot, shared history does tend to be a pain in the ass for me)
How about the fact that zsh enforces that you spend a certain amount of time per day just contemplating your existence:
% time zsh -c exit
zsh -c exit 0.22s user 0.21s system 97% cpu 0.436 total
$ time bash -c exit
bash -c exit 0.00s user 0.00s system 83% cpu 0.004 total
Typing too early will just blackhole your keystrokes, of course, so no cheating!
Or how about how when using an RPROMPT it makes copy/pasting stuff out of the terminal infuriate your IM buddies?
:)
Actually these are downsides, let's try fish instead, maybe?
% brew install fish
% fish
zsh: correct 'fish' to 'vis' [nyae]? GRRR
Shared history in zsh is essential to my workflow. I also keep many terminals open, and while I do separate them by task, I often just pick one which happens to be in the right directory and start typing away. I always search through history using Ctrl-R, and almost never use up-arrow cycling. Shared history makes this work seamlessly.
This is obviously configurable, so if you prefer a different workflow, zsh will accomodate it.
about the 3'rd thing, that's not a bash thing - that's a ubuntu thing, which nicely integrates with bash by default.
You could get the same thing by putting
function command_not_found_handler() {
/usr/bin/python /usr/lib/command-not-found -- $1
}
Zsh use's zle(Z-Shell Line Editor), which is different then libreadline as its part of the shell not a separate library. Zle's behavior is editable through your .zshrc.
Maybe I dumbed the post down too much, was just listing a few features that I use every day that IMO work better then the comparable Bash features.
Shared history can be either a burden or a godsend, I like it but I usually just end up using whatever basic bash shell I'm on without a custom config as most of the things I do are remote.
The zsh autocorrect works much differently than what you have given. You have shown a feature of ubuntu (and probably debian) that looks for packages matching/close to your given command but what zsh does is give you, depending on your chosen settings, full autocorrect.
Where you may be able to type gut status and get No command found the setup in zsh would allow either for gut status to be autocorrected to git status or would ask you if you meant git status while waiting for a confirmation.
Zsh has knobs for shared history. You can configure all terminals to have the same history at the same time, but I have it set to add history to the .zsh_history file immediately, but each shell gets it's own history. So ctrl-r in a shell lists commands entered into that shell (or preexisting when it started), and opening a new terminal starts with the shared history from all terminals. This is really the best of both worlds. Also there's a knob to only add a command if it isn't in the history, so no scrolling back over a dozen "cd .." or whatever.
Zsh has floating point math, for instance $((1.0/2)) is 0.5 instead of an error. This comes in handy sometimes in simple scripts.
Zsh is significantly faster.
Zsh autocomplete is much more advanced. Bash may have copied the pid completion and some other easy ones, but zsh has all sorts of completion hooks, for instance "svn help ch<tab>" expands to "changelist". It also runs --help and parses out GNU style help text for completing options.
Zsh completion also has optional Windows-style cycle mode, so you can do "prefix<tab><tab>"... and cycle through the matches instead of prefix<tab>a<tab><tab>b<tab>-<tab>" like in bash. I think you can actually make bash do this but it's some obscure key binding.
...basically zsh is just a bit better at everything.
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)
# 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 :-(
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.
wow - would you know the settings for the whole shared history thing you wrote about. I have mine set up in a less than ideal way and have never been able to google for these settings.
These are the history setopt's I have, but I don't know if they all make sense with each other though. I set it up once and haven't touched it in years.
HIST_IGNORE_DUPS # don't add multiple 'cd ..', etc in a row?
HIST_EXPIRE_DUPS_FIRST # save unique hist entries longer
HIST_VERIFY # edit recalled history before running
INC_APPEND_HISTORY # add commands to .history immediately
EXTENDED_HISTORY # save timestamp on history entries
# set a huge history... doesn't seem to affect performance at all
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=$((HISTSIZE/2))
For the completion I setopt AUTO_REMOVE_SLASH GLOB_COMPLETE MENU_COMPLETE NO_AUTO_LIST NO_BAD_PATTERN NO_BEEP NO_LIST_AMBIGUOUS NO_LIST_BEEP NO_NOMATCH, but I'm not sure what they all do ;-P
- shared history sounds like a bug, not a feature. I have long lived terminals open, each dedicated to a specific purpose. Shared history would intermingle them.
- typing `gut` in bash gives me:
You're batting 0/3. Certainly there must be some advantages to ZSH, but you haven't listed any yet.(Note that I didn't have to configure any of this. Ubuntu probably did, but I didn't).