58
loading...
This website collects cookies to deliver better user experience
Autocompletion and history-based autocompletion using the arrow keys.
The fancy multi-line and colorful user prompt showing the working directory, and the switching color after the fail/success of the previous command execution.
The git repository info at the user prompt.
The z
command, provided by the ZSH-z plugin.
To enable the standard autocompletion.
To set up history-based autocompletion.
This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~). This function can help you with a few settings that should
make your use of the shell easier.
You can:
(q) Quit and do nothing. The function will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment.
That will prevent this function being run again.
(1) Continue to the main menu.
-------- Type one of the keys in parentheses ---
Type 0
to exit the Zsh helper creating a blank .zshrc
file in your $HOME
directory.
To load and initialize the Zsh completion system, open the .zshrc
file in your code editor and add the following line at the top of the file:
# AUTOCOMPLETION
# initialize autocompletion
autoload -U compinit && compinit
man zshcompsys
and go to Use of compinit
).zshrc
file:
# history setup
setopt SHARE_HISTORY
HISTFILE=$HOME/.zhistory
SAVEHIST=1000
HISTSIZE=999
setopt HIST_EXPIRE_DUPS_FIRST
man zshoptions
and man zshparam
)# autocompletion using arrow keys (based on history)
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
[A
is the value your terminal emulator sends for the keyboard up arrow, and that [B
is the value for the keyboard down arrow.man zshzle
and go to ZLE BUILTINS
for key bindings, and go to history-search-
.).zshrc
file again, in the Zsh shell type:
source ~/.zshrc
.zshrc
file must look like this:# AUTOCOMPLETION
# initialize autocompletion
autoload -U compinit
compinit
# history setup
setopt APPEND_HISTORY
setopt SHARE_HISTORY
HISTFILE=$HOME/.zhistory
SAVEHIST=1000
HISTSIZE=999
setopt HIST_EXPIRE_DUPS_FIRST
setopt EXTENDED_HISTORY
# autocompletion using arrow keys (based on history)
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
# GENERAL
# (bonus: Disable sound errors in Zsh)
# never beep
setopt NO_BEEP
With those simple steps autocompletion is ready and your Zsh shell is becoming more powerful.
Part 2 explores how to apply a simple configuration to improve the user prompt.
This post appeared first at alldrops.info.
Follow me on Twitter to get more posts like this and other quick tips in your feed.
If you have any doubts or tips about this post, I’d appreciate knowing and discussing it in the comments section.
As English is not my native language, I apologize for the errors. Corrections are welcome.
Big thanks 🙌 to Eric Nielsen for pointing out some improvements in Zsh history settings.