Linux非root用户安装zsh, 并用oh-my-zsh进行

2019-11-20  本文已影响0人  elephantnose

安装 zsh

mkdir zsh && cd zsh  # 新建文件夹
wget https://sourceforge.net/projects/zsh/files/latest/download  # 下载最新版本zsh
xz -d zsh-5.7.1.tar.xz  # .tar.xz 文件需要解压两次
tar -xvf zsh-5.7.1.tar
cd zsh-5.7.1
./configure --prefix="绝对路径(我安装在了 zsh/ 下)"  # 指定路径configure
make && make install  # 安装

如果出现问题可以接着看, 如果没出现问题跳过

问题

./configure 时出现问题

configure: error: "No terminal handling library was found on your system.
This is probably a library called 'curses' or 'ncurses'.  You may
need to install a package called 'curses-devel' or 'ncurses-devel' on your
system."
See `config.log' for more details

make && make install 时出现问题

make: *** No targets specified and no makefile found.  Stop.

看看 ./configure 时是不是已经出现问题被你忽视了

如何解决

先配置相应环境变量, 执行以下命令

export CXXFLAGS="-fPIC"
export CFLAGS="-fPIC"
export NCURSES_HOME=$HOME/ncurses  # 你自己的 ncurses 目录
export PATH=$NCURSES_HOME/bin:$PATH
export LD_LIBRARY_PATH=$NCURSES_HOME/lib:$LD_LIBRARY_PATH
export CPPFLAGS="-I$NCURSES_HOME/include" LDFLAGS="-L$NCURSES_HOME/lib"

方便以后用将以上命令写到 ~/.bashrc 里也可以, 记得运行 source ~/.bashrc 命令使环境变量生效

然后安装 ncurses , 找到最新版本ncurses下载安装

cd ../../ && mkdir ncurses && cd ncurses  # 切换到上级目录新建ncurses文件夹
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz  # 下载最新版本ncurses
tar -xzvf ncurses-6.1.tar.gz  # 解压
cd ncurses-6.1
./configure --prefix="绝对路径(我安装在了 ncurses/ 下)" --with-shared --without-debug --enable-widec  # 指定路径configure
make && make install  # 安装

回到zsh下重新 ./configuremake && make install 就可以了

安装 oh-my-zsh

安装 oh-my-zsh 前先将安装好的 zsh 所在的路径添加到系统环境变量 PATH

export PATH=$HOME/zsh/bin:$PATH

安装 oh-my-zsh 几种方法

# 方法一:wget方式自动化安装oh my zsh:
$ wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

# 方法二:
$ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh 

# 官网上的另外一种写法
$ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
$ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

# 方法三:手动安装
$ git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh 
注: 1. 克隆后将templates目录下的zsh配置文件拷贝至~/.zshrc即可
    2. .oh-my-zsh一定要在$HOME下( ~ 下)

oh-my-zsh官方github地址

使用zsh

以上都安装好后运行以下命令即可

exec $HOME/zsh/bin/zsh  # 你的zsh路径

因为是非root用户, 考虑到多人使用同一台服务器, 为了不影响其他人建议将命令写到导入自己环境的脚本而不是 ~/.bashrc

上一篇下一篇

猜你喜欢

热点阅读