Overview
1. ZSH
1.1 下载
1.2 编译
解压:
$ tar xvJf zsh-5.7.1.tar.xz
...
$ cd zsh-5.7.1
“为自己”编译
zsh-5.7.1$ ./configure --prefix=$HOME
...
...
checking whether libraries can be stripped... yes
configure: creating ./config.status
config.status: creating Config/defs.mk
config.status: creating Makefile
config.status: creating Doc/Makefile
config.status: creating Etc/Makefile
config.status: creating Src/Makefile
config.status: creating Test/Makefile
config.status: creating config.h
config.status: executing config.modules commands
creating ./config.modules
config.status: executing stamp-h commands
zsh configuration
-----------------
zsh version : 5.7.1
host operating system : i686-pc-linux-gnu
source code location : .
compiler : gcc
preprocessor flags :
executable compiler flags : -Wall -Wmissing-prototypes -O2
module compiler flags : -Wall -Wmissing-prototypes -O2 -fPIC
executable linker flags : -s -rdynamic
module linker flags : -s -shared
library flags : -ldl -ltinfo -lrt -lm -lc
installation basename : zsh
binary install path : /home/joseph/bin
man page install path : /home/joseph/share/man
info install path : /home/joseph/share/info
functions install path : /home/joseph/share/zsh/5.7.1/functions
See config.modules for installed modules and functions.
zsh-5.7.1$
zsh-5.7.1$ make
...
1.3 安装
zsh-5.7.1$ mkdir ~/bin
zsh-5.7.1$ mkdir ~/share
zsh-5.7.1$
zsh-5.7.1$ make install
...
fi; \
exit 0
mkdir -m 755 -p -- /home/joseph/share/zsh/site-functions
mkdir -m 755 -p -- /home/joseph/share/zsh/5.7.1/functions
mkdir -m 755 -p -- /home/joseph/share/zsh/5.7.1/scripts
make[1]: Entering directory '/home/joseph/Software/zsh-5.7.1/Doc'
/bin/sh ../mkinstalldirs /home/joseph/share/man/man1
mkdir -m 755 -p -- /home/joseph/share/man/man1
for file in zsh.1 zshbuiltins.1 zshcalsys.1 zshcompctl.1 zshcompwid.1 zshcompsys.1 zshcontrib.1 zshexpn.1 zshmisc.1 zshmodules.1 zshoptions.1 zshparam.1 zshroadmap.1 zshtcpsys.1 zshzftpsys.1 zshzle.1 zshall.1; do \
test -s $file || exit 1; \
/usr/bin/install -c -m 644 $file /home/joseph/share/man/man1/`echo $file | sed 's|zsh|zsh|'` || exit 1; \
done
make[1]: Leaving directory '/home/joseph/Software/zsh-5.7.1/Doc'
make[1]: Entering directory '/home/joseph/Software/zsh-5.7.1/Doc'
if test x"/home/joseph/share/zsh/5.7.1/help" != x""; then \
/bin/sh ../mkinstalldirs /home/joseph/share/zsh/5.7.1/help; \
/usr/bin/install -c -m 644 help/* /home/joseph/share/zsh/5.7.1/help; \
while read from to; do \
rm -f /home/joseph/share/zsh/5.7.1/help/$to || : ; \
ln -s $from /home/joseph/share/zsh/5.7.1/help/$to; \
done < help.txt; \
fi
mkdir -m 755 -p -- /home/joseph/share/zsh/5.7.1/help
make[1]: Leaving directory '/home/joseph/Software/zsh-5.7.1/Doc'
joseph@calix:zsh-5.7.1$
1.4 运行 Z sh
zsh-5.7.1$ exit
...reconnect...
$ zsh
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 --- 0
$
$
2. oh-my-zsh
2.1 安装
$ wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
--2019-07-19 16:34:24-- https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh
Resolving github.com (github.com)... 13.229.188.59
Connecting to github.com (github.com)|13.229.188.59|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh [following]
--2019-07-19 16:34:25-- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7759 (7.6K) [text/plain]
Saving to: ‘STDOUT’
- 100%[================================================>] 7.58K --.-KB/s in 0s
2019-07-19 16:34:26 (32.7 MB/s) - written to stdout [7759/7759]
Cloning Oh My Zsh...
Cloning into '/home/joseph/.oh-my-zsh'...
remote: Enumerating objects: 1048, done.
remote: Counting objects: 100% (1048/1048), done.
remote: Compressing objects: 100% (966/966), done.
remote: Total 1048 (delta 23), reused 838 (delta 19), pack-reused 0
Receiving objects: 100% (1048/1048), 694.62 KiB | 202.00 KiB/s, done.
Resolving deltas: 100% (23/23), done.
Checking connectivity... done.
Looking for an existing zsh config...
Found ~/.zshrc. Backing up to /home/joseph/.zshrc.pre-oh-my-zsh
Using the Oh My Zsh template file and adding it to ~/.zshrc.
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us on https://twitter.com/ohmyzsh
p.p.s. Get stickers, shirts, and coffee mugs at https://shop.planetargon.com/collections/oh-my-zsh
Run zsh to try it out.
$ zsh
→ ~
→ ~
2.2 插件
2.2.1 自动补齐插件 incr
$ mkdir ~/.oh-my-zsh/plugins/incr
$ wget http://mimosa-pudica.net/src/incr-0.2.zsh
$ mv incr-0.2.zsh ~/.oh-my-zsh/plugins/incr/
$ echo "source ~/.oh-my-zsh/plugins/incr/incr*.zsh" >> ~/.zshrc
Reference: oh-my-zsh,让你的终端从未这么爽过 ?
2.3 其它 - N/A
3. Known Issue
3.1 [Home], [End] Key not working
Issue:
如果出现了按下 [Home] 键 或 [End] 键没有反应(显示 ~
)的情况
Sulution:
在桌面 Terminal(Ubuntu 自带的终端软件) 上使用 zsh 就没有这个问题。不过使用 XShell 通过 SSH 连接就会出现这个问题(搜索解决方案的时候看到说 XTerm 也有这个问题)
为 ~/.zshrc
增加以下:
$ vim ~/.zshrc
[...codes...]
######################################################
# fix 'oh my zsh' keyboard bug #
######################################################
#Rebind HOME and END to do the decent thing:
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
case $TERM in (xterm*)
bindkey '\eOH' beginning-of-line
bindkey '\eOF' end-of-line
esac
#To discover what keycode is being sent, hit ^v
#and then the key you want to test.
#And DEL too, as well as PGDN and insert:
bindkey '\e[3~' delete-char
bindkey '\e[6~' end-of-history
bindkey '\e[2~' redisplay
#Now bind pgup to paste the last word of the last command,
bindkey '\e[5~' insert-last-word
:wq
$ source ~/.zshrc # or exit > reconnect again
可能小键盘也会有问题(不过我没有小键盘),更多的按键无效问题参考 ? Cannot using home/end key after install oh-my-zsh
一份博文内容写得不错的参考 ? xshell 使用 Oh My ZSH home键 end键 小键盘区无效解决办法