DEV Community

loading...
Cover image for Shelby, the shell prompt

Shelby, the shell prompt

Athul Cyriac
Originally published at blog.athulcyriac.co ・3 min read

What???

Shelby is a bash and zsh shell prompt with more focus on improving the terminal productivity while not compromising the speed and size.

Why??

I use the terminal. I use it a LOT. Mostly editing,running scripts and servers. I use zsh because I ❤️ oh-my-zsh. I used to use Spaceship Prompt and it felt like quite slow to me. Then I flipped to Starship Prompt by the awesome @matchai.

I really fell in love with Starship. It's fast, it's built with Rust were too big to be for me to fall in ❤️. The only drawback was that it showed a lot of info. A lot. I didn't want to customize it much because I was lazy(obviously) and writing another TOML file was meh.

Then on this fine evening(Dec 2nd) before going to sleep, during to the Study Leaves before my Uni Exams, I thought of writing a shell prompt in Go. I wanted it be fast, to only show the needed info(virtualenvs,SSH and git), and has a small size. The small package size maybe because I use a Macbook Air with 128gigs of storage and not wasting data for downloading the stuff.
I've seen Go and Rust programs get photo finishes at speed benchmarks and I thought, why not learn Go on the go and write this Stuff????

This was also the time I found out that Study Leaves increases the productivity and improves out of the box thinking.

Then I wanted a name for it. I didn't want it to be a ship anymore but more personally and technically relatable. So I named it Shelby because Shell+feminine name (because ships are mostly given feminine names🤪) and my childhood caretaker's name was Silby😁.

Code

I started a bit on it like setting up the repo both local and remote and went to sleep. Since being a total noob to Go(I started learning a few days ago), I searched for any other implementations of the same. I stumbled upon Powerline Go by @justjanne and Mimir by @talal. I found both the code hard to follow but grasped their logic in time. Shelby still use mimir's code in some functions😅.

So, forward a few weeks after my 3rd paper(Discrete Mathematics) I got to spend a bit more time into it and on 22nd Decemeber 2019, I released the Alpha of Shelby. It still has bugs in it but due to my lack of knowledge in Go, I'm still searching for fixes🙂.

Some of it's properties are:

  • Small Size(binary ~= 2MB, tar ~= 700KB)
  • Shows if a Virtualenv is enabled
  • Shows the Username and Hostname if that system is accessed via SSH
  • Shows the Git branch
  • Shows the number of untracked and unstaged files as [+] and [!] respectively. There will be a count of both of the files unstaged or untracked.

You can find Shelby on GitHub do give it a try and open an issue or two if you find anything unusual😃. It also passed 35 stars on GitHub(my highest starred repo). I also built a GitHub Action to keep me posted on any new stars on telegram just to keep me motivated😊.

GitHub logo athul / shelby

Shelby is a fast ⚡️ , lightweight ☁️ , minimal✨, shell prompt written in Go.

Build Status Go Report Card

Shelby is a fast ⚡️ ,lightweight ☁️ ,minimal, shell prompt written in Pure Go.


Installation

Follow the steps below(Linux and macOS), and Post Installation Instructions

  • Run
$ sh -c "$(curl -sL https://git.io/ishelby)" 

OR For macOS Users, install via Homebrew

brew install athul/tap/shelby

OR

  • Download the binary from the WorkFlow Artifacts(Only for Linux)
  • You might wanto to make the binary executable, run chmod +x <binary_name>
  • Move the Binary to /usr/local/bin/

Build From Source

  • Clone the Repo
  • Run go get -v
  • Run go build
  • Move the Binary to ~/.local/bin/shelby

Post Installation Instructions

You must have to add the below code to either the .bashrc or .zshrc or .profile file inorder to Shelby to fully work.

The prompt symbol is and changes to red if the previous command exited with an error.

Bash

Add this to your .bashrc file:

eval "$(shelby init bash

I'd like to also thankGopikrishnan Sasikumar for providing me with a much needed mental support and being my mentor😇, and my Friend Kiran for the support and ideas .

Thanks

Discussion (0)