Linux非root用戶安裝zsh, 并用oh-my-zsh進(jìn)行配置

安裝 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="絕對(duì)路徑(我安裝在了 zsh/ 下)"  # 指定路徑configure
make && make install  # 安裝

如果出現(xiàn)問題可以接著看, 如果沒出現(xiàn)問題跳過

問題

./configure 時(shí)出現(xiàn)問題

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 時(shí)出現(xiàn)問題

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

看看 ./configure 時(shí)是不是已經(jīng)出現(xiàn)問題被你忽視了

如何解決

先配置相應(yīng)環(huán)境變量, 執(zhí)行以下命令

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 里也可以, 記得運(yùn)行 source ~/.bashrc 命令使環(huán)境變量生效

然后安裝 ncurses , 找到最新版本ncurses下載安裝

cd ../../ && mkdir ncurses && cd ncurses  # 切換到上級(jí)目錄新建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="絕對(duì)路徑(我安裝在了 ncurses/ 下)" --with-shared --without-debug --enable-widec  # 指定路徑configure
make && make install  # 安裝

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

安裝 oh-my-zsh

安裝 oh-my-zsh 前先將安裝好的 zsh 所在的路徑添加到系統(tǒng)環(huán)境變量 PATH

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

安裝 oh-my-zsh 幾種方法

# 方法一:wget方式自動(dòng)化安裝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 

# 官網(wǎng)上的另外一種寫法
$ 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)"

# 方法三:手動(dòng)安裝
$ 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

以上都安裝好后運(yùn)行以下命令即可

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

因?yàn)槭欠莚oot用戶, 考慮到多人使用同一臺(tái)服務(wù)器, 為了不影響其他人建議將命令寫到導(dǎo)入自己環(huán)境的腳本而不是 ~/.bashrc

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容