How to Customize Your Command Prompt
Tutorial Details
- Platform: Mac
- Difficulty: Moderate
Lately, I’ve been getting this question a lot: “how did you get your terminal to look the way it does?” If you’ve noticed my terminal and are curious about how I set it up, this is the tutorial for you! Of course, what you learn here will be enough to get you started on creating your own custom command prompt, as well!
Before we get started, I want to make something extremely clear. I’m certainly a command line enthusiast, but I’m not at all a command line pro. I feel at home in a terminal, but I’m a far cry from knowing everything. So here’s the deal: I’m going to show you how I’ve set up my terminal, but that doesn’t mean I’ll be able to explain every single line of code we’ll look at. There are some things here that are the way they are just because that’s what works … and I don’t always 100% know why.
With that disclaimer out of the way, let’s see what we’re doing.
Meeting the Finished Product
Here’s what my command prompt looks like:

If you’re not sure what you’re looking at there, let me explain:
- In the turquoise, we have the name of the computer; in my case, that’s
mothership. That’s followed by a colon. - Next, we have the working directory, in a yellow-orange.
- If we’re in a git repository, we have some info on that next. The main thing here is the branch name (
masterortilt_in_post_classin the screenshot). Also, if the working directory is clean, that text appears in green; otherwise, it appears in red. - Finally, we have a battery indicator. If the ten triangles are all green and filled in, things are powered up. As my battery empties, the triangles will empty and eventually turn red. Of course, if you aren’t on a laptop like I am, this won’t be as useful to you.
Getting the Environment Ready
Let’s now get a few preliminary pieces together, before actually writing some shell scripts.
First, there’s the colour scheme. You might recognize it as Ethan Schoonover’s Solarized colour scheme. It’s pretty amazing, and I’ve used it on both the terminal and in Vim ever since I discovered it. If you want to use it in the Terminal, you’ll have to install the theme. The Terminal in Snow Leopard didn’t support xterm-256color, so you’ll have to follow some special directions on the Solarized GitHub page to get that working if you’re still on that OS.
If you’ve moved on to Lion, you can just install the .terminal files you’ll find in the xterm-256color folder. Once you have those installed (just double-click them), you should be able to select the one you want in the Terminal preferences. Don’t forget to set it as the default scheme.

The next thing to know is that I’m not using the default bash shell in my Terminal. Instead, I’ve switched to zsh, which is basically much bash-compatible, but has a few nice additions, like better tab completion. Here’s how to do it: open the Mac system preferences and go to “Users & Groups.” Unlock the pane by clicking the lock at the bottom and entering your password. Then, right-click on your user in the list and choose “Advanced Options.” In the “Login Shell” field, switch from /bin/bash to /bin/zsh. It’s that simple.
Fonts
Next step: get the right font. I’m using Inconsolata at 15pt. It’s a free monospace font that I love staring at all day long. (Besides using it in the Terminal, I use it in Vim and TextEdit.) You can set your default font from within the Terminal preferences, right where you choose the colour scheme.
Another small thing is the size of your window: Open Terminal Preferences > Settings and click the Window tab; part-way down, you can choose the number of columns and rows you want; I use 130 columns by 30 rows.
Battery
Remember the battery level indicator? Well, that requires a little script from developer Steve Losh; simply copy that into a file and save it as a python file; since ~/bin is in my terminal PATH, I’ve saved the file to ~/bin/batcharge.py. As he notes, this script will only work on Mac OS X, so if you’re running zsh on another system, you’ll have to leave this part out.
Zsh
Last, but most certainly not least, there’s oh-my-zsh. According to the Github repo, this is just “A handful of functions, auto-complete helpers, and stuff that makes you shout ‘OH MY ZSHELL!’”
Why use it? For me, I decided to give it a try at one point and I’ve left it installed. If you use the terminal a lot, poke around oh-my-zsh for a bit when you have some time. You might be surprised at what you’ll find. Installing oh-my-zsh is fairly simple: just follow the setup instructions in the README; they’re pretty straight-forward.
Now we have all the necessary parts in place. We’re ready to actually start creating our custom terminal.
Creating the Files
When you installed oh-my-zsh, it was installed to ~/.oh-my-zsh. Pop that open. You’ll see two folders of note: themes and templates. Inside templates, you’ll find a file called zshrc.zsh-template This is a template for you ~/.zshrc file. If you’ve customized your terminal before, you’ll know that the .bashrc file is where your customizations are stored when you’re using a bash shell. The .zshrc is that same thing, except for the zsh shell. So open up that template file; you don’t have to know what exactly is going on; after all, there are a lot of comments in the file that might not make sense. One thing here is important to use. Notice the line that says this:
ZSH_THEME="robbyrussell"
That’s the name of the theme your terminal is using. Look in the themes folder: you’ll see a robbyrussel.zsh-theme file. What we’re going to do is create a theme of our own, so you can replace that string with the name of our new file. I’ve uncreatively called mine ‘doubleend” because it’s got into on both sides of the terminal.
Any other customizations you want to make to your zsh environment can be made in this file. If you use the terminal a lot, check out oh-my-zsh‘s plugins (in the plugins folder): a ton of useful stuff in there.
Don’t forget to copy to zshrc.zsh-template to your home directory and rename it to .zshrc before you make your changes. Now, in the themes folder, create a file with the theme name you set in your .zshrc file. Make sure you give it the .zsh-theme extension. We’re ready to build our custom theme.
Building the Custom Theme
The most important thing in your theme file is the PROMPT variable. It’s contents is your command prompt. To get the idea of this, just start with this in your theme file:
PROMPT='myPrompt=>'
Open a new Terminal window and you should see this:

