jean-zay-doc icon indicating copy to clipboard operation
jean-zay-doc copied to clipboard

Document how to use zsh

Open lesteve opened this issue 4 years ago • 8 comments

  • install zsh from conda-forge
  • source /gpfslocalsup/spack_soft/environment-modules/current/init/zsh so that the module command works.
  • launch zsh directly when sshing to Jean Zay: either tweak .bashrc to launch zsh instead of bash (http://unix.stackexchange.com/a/136511) or maybe simpler use RemoteCommand in ~/.ssh/config (https://unix.stackexchange.com/a/548057/174101) but that needs ssh 7.6 (see https://www.openssh.com/txt/release-7.6)

lesteve avatar Mar 10 '20 10:03 lesteve

Hi @lesteve, just one comment here: the official shell on Jean Zay is bash. In particular, all system scripts are bash scripts. Additional shells are installed but we do not provide support for them yet. zsh might work very well (and I hope it will) but I just want to warn you that if there are some troubles when using it, this will be considered as a low priority issue.

mypey avatar Mar 10 '20 15:03 mypey

Thanks a lot for the precision! I think I have seen it somewhere in your official doc that bash was the only supported shell indeed. I will make sure to mention that zsh is not supported officially!

In practice I have not noticed any issue so far so I thought I would mention that if people are interested.

Just to explain, I am used to have a zsh prompt and there are a few zsh features or rather prezto features (a zsh framework similar to oh-my-zsh) that I can not live without (nice prompt, autosuggestions, Control-P matching anywhere in my history, Alt-P matching history with the whole beginning of my command, etc ...).

Basically this is a way to feel more at home and productive on Jean Zay!

lesteve avatar Mar 10 '20 16:03 lesteve

It does work for fish too. I have a similar setup:

  • install fish from conda-forge
  • to get the module command source /gpfslocalsup/spack_soft/environment-modules/current/init/fish
  • add exec $PATH_TO_CONDA_ENVS/bin/fish -l to your .bashrc

rstrudel avatar Mar 25 '20 15:03 rstrudel

Excellent thanks for letting us know!

lesteve avatar Mar 25 '20 16:03 lesteve

source /.../environment-modules/4.3.1/gcc-4.8.5-ism7cdy4xverxywj27jvjstqwk5oxe2v/init/zsh so that the module command works. Probably needs something a bit more robust than this complicated name.

It would indeed to better to use /.../environment-modules/current/init/... instead.

RemiLacroix-IDRIS avatar Jun 24 '20 16:06 RemiLacroix-IDRIS

Yep I looked at my .zshrc and that's what I have indeed (I edited my first post):

MODULE_INIT_ZSH=/gpfslocalsup/spack_soft/environment-modules/current/init/zsh
if [[ -s "$MODULE_INIT_ZSH" ]]; then
  source "$MODULE_INIT_ZSH"
fi

lesteve avatar Jun 25 '20 07:06 lesteve

In fact we even have an environment variable $MODULESHOME but I am not sure if it's inherited by zsh?

RemiLacroix-IDRIS avatar Jun 25 '20 07:06 RemiLacroix-IDRIS

In case someone doesn't want to use conda, zsh can be compiled from source without sudo (https://stackoverflow.com/a/15293565).

  1. Install zsh form source
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
  1. Edit the .zshrc to enable the module command, in a new line add: source "$MODULESHOME/init/zsh"
  2. (zsh on login) Edit your .bashrc and add in a new line: exec zsh

PS: If something goes wrong after editing the .bashrc, i.e., zsh has not been properly installed or whatever, the shell will raise an error and close the ssh connection. The solution is to remove the problematic line (e.g. exec zsh), but since the ssh connection is closed upon login, it's annoying. Simple "hacky" solution is to ssh into jean-zay and hit Ctrl+c as soon as the authentification is done (when the welcome screen is printed). This will stop the execution of the .bashrc and gives you access the the shell.

flbbb avatar Jul 10 '23 08:07 flbbb