Last active
July 29, 2025 08:43
-
-
Save Chord-Chen-30/5d84883ffe02c255f2e82199316d564e to your computer and use it in GitHub Desktop.
Install zsh without root. Also, oh-my-zsh and 2 plugins (zsh-autosuggestions zsh-syntax-highlighting).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Referenced from https://gist.github.com/ZhaofengWu/f345652e994e3b68c309352a7610460f. Nice scripts. | |
| # New feature: Add plugins zsh-autosuggestions and zsh-syntax-highlighting | |
| # 1. Set up your $HOME variable | |
| # 2. If you set a new HOME, it's likely required to install ncurces. (Even the following code might skip installing!) | |
| # 3. Read & Run the last few lines line-by-line | |
| # HOME=... | |
| set -e | |
| # zsh will not install without ncurses. IF your machine doesn't have ncurses, you need to install it first. | |
| if ! ldconfig -p | grep -q libncurses; then | |
| export CXXFLAGS=" -fPIC" CFLAGS=" -fPIC" CPPFLAGS="-I${HOME}/include" LDFLAGS="-L${HOME}/lib" | |
| wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.2.tar.gz | |
| tar -xzvf ncurses-6.2.tar.gz | |
| cd ncurses-6.2 | |
| ./configure --prefix=$HOME --enable-shared | |
| make | |
| make install | |
| cd .. && rm ncurses-6.2.tar.gz && rm -r ncurses-6.2 | |
| else | |
| echo "ncurses is already installed, skipping installation" | |
| fi | |
| # install zsh itself | |
| wget -O zsh.tar.xz https://sourceforge.net/projects/zsh/files/latest/download | |
| mkdir zsh && unxz zsh.tar.xz && tar -xvf zsh.tar -C zsh --strip-components 1 | |
| cd zsh | |
| ./configure --prefix=$HOME | |
| make | |
| make install | |
| cd .. && rm zsh.tar && rm -r zsh | |
| # OPTIONAL | |
| # echo -e "export SHELL=~/bin/zsh\nexec ~/bin/zsh -l" >> ~/.bash_profile # or chsh | |
| # Run line-by-line! | |
| # Make sure HOME is the directory you want first. | |
| export PATH=$HOME/bin:$PATH # To make shell find newly installed zsh for this time. | |
| # Install oh-my-zsh | |
| sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)" | |
| # Add plugins | |
| git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting | |
| git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | |
| # Modify your ~/.zshrc: | |
| # plugins=(git zsh-autosuggestions zsh-syntax-highlighting) |
Good job, Chord-Chen. Catch you torching fish during working!
Author
Good job, Chord-Chen. Catch you torching fish during working!
? 此所谓,磨刀不误砍柴工
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wonderful!