---
title: Announcing gitsh
teaser: |
  Announcing a new open source library, gitsh, for running Git in a
  dedicated shell.
tags: news,git,open source
author: George Brocklehurst
published_on: 2014-02-10
---

`gitsh` is a new way to use Git: instead of running Git commands in a general
purpose shell like zsh or bash, `gitsh` provides you with a dedicated shell just
for your Git commands.

<iframe src="//fast.wistia.net/embed/iframe/wkl3njtmz0" frameborder="0"
scrolling="no" class="wistia_embed" name="wistia_embed" width="640"
height="480"></iframe>

Many of the early Unix utilities, like [`dc`][dc], didn't take sub-commands like
Git and other modern programs do, instead they launched a shell. For a program
like Git, which has so many commands and options, interacting via a shell still
makes a lot of sense, and so `gitsh` follows in this long Unix tradition.

## Save yourself some typing

At its simplest, `gitsh` saves you from typing the word `git` over and over.

Git commands are very moreish, you almost never just want one. If you work with
Git, this flurry of commands is probably very familiar to you:

```sh
git status
git add -p
git commit
git push
```

With `gitsh` this gets easier:

```sh
$ gitsh
gitsh@ status
gitsh@ add -p
gitsh@ commit
gitsh@ push
gitsh@ :exit
$
```

All of your [Git aliases][git-aliases] will work in `gitsh` too, so you can save
yourself even more typing.

## Deep integration

Now we're in a dedicated Git shell, there's a lot more it can do than just save
us a few keystrokes. `gitsh` is only concerned with Git, so it has all kinds of
little ways to make using Git easier.

### What's my status

Of all the Git commands, I find myself using `git status` most often. If I'm
about to commit, or push, or pull, it's a great way of quickly checking where
things are up to.

In `gitsh`, if you hit return without entering a command, we assume you wanted a
status, saving you even more typing and making it really easy to check the
status after any command.

If you prefer the more taciturn output of `git status -s`, or find yourself
using a completely different command with annoying regularity, you can always
change `gitsh`'s default command by setting the `gitsh.defaultCommand` variable
using `git config`:

<kbd>gitsh@ config --global gitsh.defaultCommand "status -s"</kbd>

### Tab completion and Git prompts

In `gitsh` you automatically get tab completion for commands, branch names, and
paths, and the name and status of the current branch in your prompt. For
example, if everything is committed and your working directory is clean the
prompt is blue and ends with `@`, but if you have untracked files the prompt
is red and ends with `!`.

It is possible to set up parts of this in bash or zsh, but it can be fiddly to
get working, easily broken, and can interact strangely with aliases and
third-party Git commands.

### Git environment variables

Like most general purpose Unix shells, `gitsh` also provides environment
variables. You can set a variable using the `:set` command, and read them using
a `$` prefix:

```sh
gitsh@ :set message "A commit message"
gitsh@ commit -m $message
```

If the variable name contains a dot, it will temporarily override one of your
`git config` settings, until the end of your `gitsh` session. This is useful
when pair programming:

```sh
gitsh@ :set user.name "George Brocklehurst &amp; Mike Burns"
gitsh@ :set user.email support+george+mburns@thoughtbot.co
gitsh@ commit -m "We are pair programming!"
```

## Convinced

If you're on Mac OS X, you can install `gitsh` via Homebrew:

<kbd>brew tap thoughtbot/formulae && brew install gitsh</kbd>

If you're on Linux, there are install instructions in the [`gitsh`
README][readme].

Don't forget to check out the man page (via <kbd>man gitsh</kbd>).

And if you do find a bug, please report it on the [`gitsh` GitHub repo][repo].

[dc]: http://en.wikipedia.org/wiki/Dc_(computer_program)
[git-aliases]: https://github.com/thoughtbot/dotfiles/blob/ce425d6/gitconfig#L5
[readme]: https://github.com/thoughtbot/gitsh#readme
[repo]: https://github.com/thoughtbot/gitsh
