I recently re-installed the OS on my laptop. I had been using bash with the bash completion scripts, and come to quite like it. However, on the new system I didn't have completion available easily. So, I decided to try zsh. I've been meaning to for a while, but bash with completion was working well for me. I figured I'd try zsh, which is easily available.
The biggest part of getting comfortable was to get the correct settings in zsh so that it acts as I would like. I've ended up with a configuration that I really like. Here they are.
"setopt APPEND_HISTORY" -- Instead of overwriting the history file, instead it appends lines. This helps if there are multiple zsh sessions, so that they don't just overwrite the history. I run around 20 different terminals all the time, so this is handy.
"setopt INC_APPEND_HISTORY" -- Each shell, as it runs a command, appends the command to the history file right away. This way, each shell has a unique history while it's running, but stores an interleaved set of history in the file. Starting a new shell or restarting my X session, results in having access to my history as I executed it previously.
"unsetopt HIST_EXPIRE_DUPS_FIRST" -- I've disabled this, because it is a space saving option which removes duplicate history lines before limiting the number of lines. This option removes duplicated commands, even if they aren't sequential in history. I prefer to have my history sequentially complete, even if truncated.
"unsetopt BANG_HIST" -- If this were set, the "!" character in commands is treated specially. I never use it, so I prefer it not be treated specially.
"setopt HIST_FIND_NO_DUPS" -- With this set, searching in history will skip duplicate entries when searching. I'm not sure if I will like this in the long term, because sometimes I have the same command in different sets of commands, and I'm looking for different surrounding commands.
"setopt HIST_IGNORE_DUPS" -- If the same command is run multiple times in a row, it is only entered in history once.
"unsetopt CORRECT" -- Spelling corrections. I'm not sure I like that idea. I'd rather get an error if I typo, rather than the possibility that it corrects my spelling in a nasty way.
"setopt INTERACTIVE_COMMENTS" -- This allows you, from the command line, to enter comments. Without this, the # character is treated as a normal character. I like to comment out commands at times when I'm not quite ready to run them for some reason or am in the process of building a long command line and need to get some more information.
"setopt PRINT_EXIT_VALUE" -- If a command exits with a non-zero, zsh will display a message with the exit code.
"setopt CHECK_JOBS" -- If there are jobs running and you try to exit a shell, it will print a warning. There are other options that cause jobs to be backgrounded, but I prefer this setting.
"unsetopt HUP" -- When unset, HUP is not sent to jobs being run in the shell at exit.
"setopt NOTIFY" -- This option causes the shell to continually watch for background jobs and will report when they exit immediately instead of only before printing the next shell.
"unsetopt NOMATCH" -- If set, this option causes globs which do not match a file to result in an error without running the command. If unset, the command is run with the un-expanded glob. I do a lot of math at the command line and have gotten used to doing things like "5*7" without quoting. Just what I'm used to, but nice that I can customize it.
"hash -d tummyDoc=~/projects/tummy/tummyDoc/" -- This sets up a named directory, which can be used as a shortcut with "cd ~tummyDoc". This even works with expansion such as "cd ~tu
bindkey -M vicmd j vi-down-line-or-history
bindkey -M vicmd k vi-up-line-or-history
The default bindings for j and k move to the end of the line, but bash moves to the beginning. I prefer that, so these mappings emulate how bash works.
bindkey -M main -r '^[/'
By default, ESC followed by / will search for a string matching what is currently on the command-line. An interesting idea, but not the way I prefer to work. This causes ESC+/ to start searching as bash does.