给Openwrt安装oh-my-zsh
Openwrt自带的那个破bash有点不好用,换成zsh试试吧。
首先下载安装zsh
wget https://downloads.openwrt.org/releases/packages-18.06/x86_64/packages/zsh_5.4.2-1_x86_64.ipk
opkg install zsh_5.4.2-1_x86_64.ipk
安装oh-my-zsh依赖
opkg install wget unzip ca-certificates
安装oh-my-zsh
sh -c "$(wget -O- https://raw.githubusercontent.com/felix-fly/openwrt-ohmyzsh/master/install.sh)"
ash设为默认shell
which zsh && sed -i -- 's:/bin/ash:'`which zsh`':g' /etc/passwd
安装自动补全插件
wget http://mimosa-pudica.net/src/incr-0.2.zsh
复制到插件目录~/.oh-my-zsh/plugins/incr/
在~/.zshrc加一行
source ~/.oh-my-zsh/plugins/incr/incr*.zsh
配置生效命令
source ~/.zshrc
以上就是我在github看到的使用说明文档。
当你按照Github上面的安装说明一步步装完后,
[RainBowText]你 会 发 现 100% 不 好 使 !!![/RainBowText]
Openwrt是个针对路由器的系统,和我们常用的不一样。
所以加点原创的内容:我们需要手动添加Openwrt适配,把针对Openwrt系统的命令/etc/shinit的内容手动加在~/.zshrc里
(你看下面这个service命令是咋实现的 :@(中枪) )
[ -x /bin/more ] || alias more=less
[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi
alias ll='ls -alF --color=auto'
[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc
[ -x /usr/bin/arp -o -x /sbin/arp ] || arp() { cat /proc/net/arp; }
[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
service() {
[ -f "/etc/init.d/$1" ] || {
echo "service "'"'"$1"'"'" not found, the following services are available:"
ls "/etc/init.d"
return 1
}
/etc/init.d/$@
}
[ -n "$KSH_VERSION" -o \! -s "$HOME/.shinit" ] || . "$HOME/.shinit"
[ -z "$KSH_VERSION" -o \! -s "$HOME/.mkshrc" ] || . "$HOME/.mkshrc"
最后安装自己喜欢的画风简单调整下显示,
放在oh-my-zsh安装文件夹/themes/选择的theme配置文件
PROMPT="
%{$terminfo[bold]$fg[blue]%}#%{$reset_color%} \
%{$fg[green]%}%n \
%{$fg[white]%}in \
%{$terminfo[bold]$fg[yellow]%}%~%{$reset_color%}\
${hg_info}\
${git_info}\
\
%{$fg[white]%}[%*] $exit_code
%{$terminfo[bold]$fg[red]%}$ %{$reset_color%}"
生效配置
source ~/.zshrc
输入ssh命令,连接!
完美。
(给路由器系统装omz是不是有点丧病)