|
General information about using zsh, including the default
set up and what you might want to put in your own
~/.zshrc file.
Your history will be saved in ~/.zsh_history.
You can change that by adding: HIST=filename to
your ~/.zshrc. You can also change
HISTSIZE for number of lines to save.
Emacs keybindings are on by default.
Tab completion is not. Please use these commands for
completion or you may get errors when logging into different
architectures:
if [[ "$ZSH_VERSION" == (3.1|4)* ]] ; then
autoload -U compinit
compinit -d "${HOME}/.zcompdump.${WHATAMI}"
zmodload -i zsh/complist
fi
You can set your prompt using PS1/PS2 here's an example:
PS1="[%n@%m]: %B%~%b
%# "
PS2="[%n@%m]: %B%~%b
%_> "
You can use literal newlines like this to put a newline in
your prompt. This one looks like:
[user@host]: your/current/path
%
You can add support for csh style variable exports (setenv)
like so:
setenv () { typeset -x "${1}${1:+=}${(@)argv[2,$#]}" }
| Completion Type |
Command |
| Full |
zstyle ':completion:*' completer _complete _list _oldlist _expand _ignored \
_match _correct _approximate _prefix
|
| Username |
users=(root joe user guest etc) ## complete usernames
zstyle ':completion:*' users $users
|
| Hostname |
hosts=( $(<~/etc/hosts) )
zstyle ':completion:*' hosts $hosts
compctl -k hosts + ncftp ping rwho traceroute host mtr dig
Add any commands for which you
wish to use hostname completion to the last line.
|
Using the setopt command
setoptis zsh's command to set user preferences.
Useful ones are explained in the setopt command table below.
| Command |
Description |
| setopt always_to_end |
Go to the end of the word upon completion |
| setopt NO_beep |
No error beeps |
| setopt complete_in_word |
In-word completion |
| setopt NO_correct |
Turn OFF spellchecking |
| setopt hist_expire_dups_first |
History expires duplicate commands |
| setopt ksh_arrays |
Enable ksh-like array handling |
|