All right, let’s get to work. We’re going to have to write several functions, but we’ll start with the PROMPT variable. It might not be noticeable when looking at the terminal, but there are actually three lines to my prompt. The first is a blank line, just to give me some breathing room. The second has all the information, and the third has the arrow. That third line is where you actually type the command. So, here’s our start:
PROMPT=' $reset_color→ '
Yes, you can do multiline strings that easily in shell scripting. But what’s up with $reset_color? That’s a variable that oh-my-zsh defines for us; it resets the colour of the output. This requires a short diversion to discuss how we colour different words in the prompt. You see, there’s a code—a series of characters—that switch the following text to a colour. Obviously, there’s a code for each available colour. Don’t worry, there are other variables for the other colours; you don’t have to learn the codes. By the time we get to the third line, though, we want to reset that to the default text colour; so, we use the $reset_color variable.
If you’re curious about the arrow character, it’s the Unicode rightwards arrow (U+2192, →). That’s all.
So, now our prompt is looking like this:

Looking svelte. Let’s now add the computer name and working directory. This is all for that second line of our PROMPT variable.
$fg[cyan]%m: $fg[yellow]$(get_pwd)
We start by setting the text colour to cyan; it appears that we’re getting that colour code from an associative array or hash; while I don’t use it, there’s a $bg hash which changes the background colour instead of the foreground (text) colour.
After setting the colour, we have %m this outputs the name of the computer. After the colon and space, we switch the text colour to yellow. Next, we use the dollar sign and parens to add the output of the function get_pwd. This will output our current working directory, we a bit of a twist. If I’m in the home directory, I don’t want to see /Users/andrew, I want to see ~ instead. So, here’s that function:
function get_pwd() {
echo "${PWD/$HOME/~}"
}
The function shell is pretty straightforward if you’ve written JavaScript before; identical syntax. I’m not sure where that search-and-replace syntax originated, but that looks pretty similar to the Vim search-and-replace syntax: If PWD includes the text $HOME (a system variable for your home directory), replace it with ~.
Now, here’s what’s down:

