...but I want a pretty PROMPT!
Tags: zsh, shell, command, line
Published: 2020-11-30 17:09:34

![0](https://dev-to-uploads.s3.amazonaws.com/i/j3icfp4nwod3uuqvth3k.png)
 
If you're anything like me, you like to customize EVERY. SINGLE. THING. that is remotely customizable! I love changing colors, adding my own personal style, and finding themes. By this point, I have already customized my terminal window through the Mac's `Terminal > Preferences`. 

![82003515](https://dev-to-uploads.s3.amazonaws.com/i/zvyr0bllpumtswnsi4w0.jpg)
 
This blog is particularly about changing the COMMAND LINE of your Z-Shell...particularly *oh-my-zsh*. 

**If you're a whiz, scroll waaaaaaaaay down to the bottom for a summary of the process.**

#**FIRST** 

Open up your (probably boring) terminal and navigate to the root-directory. This is where your terminal defaults to when you first open it. If you're anything like me, you get lost in there sometimes so you can type `cd ~` and it'll take you to your root directory. 

Then type `code .zshrc` --which is really hard to type smoothly like an experienced hacker.

![1](https://dev-to-uploads.s3.amazonaws.com/i/ett9yxriwibuts4a5zth.png)

This should open your code editor...I'm using VS Code, so it automatically opened it in there. 

The page displayed is like the manual(README) for *oh-my-zsh*, and if you're like me, you won't really read anything because you're so eager to CUSTOMIZE! Seriously I'm so annoying, asking "How do I do this?" when it's literally written in the commented-out portions of the page smh...I'm like a t-rex, I won't see it unless it's jumping up and down in front of my face. Keep this open in a tab until you figure out your lovely theme. It looks like this: 

![zshrc](https://dev-to-uploads.s3.amazonaws.com/i/8f2vgorx2lfxil4yp1ca.png)

#**SECOND**

Probably don't mess with too many things in here, but the instructions are pretty clear...just uncomment things you want to have! But we're not really here to discuss that. 
Somewhere around line 13, you should see `ZSH_THEME="something"`. 

This is telling you what THEME you're currently using in your command line. There are a lot of themes. I changed the `"something"` in that line to be `"random"`. 

Now you can go back to your terminal, and type `$SHELL`, which would refresh your terminal, loading a random theme! Maybe there's a website that shows all the themes on one page, but if you're like me, you're gonna `^ + ENTER` a million times to cycle through randomly. 

My name is Inee and my username is "xoliio", both weird-sounding things, so that's what you're seeing on here, in case you were confused: 

![2](https://dev-to-uploads.s3.amazonaws.com/i/jo1aolmhhfjpz4xw2taf.png) 

They kind of all start looking the same after a while, but find the theme you like and store it in a little piece of memory in your biological human brain. 

Something that might be helpful is to notice where the cursor ends up (the blinking block thing where you type). Does the command-line theme take up one or two lines? What info does it display? Is it readable? Does it have colors you like? You can change this stuff anyway, but to start it helps to have something close to what you were looking for.

For now, I liked the cute simplicity of `"af-magic"`. Still got the name of the theme you like in your noggin? Keep it there for just a little longer. 

#**THIRD**

Now we're going to FIND THAT THEME'S FILE. 
Open your computer's terminal and navigate to your root directory. 

Type `ls -a`...which lists all the files, but also the *SECRET* hidden files. You'll see `.oh-my-zsh` listed in there. 
Navigate to that with `cd .oh-my-zsh`. 
Now, you can OPTIONALLY enter `ls` to see what's in here, but what you want to get into is the "themes" folder via `cd themes`. 

Once you're in there, you can OPTIONALLY `ls` that and have all the themes listed, but really you just want to type `code [theme-name].zsh-theme`. ((It's not a directory so you're not going to `cd`, you want to open it in your code editor this time.)) In my case it'll look like `code af-magic.zsh-theme`. 

This should open up that theme's file in your code editor. Looks so weird, idk what this language is. 
![4](https://dev-to-uploads.s3.amazonaws.com/i/1sxby3kcfupod97ccblu.png) 

#**FOURTH**
(why am I counting like this?)

Since we're going to mess with the codes of these themes, let's save it as something else, so that next time *oh-my-zsh* updates, it won't overwrite your edits. With VS Code selected go to the top left of your screen and select `File > Save As...`. I want moons on my prompt so I'm going to save mine as `moons.zsh-theme`...obvi keep the extension of ".zsh-theme" and don't change the save location either, you want this to go into your `.oh-my-zsh > themes` folder. 

![5](https://dev-to-uploads.s3.amazonaws.com/i/3ptnml41byq5dv9eau3u.png)

NOW we can do some stuff...
**Make sure you go back to your `.zshrc` README to change your `ZSH_THEME` to the new theme name you just saved so you can see the new changes as you edit!**

Did you know WE CAN ADD EMOJIS!?😱!?😱!?😱!?
If you're like me, you probably go about things the long way, or simply don't know the super-smart way. I opened up a new gmail email window and used my touch bar to put a bunch of emojis I wanted to play with...

![6](https://dev-to-uploads.s3.amazonaws.com/i/tl8z6mdgqjgsaensd0jx.png)

You could also open a text field anywhere and press `ctr + cmd + SPACE` to pull up your emoji options: 

![7](https://dev-to-uploads.s3.amazonaws.com/i/v2lesccbo2p6sjwvoy8z.png)
 
#**FIFTH**

Anyhowwww, once you have your emojis somewhere easy to access, you can copy-paste them into the code file of that theme. Just takes a little bit of deciphering and pattern-spotting to figure out where...

![8](https://dev-to-uploads.s3.amazonaws.com/i/omnvi6rw5rwina6vvs5t.png)

What I've deduced is that `$FG[000]` things designate color (FG stands for foreground I think). Also in this code there's `%{$reset_color%}` which resets the color of the background and text to whatever was changed immediately before. Still have yet to figure out what `$my_orange` is exactly, but I think it's another way of asking for colors. 

*oh-my-zsh* theme files may be structured differently, but ultimately you want to find the code lines that deal with the PROMPT. On mine, the title has it commented out as `# primary prompt`. From there, you just have to use your **riddle-loving-raven-brain** to experiment a little with moving those tags around and finding WHERE to add your emoji! 

I suggest, if you want to alter stuff *safely*, copy-paste the whole line of code somewhere else; then, comment it out so that you still have the untainted line to revert back to if you break something. 

![4 copy](https://dev-to-uploads.s3.amazonaws.com/i/6nfz61xm9kz0hrlbwqhm.png) 

On mine, down near line 23, we see the code written for `primary prompt`. You can KIND of see in the `PS1` text what it's doing. Right after our first color tag of `$FG[032]` we see a teeny tiny `%~`. 
You can look at this incomplete chart to see what the other little things mean: 
```
%n - username
%B - make bold
%m - short name of current host
%M - name of current host
%# - a `%` or a `#`, depending on whether the shell is running as root or not
%~ - relative path
%/ or %d - absolute path
```
You can experiment with changing the colors. This is a great chart that has all 256 and organizes the gray-scale and the main-16 too: 

![9](https://dev-to-uploads.s3.amazonaws.com/i/zb5hpq6acgwwfwsvgptq.png)

So real quick, here's the original `af-magic.zsh-theme` prompt-code-line-thing. 

![10](https://dev-to-uploads.s3.amazonaws.com/i/7idsqyja4f7taybyqo9f.png) 

And here's mine...I want **MOONS**, so I'm going to change my `PS1` to look like: 
 
![11](https://dev-to-uploads.s3.amazonaws.com/i/v9r80irah02hygzhvnwa.png)

As you experiment and change the colors etc etc, you can refresh your terminal with `$SHELL`. You can uncomment stuff to help isolate what you're trying to target.

Notice I changed the color at the VERY beginning of the `PS1` line(`$FG[255]`), and added a teeny tiny `%n` in there because this is where I wanted to add my username. Then I have another color tag (`$FG[105]`) right before all those ostentatious moons. This color will actually affect the thing AFTER the moons, which is `$(git_prompt_info)`...essentially the path to your current git file you're working on. 

Also notice, I made a new constant called `NEWLINE=$'\n'` and added it to the END of `PS1`. Sometimes the file path is so long, I'd rather just start on a clean line...and I love snails so I had to add this little guy 🐌 too! Now when I press `ENTER` the cursor is on the next line, right next to my little beloved snail pal. 

Also notice there's a `$FG[048]` color tag before a `(!.#.>>)` thing...this is the color of the little arrows that come at the end of my prompt line. 

What else did I do...
I added **LEAVES** to it too. This is going to happen in the group of lines called `# git settings`. "Clean" means there are no changes to your git file, "Dirty" means there are uncommitted changes...something like that. Mostly, you'll be working in a "Dirty" state, so keep in mind you'll see it in this form most frequently. Here's what my git settings code looks like: 

![12](https://dev-to-uploads.s3.amazonaws.com/i/7kgwxpjc94lwjjn4jqwk.png)

Notice I kept a copy of the prefix up above so I can revert back if needed. The end of the `ZSH_THEME_GIT_PROMPT_PREFIX` line has a color tag...that actually applies to what color your current git branch will be. I chose white. Then notice on `ZSH_THEME_GIT_PROMPT_DIRTY` it has a teeny tiny `*`...this will show up orange, and be present when I'm working on a "Dirty" file. 

I uncommented the entire `# right prompt` lines of code because I just didn't want them.

There's stuff in there about `# hg settings`, I think that's another code editor? 
 
#**SUMMARY**

Here is my terminal now: 

![13](https://dev-to-uploads.s3.amazonaws.com/i/9kesyx0oy80y784ds1yg.png)

**For the smarty-pants, I have summarized the process in only 987954837 steps!**
1. Terminal root dir: `code .zshrc`
2. Change `ZSH_THEME` to "random"
3. Use `$SHELL` in your terminal to cycle themes
4. Remember name of the one you like
5. Terminal root dir: `cd .oh-my-zsh` then `cd themes` then `code [theme].zsh-theme`
6. "Save As" a new file name in ".oh-my-zsh > themes"
7. Change `ZSH_THEME` to your chosen theme
8. Alter your custom theme file using `$SHELL` to refresh
9. Repeat until satisfied

If you want to get DEEPER, here are some helpful resources: 
* https://blog.aamnah.com/sysadmin/zsh-custom-theme-ultimate-guide
* https://blog.carbonfive.com/writing-zsh-themes-a-quickref/

Love from me