Install iterm2 on mac computer
Download address: https://iterm2.com
The terminal that comes with the Mac computer feels too simple to use, so I chose a new terminal window. iterm2 is an application that can be used after installation. However, the terminal page is too black and white, so install the corresponding plug-in and make it appear highlighted.
InstallOh my zsh
The configured address is: https://sourabhbajaj.com/mac-setup/iTerm/zsh.htmlInstallation
method:
sh -c “$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)”
The official document requires changing the command mode
chsh -s $(which zsh)
, but I did not use this command during installation.
theme
Changing the theme is as easy as changing a string in the configuration file. The default theme is robbyrussell. Just change the value to change the theme and don't forget to apply the changes.
ZSH_THEME=pygmalion
I'm used to the terminal showing the full file path,
so I changed the default configuration
and entered the commandvim ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
PROMPT="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT+=' %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"
The above is the default configuration. Modify the second line to
PROMPT+=' %{$fg[cyan]%}$PWD%{$reset_color%} $(git_prompt_info)'
so that you can get the complete path.
Configuration highlighting
Enter the command to download the plug-in.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
Enter ~/.zshrc
the file and add it last.source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
This
/usr/local/share/zsh-syntax-highlighting/
path is the specific file address you downloaded
Excuting an ordersource ~/.zshrc
Modify the terminal prefix
It depends on the theme you choose before you can modify the configuration.
First, check the theme configuration of your own machine.
cat ~/.zshrc | grep ZSH_THEME
ZSH_THEME="agnoster"
# Setting this variable when ZSH_THEME=random will cause zsh to load
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
I am using the agnoster theme here, and the file I modified is the following configuration
vim ~/.oh-my-zsh/themes/agnoster.zsh-theme
# Context: user@hostname (who am I and where am I)
>prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
#原先下面那一行是没有注释掉的也就是后面是$n@%m的这一行,再下面一行是我改的
# prompt_segment black default "%(!.%{%F{yellow}%}.)$n@%m"
prompt_segment black default "%(!.%{%F{yellow}%}.)$n"
fi
}
Then execute source ~/.zshrc
and reload the configuration
Autocomplete command
Plug-in download command git clone https://github.com/zsh-users/zsh-autosuggestions
Then edit vim ~/.zshrc
the file, find plugins
the configuration, and add zsh-autosuggestions
the plug-in.
Then execute source ~/.zshrc
and reload the configuration