Skip to content

Instantly share code, notes, and snippets.

@collinarnett
Created November 3, 2021 18:47
Show Gist options
  • Save collinarnett/2fafddbc1e2552ace177b9c5c6596a9f to your computer and use it in GitHub Desktop.
Save collinarnett/2fafddbc1e2552ace177b9c5c6596a9f to your computer and use it in GitHub Desktop.
Making Zeus more user friendly

Making Zeus more user friendly

Professors will often instruct students to use zeus without explain much. This is not unusual since their objective is not to teach you about the command line interface (CLI) but rather the content of the course. This guide is meant to simplify the process of using Zeus while also giving a brief glimse into the motivation behind using the CLI.

Logging In

Currently the process of logging into Zeus is as follows:

  1. Enter the ssh command
ssh USERNAME@zeus.vse.gmu.edu
  1. Enter your password

This process is repeptitive and unnessary and can be extremely annoying if you get disconnected for any reason, having to repeat the process all over again. To simplify this process we must first create a ssh key without a password. This may seem insecure at first; however as long as no one else has physical access to your machine and your computer is up to date with security patches this practice is reasonably secure.

If you have never heard about the concept of a ssh key, I strongly recommend you read the manual page for the command we're about to use, ssh-keygen.

Generating ssh key

Follow the directions availible on Githubfor creating a new ssh key. These directions are far more complete than I could ever hope to write in this guide and will give you options to add the ssh key to the ssh-agent. Complete both the generation instructions and adding to the ssh-agent. Note: Make sure not to include a password when generating your new key.

Copying the key to zeus

At this stage Zeus is unaware of your ssh key so if you try authenticate with it, you will not be able to log in. Run the following command to place your ssh key in the correct location on Zeus.

ssh-copy-id USERNAME@zeus.vse.gmu

Testing your new key

To test whether or not you've succesfully generated your key and added it to the ssh-agent, run the following:

ssh USERNAME@zeus.vse.gmu.edu

If you get a message that prompts you to enter "yes" or "no", enter "yes" and this message will not be shown again. This message is only warning you that you have not connected to this address before and asks if you would like to remember this address in the future. If you managed to log in at this point, move on to the next sectiom otherwise if you're having trouble with this section, go back and read the directions carefully, do not execute a command unless you understand the potential ramifications.

Creating a ssh config

We can make simplify this process even further by creating an alias for the ssh command to make authenticating to zeus even easier.

If you followed the Mac portion of the github guide you can append to your ssh config file (~/.ssh/config) with the following:

Host zeus
	User USERNAME
	Hostname zeus.vse.gmu.edu

Now you can ssh into zeus using the follwing command:

ssh zeus

Much faster, right? From here you can add Zeus as a remote server to VScode and develop on Zeus using VScode rather than Vim. Later in the guide we will cover enhancing Vimon Zeus but for now you can use VScode if that suits you more. Just enter the last ssh command when VScode prompts you to add a remote server.

Switching to ZSH

Log into Zeus to continue the guide.

Unfortunately, the default shell on Zeus is bash which is outdated and lacks many features of a modern shell; however Zeus does have another shell called ZSH already installed. For many users ZSH has superceded bash based on it's ability to support plugins as well as maintaining backwards compatibility with bash commands.

Normally the command to switch to ZSH would be:

chsh -s zsh

however due to the way users are setup on Zeus, this is impossible. Instead we will configure bash to run ZSH when bash starts. To make the switch we must edit our bash config which can be found at ~/.bashrc, if this file does not exist, create it. Append the follwing to your bashrc:

# Run zsh
if [ "$SHELL" != "/usr/bin/zsh" ]
then
    export SHELL="/usr/bin/zsh"
    exec /usr/bin/zsh
fi

This code just checks if the current shell is zsh and switches to zsh if the current shell is not zsh. To apply this configuration to your current enviornment run the following:

source ~/.bashrc

Congrats! You should now be on ZSH and every time you log in from now on ZSH will be your current shell.

Installing plugins

Here's where this section of the guide gets personal. I am recommending various plugins that may not suit your needs; however I strongly recommend that you research the tools and their alternatives to decide which tool works best for you.

The plugin system that I recommend to novice ZSH users is Oh My ZSH! A plugin system for ZSH. Run the command on their homepage:

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

This will download and run a script that will install Oh My ZSH! If the installer prompts you to create a ZSH config, accept because that will lead us into our next step.

Installing p10k

Now we will install p10k a powerline theme that makes your terminal much more sexy and informative. Since we're using Oh My ZSH! we can easily install p10k using the following command:

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

Next, set the theme of Oh My ZSH! to p10k in your ~/.zshrc file: ZSH_THEME="powerlevel10k/powerlevel10k"

Apply your zsh config your current enviornment usingt the following command just like we did before with bash:

source ~/.zshrc

You should see a screen that asks you to answer a few prompts on fonts and customizing p10k. See this section of the docuementation regarding how to answer these prompts.

Conclusion

This should make your experience on Zeus much better than the default configuration. To see which plugins are availible for Oh My ZSH! you should check out this link: https://github.com/unixorn/awesome-zsh-plugins

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