Good! Now comes the tricky part. You see, I want to right-align the git information and the battery indicator. Since there’s no way to actually right-align, we have to count the number of characters of text we want, subtract that from the width of the window, and add that spacing. It’s pretty hacky, and the code is pretty messy, but it’s all I’ve been able to find that actually works.
Ready? We insert the spacing with a function that I call get_spacing. So add $(get_spacing) to the end of our second line, so it now looks like this:
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)
Now, that function. Of course, here’s the shell:
function put_spacing() {
}
There are four parts inside. Here’s the first.
local git=$(git_prompt_info)
if [ ${#git} != 0 ]; then
((git=${#git} - 10))
else
git=0
fi
We start by getting the output from the git_prompt_info function and storing it in a local variable, git. Next, if the length of that string is not 0, we reset git so that is now the length of the string minus 10. Otherwise, we reset git to 0. This doesn’t seem to make much sense, until you realize what we’re trying to do here. We want to find out how many character “slots” the git information takes up. The tricky part is that we’re reusing the variable git: first it holds the string, then it holds the number representing the number of characters our git info is long. If git is zero characters long, we set git to 0; if it isn’t (meaning we’re in a git repository), we set git to the number of characters in the string, minus 10. This is because the string character count includes the colour codes, which aren’t actually visible, so they don’t take up width. The double parens? Oh, they’re used for doing math.
We do the very same thing for the battery output:
local bat=$(battery_charge)
if [ ${#bat} != 0 ]; then
((bat = ${#bat} - 18))
else
bat=0
fi
In the third part, we figure out how much spaces we’ll need:
local termwidth
(( termwidth = ${COLUMNS} - 3 - ${#HOST} - ${#$(get_pwd)} - ${bat} - ${git} ))
A bit more math: we start with COLUMNS, which is the number of characters the Terminal is wide. We subtract all the appropriate values (the 3 is for two spaces and a colon), and we end up with the fact that we need termwidth number of spaces between the left and right parts of the prompt.
Now, let’s create a string that’s termwidth number of spaces long:
local spacing=""
for i in {1..$termwidth}; do
spacing="${spacing} "
done
echo $spacing
A simple for-in loop allows us to create the string; then, we return it.
You can’t really tell that the whitespace has been added, so I’ve added some dummy text so you can see that’s it’s been added.

Next up, the Git info. We add $(git_prompt_info) to the end of prompt line 2; as you know, that’s a function call.
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info)
Notice that we don’t change the colour before loading the Git info: the function will take care of that, because it depends on the repository status.
And here’s the function:
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
The first line just checks to see if we’re in a Git repository. If we aren’t we return. If we are, the next line echos out the right info. Notice two things here: first, we’re using two variables: $ZSH_THEME_GIT_PROMPT_PREFIX and $ZSH_THEME_GIT_PROMPT_SUFFIX. I’ll show you how these are defined in a second. The other thing is two other functions that are called. These are provided by oh-my-zsh. The current_branch function just returns the current branch. The parse_git_dirty is more interesting, though. If the current branch is dirty (has uncommitted changes), the function will output the $ZSH_THEME_GIT_PROMPT_DIRTY; otherwise it will output $ZSH_THEME_GIT_PROMPT_CLEAN.
I have these four variables defined like so:
ZSH_THEME_GIT_PROMPT_PREFIX="[git:" ZSH_THEME_GIT_PROMPT_SUFFIX="]$reset_color" ZSH_THEME_GIT_PROMPT_DIRTY="$fg[red]+" ZSH_THEME_GIT_PROMPT_CLEAN="$fg[green]"
Based on these variables, a repo on a clean master branch will output [git:master] in green; a dirty master branch will output +[git:master].
And lastly, we call the battery_charge function:
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info) $(battery_charge)
Here’s the battery_charge function:
function battery_charge() {
if [ -e ~/bin/batcharge.py ]
then
echo `python ~/bin/batcharge.py`
else
echo '';
fi
}
If the file exists, we run that file and echo the output. Notice that we use the backticks around the running of the file (those aren’t single quotes): this allows us to execute a string of code as if it was in the terminal. If the file doesn’t exist, we just echo an empty string.
And with that, we’re done! Here’s what we end with:

Conclusion
Well, that’s what my terminal looks like. I’ve forked the oh-my-zsh project on GitHub and added this theme, so you can find it there. If you’re interested in seeing my other dotfiles, I’ve got them on GitHub too.
However, I’m not done with my command line setup yet. While I haven’t made any changes in a while, I’m thinking of including the current user’s name (because I use this same theme on my server), and also some RVM info. Also, I’m not sure why I have the word git in there; I guess I originally had a setup that worked with multiple version control systems … Anyway, the point of all this is that this is something you’ll continually be tweaking. When I make changes, I’ll be sure to push them to GitHub, so you’ll be able to see them there.
Let me leave you with several links that you’ll find useful in hacking around on the command line:
- 7 Simple and Useful Command Line Tips | Nettuts+
- 10 Terminal Commands that will boost your Productivity | Nettuts+
- How to Customize your Command Prompt | Nettuts+
- Speed up your Workflow in the Terminal | Nettuts+ Premium
- Steve Losh: My Extravagant Zsh Prompt
- Peepcode Blog Post: My command line prompt
- Peepcode: Meet the Command Line ($12)
- Peepcode: Advanced Command Line ($12)
- Phil’s Zsh Prompt
- Bash Prompt HOWTO
- Oh-my-zsh themes wiki page (You can refer to these images when looking at the themes in the
themesfolder; you’ll pick up some useful tips that way.) - Of course, a web search for terms like “bash if statement” or “bash for loop” will bring up helpful results if you’re just learning. Remember, since zsh is pretty much fully compatible with bash, any bash script snippets you use should work find in a zsh prompt.
Have fun!

You can display the
~instead of/Users/xxxby usingprint -D $PWDIn fact, in my .zsh-theme I overwrote the pwd command like this.
# uses ~ instead of /Users/baylorrae/ pwd() { print -D $PWD }
Sorry, WP didn’t format my code properly. Here it is again.
# uses ~ instead of /Users/baylorrae/\n
pwd() { print -D $PWD }Nice! I’ve updated my code accordingly.
Does anyone know a Linux terminal that allows a lot of custimization? I tried Konsole (didn’t allow a custom font, and solarized didn’t look very well there) and the GNOME Terminal (Which doesn’t look good with KDE at all + I wasn’t able to choose Inconsolata as a font allthough it’s installed).
By the way, nice tut! It’s awesome to see more cl tutorials on net.tuts.
My terminal emulator of choice is roxterm
I love the theme! My only problem with this is when I resize the window, all kinds of weird stuff happens. For one, the ‘right aligned’ stuff gets all messed up. The main issue is when I resize the window and the height increases it just keeps on duplicating a new prompt line.
I did some digging and I believe this is a behavior of Zsh and something to do with “SIGWICH” (not sure what that is, sorry).
But if anyone else wants to fix this annoyance (at least to me, it’s an annoyance as I resize my terminal a lot when there’s a lot of data, etc).
I had to change my Prompt stuff to this:
function precmd() {
print -rP ”
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info) $(battery_charge)”
}
PROMPT=’$reset_color→ ‘
Yeah, I’ve seen those issues to: I just don’t resize my terminal that often. But that interesting: I knew that the
precmdfunction was run before each prompt was printed out, but I didn’t realize that it helped with the repeating-prompt-on-resize issue. Thanks!The images are not loading here =/
I’m using chrome on Windows 7 x64.
Hey Andrew, thanks for the great tut. For some reason, after I’ve made the switch to ZSH, none of my rails commands work? I get this error message :-S
/Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs’: Could not find rails (>= 0) amongst [bigdecimal-1.1.0, io-console-0.3, json-1.5.4, minitest-2.5.1, rake-0.9.2.2, rdoc-3.9.4] (Gem::LoadError)
from /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec’
from /Users/david/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/rubygems.rb:1210:in `gem’
from /Users/david/.rvm/gems/ruby-1.9.3-p0@railstest/bin/rails:18:in `’
I’m not sure, but it could be an PATH issue; are the right directories showing up in your PATH variable?
All mine broke, too. Simple fix, though – I just had to move all my previous customisations from ~/.bash_profile to ~/.zshrc and they all worked again.
If you’ve installed something that added extra stuff to ~/.bash_profile, ~/.bashrc or any of the other terminal-specific scripts, you’ll need to move them into the right one for ZSH.
A prompt that takes up 3 lines? Seems wasteful to me.
Hi,
NIce tutorial only thing I will suggest is that you swap the words “command prompt” with “terminal” as I initially thought someone had finally worked out how to kill that ugly Windows DOS prompt. :p
Additionally, tried the PROMPT command and the PROMPT command should be using double quotes instead of single as otherwise it will just output “$reset_color →”.
PROMPT=”
$reset_color→ ”
huh, that’s interesting. That’s not been my experience.
I had the same thoughts. Maybe add Mac to the title?
Oh look customizing the command prompt…
…
…
for apple users
>:(
I know, I’m sorry. I knew someone would mention that. Truth is, I only wrote this because I really did receive a lot of requests for it. Really, though, it’s not really Mac-specific, more more zsh-specific. You might have to do a bit more research to get the colours, font, and zsh working on other OSes, but once you do that, oh-my-zsh and the theme files will still work.
Hey guys, thanks for reading and commenting!
Just wanted to mention this here: Since I wrote this, I’ve made a few tweaks to my theme file on Github, and I’ve got plans for a few more. Anyway, if you want to get the code that I used in this tutorial, I’ve tagged that commit in the repository’s history with the tag
tutorial-code. You can download that from Github if you want, or just clone the repo and rungit checkout tutorial-code.Would love a Windows version of this tutorial. :-)
Hi,
i have a problem with installation
when i use : curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
it will write me this:
Cloning Oh My Zsh…
env: git: No such file or directory
Looking for an existing zsh config…
Using the Oh My Zsh template file and adding it to ~/.zshrc
cp: /Users/Brothell/.oh-my-zsh/templates/zshrc.zsh-template: No such file or directory
Copying your current PATH and adding it to the end of ~/.zshrc for you.
Time to change your default shell to zsh!
Changing shell for Brothell.
Password for Brothell:
chsh: no changes made
__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/
….is now installed.
what im doing wrong or how can i continue?
Thanks for help;]
Looks like you might not have Git installed. Is that the case?
That was my case, by the way. Not that git was not installed, but it was installed in /usr/local/git/bin and was not in my PATH. As soon as I added it there, everything works!
HI,
thx a lot. Unfortunately i am missing steps between your tutorial. This is maybe because i am really new to working with the terminal. I would like to see an tutorial on how to start with terminal. What are the advantes etc.
Thx and greets
I’d really recommend you check out the Peepcode screencasts I linked to at the end of the tutorial. Also, the “7 Simple and Useful Command Line Tips” and 10 Terminal Commands that will boost your Productivity” Nettuts+ articles linked there too are great for beginners. As far as advantages go, I find anything is just quicker in the terminal, and I enjoy using it.
Recently I went through the tutorial on here for customizing the bash prompt.
Part of that used vcprompt to display version control information which included git, subversion and mercurial.
This tutorial only covers git information.
Any thoughts on support for other version control systems?
Good stuff though!
There’s no reason you can’t replace the the git info here with that
vcpromptscript. I’d be pretty straightforward: since it’s just a command you install, you can interpolation the output into the PROMPT string and also get and count the output for the spacing.For anyone who isn’t familiar with
vcprompt: https://github.com/djl/vcprompt, http://vcprompt.com/Here’s a tip for windows users. How to customize your command prompt? – Buy a Mac.
I’m not an Apple fanboy, I don’t even own any Apple products. However, windows users must admit that command prompt in windows is awkward to use, to say the least. Then again, maybe it’s just me…
I’m not against anyone buying a Mac, but there are less expensive ways to customize your terminal on Windows. :) Installing Cygwin or something like that is one of them.
@Edmund There are terminals for PowerShell too. I’m using console2 and have no problem with syntax highlighting and/or customizing the prompt. Also i have installed posh-git which draws in prompt git information. So it’s not as bad as you think. There it’s even the solarized theme for console2.
Or use a distribution of Linux, which is free.
Thanks for the tips! There is only 1 problem I am still having. How can I change the other colors of the shell? For exampe ‘ls -G’ was still showing different colors that didn’t match the main theme colors.
I have added LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD but there are still other things that have the old colors like the autocomplete for directories.
Is there a “fix” for this?
hmm, don’t have an answer for that one. I’ve never used the
LSCOLORSvariable. If that’s a way to customize the colours, you might find this list of the different solarized colour values helpful: http://ethanschoonover.com/solarized#the-values. Let us know if you come up with a solution!for those who dont want to drop bash to zsh there is a couple of bash scripts that emulates the oh-my-zsh!
search for bash-it on github.
Good tip, although everything I do in bash, I can also do in zsh – including all the aliases etc that I had setup before.
Always good to know there are options, though. :)
Hi Andrew,
I’ve followed the tutorial but am noticing some off tabbing behaviour in my Mac OS X Lion ZSH shell.
It seems that whenever I use the tab key to trigger an auto complete and there are multiple matches, which of course returns a list of possibilities on the next line, the 2nd line of the prompt jumps and repeats the original query.
Let me show you an example, I have a folder called `git` inside my `~/Sites/` folder, there are also a `git.so`, `getsimple` and a `github` folder in the same directory.
# original query
Jannis-Mac-Pro: ~/Sites
→ cd g
# after typing the g i use tab to give me all options
# however this is where things break, returning this:
Jannis-Mac-Pro: ~/Sites
→ cd g cd g
getsimple/ git/ git.so/ github/
Notice the repetition of the `cd g` string.
I have no idea where this is coming from but would appreciate any ideas you and other may have here.
My font is set to Monaco 15pt in case that factors in at all…
Thanks for the excellent tutorial regardless,
Jannis
+1 I have the same issue
Hey guys,
Sorry about this issue; I hadn’t been experiencing this issue, but while writing this tutorial I removed what I thought were some unnecessary characters in the
PROMPTvariable. I didn’t realize it, but that caused that issue, which I’d been experiencing since, and hadn’t really spent the time to debug. However, the helpful ghsyeung on Github found a solution and sent me a pull request. If you check out the latest code, you’ll see that each time you reference a color variable, you have to surround it by%{and%}. Note that in the latest code, I’m usingprecmdto output the first two lines, so those are only necessary in the third line, which is all thePROMPToutputs. To see the code with the correctly wrapped colour values that’s closest to what I used in the tutorial, see this older commit: https://github.com/andrew8088/oh-my-zsh/commit/de6d98ce2ee383c99b1a194e4f2ed07459b2867b.Let me know if that helps!
Oops, sorry: this was supposed to be a reply to Jannis and Sergey . . .
Well, I just took the doubleend.zsh-theme source and it worked just fine.. Now I too have things that are the way they are just because that’s what works..
Thanks Andrew, now it works perfectly.
I’m not sure if you’re aware of it, but the RPROMPT variable is the right-aligned partner of PROMPT, and avoids all the fiddly bits of adding whitespace.
Unless there’s a reason you’re not using it?
Yes, I’m aware of
RPROMPT, but the thing about that variable is that it is printed on the same line as the one you type your commands on. I’d like that info to be on the line above.When I do; CMD+K to clear my screen (which I do a lot) the prompt just reverts to ‘$’ (which I set) but with none of the extra PWD/git goodness. Any ideas for fixing that?
Yeah, I have the same issue; there isn’t a fix for it, as far as I know.
i am new to mac and terminal, and i dont know how to install .terminal files. i am stuck.
Just double-clicking them should do it; that will open a new terminal window with that theme, but more importantly, it will make that theme an option in the preferences. You can just close the new window that gets opened.
Hi,
getting this error:
command not found: ^[[36m%m:
Also my date and last time login have disapeared.
Anyone kind enough to help.
Thanks anyway
Seems like there is problem with python script for battery level. If You go to its source page, there is a comment about non UTF-8 characters just after the code. Solution for me was to copy battery script code from browser, then paste it in text editor, not terminal, and save that script there rather than directly in terminal.
Can you show me some code from your theme file? It looks like you might be using a variable wrong way.
I have put the batcharge.py in my homedirectory.
This is my terminal output after the tutorial:
➜ ~
Last login disapeared, also batcharger doesn’t come up
This is my code directly form github repo:
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo “$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX”
}
function get_pwd() {
print -D $PWD
}
function battery_charge() {
if [ -e ~/bin/batcharge.py ]
then
echo `python ~/bin/batcharge.py`
else
echo ”
fi
}
function put_spacing() {
local git=$(git_prompt_info)
if [ ${#git} != 0 ]; then
((git=${#git} – 10))
else
git=0
fi
local bat=$(battery_charge)
if [ ${#bat} != 0 ]; then
((bat = ${#bat} – 18))
else
bat=0
fi
local termwidth
(( termwidth = ${COLUMNS} – 3 – ${#HOST} – ${#$(get_pwd)} – ${bat} – ${git} ))
local spacing=”"
for i in {1..$termwidth}; do
spacing=”${spacing} ”
done
echo $spacing
}
function precmd() {
print -rP ‘
$fg[cyan]%m: $fg[yellow]$(get_pwd)$(put_spacing)$(git_prompt_info) $(battery_charge)’
}
PROMPT=’%{$reset_color%}→ ‘
ZSH_THEME_GIT_PROMPT_PREFIX=”[git:"
ZSH_THEME_GIT_PROMPT_SUFFIX="]$reset_color”
ZSH_THEME_GIT_PROMPT_DIRTY=”$fg[red]+”
ZSH_THEME_GIT_PROMPT_CLEAN=”$fg[green]”
template:
redirected to Mytheme
I’m having the same issue as michiel de wilde. In my case, it seems like no matter what theme I set Oh My Zsh to, it only shows the arrow. If it’s important, I’m trying to do this in Ubuntu.
I’m trying this on my mac now, and am running into the same problem. I have both of them set up with RVM, if that means anything.
Oh, I feel really silly. I was modifying the file in the “templates” folder, not the “.zshrc” file in ~ , so I was never changing my theme. It works now.
Hi Andrew,
I’ve followed your tutorial but when I download Incosonlata.otf and set it into terminal with Solarized color theme, the size of the terminal shrink a lot and it’s totally unreadable. I have correctly set the font to a size of 15 and the size of the shell like you did : 130 / 30 but the font seems to be 1 pixel high. Did anyone noticed this ? What is the way to correct this ? I’m running OS X Lion.
By the way, is there on this site a tutorial to install from scratch a good development environment on OS X Lion, with good apps, tools, tweaks and customisation like this one for iOS and web (HTML / CSS / PHP / JS) development ?
Thank’s in advance
Hey Bertrand,
I can’t help you with a font.
But this for a tutorial osx (apps, tools).
http://net.tutsplus.com/tutorials/tools-and-tips/the-tools-of-modern-mac-based-web-development-new-on-premium/
Hello,
I have done some research and after a lot of testing.
I get this:
File “/Users/home_directory/bin/batcharge.py”, line 1
function collapse_pwd {
^
SyntaxError: invalid syntax
File “/Users/home_directory/bin/batcharge.py”, line 1
function collapse_pwd {
^
SyntaxError: invalid syntax
Anyone kind enough to help?
Hi,
All my terminal now open within a tiny window and it looks like the line height is too small. I can’t even see the text. I got the problem only with the dark version, the ligth seems to work.
Any idea why I get this ?
For others that may have the same issue, here is the solution : http://apple.stackexchange.com/a/15350
How do I add the time to right hand side ?
I can’t seem to get the battery to work, can’t figure out how to copy the file and move to my $PATH
cp batchange.py ~/.bin
Hey thanks for all your help, got it working now !