Skip to content

Instantly share code, notes, and snippets.

@ZhaofengWu
Last active November 14, 2024 14:53
Show Gist options
  • Save ZhaofengWu/f345652e994e3b68c309352a7610460f to your computer and use it in GitHub Desktop.
Save ZhaofengWu/f345652e994e3b68c309352a7610460f to your computer and use it in GitHub Desktop.
Install zsh without root
#!/bin/bash
set -e
# OPTIONAL: zsh will not install without ncurses. IF your machine doesn't have ncurses, you need to install it first.
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
# 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
echo -e "export SHELL=~/bin/zsh\nexec ~/bin/zsh -l" >> ~/.bash_profile # or chsh
# OPTIONAL: install oh-my-zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
@sahiljhawar
Copy link

This script more or less worked. My group has multiple machines with different configurations, however for all the machines the $HOME directory is the same. oh-my-zsh works perfectly fine when I ssh to one of the inferior machine, but when I ssh to one of the powerful machines for actual computation the following error occurs:

/etc/zshrc:71: compinit: function definition file not found
/home/powermachine/myuser/.oh-my-zsh/oh-my-zsh.sh:131: compinit: function definition file not found
/home/powermachine/myuser/.oh-my-zsh/oh-my-zsh.sh:154: zrecompile: function definition file not found
/home/powermachine/myuser/.oh-my-zsh/lib/completion.zsh:78: bashcompinit: function definition file not found
 compdef: command not found
/home/powermachine/myuser/.oh-my-zsh/lib/termsupport.zsh:108: add-zsh-hook: function definition file not found
/home/powermachine/myuser/.oh-my-zsh/lib/termsupport.zsh:109: add-zsh-hook: function definition file not found
/home/powermachine/myuser/.oh-my-zsh/lib/theme-and-appearance.zsh:2: colors: function definition file not found
 compdef: command not found
 compdef: command not found
 compdef: command not found
 compdef: command not found
/home/powermachine/myuser/.oh-my-zsh/plugins/git/git.plugin.zsh:219: is-at-least: function definition file not found
 compdef: command not found
 compdef: command not found
 compdef: command not found
 compdef: command not found
/home/powermachine/myuser/.oh-my-zsh/plugins/git/git.plugin.zsh:297: is-at-least: function definition file not found
 compdef: command not found
/home/powermachine/myuser/.oh-my-zsh/plugins/git/git.plugin.zsh:308: is-at-least: function definition file not found
 compdef: command not found
/home/powermachine/myuser/.oh-my-zsh/plugins/git/git.plugin.zsh:367: is-at-least: function definition file not foundf

Do you have any solution for this?

@ZhaofengWu
Copy link
Author

Sorry I don't know what causes this :(

@zhuzzz
Copy link

zhuzzz commented Jan 31, 2024

Thanks for the script! Works like a charm :)

@NiklasRoberts
Copy link

Works perfectly, thanks!

@sahiljhawar
Copy link

sahiljhawar commented May 21, 2024

This is not a promotion or spam, but for those people who cannot run oh-my-zsh due to some limitations and are using oh-my-bash but facing sluggish performance. I highly suggest all of them to watch this video and setup all the plugins independent of oh-my-zsh. Works flawlessly!

IMAGE ALT TEXT

@LeetIDA
Copy link

LeetIDA commented Sep 18, 2024

[A2023@student1 zsh]$ ./configure --prefix=$HOME
configuring for zsh 5.9
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to run the C preprocessor... gcc -E
checking for an ANSI C-conforming const... yes
checking for gcc option to accept ANSI C...
checking whether to use prototypes... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for sys/param.h... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking if the compiler supports union initialisation... yes
checking if signed to unsigned casting is broken... no
checking if the compiler supports variable-length arrays... yes
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking for gawk... gawk
checking whether ln works... yes
checking whether ln -s works... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for yodl... no
checking for texi2dvi... no
checking for texi2pdf... no
checking for texi2any... no
checking for texi2html... no
checking for ansi2knr... no
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking whether stat file-mode macros are broken... no
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for sys/time.h... yes
checking for sys/times.h... yes
checking for sys/select.h... yes
checking for termcap.h... no
checking for termio.h... yes
checking for termios.h... yes
checking for sys/param.h... (cached) yes
checking for sys/filio.h... no
checking for string.h... (cached) yes
checking for memory.h... yes
checking for limits.h... yes
checking for fcntl.h... yes
checking for libc.h... no
checking for sys/utsname.h... yes
checking for sys/resource.h... yes
checking for locale.h... yes
checking for errno.h... yes
checking for stdio.h... (cached) yes
checking for stdarg.h... yes
checking for varargs.h... no
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/capability.h... no
checking for utmp.h... yes
checking for utmpx.h... yes
checking for sys/types.h... (cached) yes
checking for pwd.h... yes
checking for grp.h... yes
checking for poll.h... yes
checking for sys/mman.h... yes
checking for netinet/in_systm.h... yes
checking for pcre.h... yes
checking for langinfo.h... yes
checking for wchar.h... yes
checking for stddef.h... yes
checking for sys/stropts.h... no
checking for iconv.h... yes
checking for ncurses.h... no
checking for ncursesw/ncurses.h... no
checking for ncurses/ncurses.h... no
checking for dlfcn.h... yes
checking for dl.h... no
checking for conflicts in sys/time.h and sys/select.h... no
checking TIOCGWINSZ in termios.h... no
checking TIOCGWINSZ in sys/ioctl.h... yes
checking for streams headers including struct winsize... no
checking for printf in -lc... yes
checking for pow in -lm... yes
checking for clock_gettime in -lrt... yes
checking if _XOPEN_SOURCE_EXTENDED should not be defined... no
checking for library containing tigetstr... no
checking for library containing tigetflag... no
checking for library containing tgetent... no
configure: error: in /home/A2023/zsh': 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

@paour
Copy link

paour commented Sep 20, 2024

I'm getting the same issue as @LeetIDA.

@sahiljhawar
Copy link

You have to install ncurses on your machine. I think ncurses can be compiled without sudo.

@paour
Copy link

paour commented Sep 20, 2024

I've since found this project, which makes it much simpler https://github.com/romkatv/zsh-bin.

@sahiljhawar
Copy link

Mostly the issues arises with OMZ and not zsh. Most modern HPC/clusters already have zsh installed on them. That's why I linked that video

@LeetIDA
Copy link

LeetIDA commented Sep 20, 2024

I've since found this project, which makes it much simpler https://github.com/romkatv/zsh-bin.

Tysm <3

@ZhaofengWu
Copy link
Author

You should be able to install ncurses using the first part of this script.

@Chord-Chen-30
Copy link

Nice scripts! Works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment