Code Monkey home page Code Monkey logo

gitsh's Introduction

gitsh

The gitsh program is an interactive shell for git. From within gitsh you can issue any git command, even using your local aliases and configuration.

For a quick introduction to gitsh, watch our video on Upcase. For further documentation, you can view the man page by running man gitsh in your terminal.

Build Status Code Climate Reviewed by Hound

Why should you use gitsh?

  • Git commands tend to come in groups. Avoid typing git over and over and over by running them in a dedicated git shell:

    sh$ gitsh
    gitsh% status
    gitsh% add .
    gitsh% commit -m "Ship it!"
    gitsh% push
    gitsh% ctrl-d
    sh$
    
  • Hit return with no command to run git status (change this command by setting gitsh.defaultCommand via git config; remember it will be prefixed with git ), saving even more typing:

    gitsh% ⏎
    # On branch master
    nothing to commit, working directory clean
    gitsh%
    
  • Easily execute shell commands:

    gitsh% !echo Hello world
    Hello world
    gitsh%
    
  • Combine commands with &&, ||, and ;:

    gitsh% commit && push
    
  • Make temporary modifications to your git configuration with gitsh config variables. These changes only affect git commands issued in this gitsh session and are forgotten when you exit, just like shell environment variables.

    gitsh% :set user.name 'George Brocklehurst and Mike Burns'
    gitsh% :set user.email [email protected]
    gitsh% commit -m 'We are pair programming'
    
  • Access information about your repository with magic variables like $_rebase_base, $_merge_base and $_prior.

    gitsh% rebase master
    CONFLICT (content): Merge conflict in db/schema.rb
    gitsh% checkout $_rebase_base -- db/schema
    gitsh% !rake db:schema:load db:migrate
    
  • Tab completion for git commands, aliases, and branches without modifying your shell settings, and without any extra setup for aliases and third party git commands.

  • Information about the state of your git repository in the prompt, without modifying your shell settings. This includes the name of the current HEAD, and a colour and sigil to indicate the status.

  • It works with hub and gh:

    sh$ gitsh --git $(which gh)
    gitsh% pull-request
    

Installing gitsh

See the installation guide for install instructions for other operating systems.

Contributing to gitsh

Pull requests are very welcome. See the contributing guide for more details.

Similar projects

  • git-sh - A customised bash shell with a Git prompt, aliases, and completion.
  • gitsh - A simple Git shell written in Perl.
  • repl - Wraps any program with subcommands in a REPL.

License

gitsh is Copyright © 2016 Mike Burns, George Brocklehurst, and thoughtbot. It is free software, and may be redistributed under the terms specified in the LICENSE file.

About thoughtbot

thoughtbot

Created, maintained and funded by thoughtbot. The names and logos for thoughtbot are trademarks of thoughtbot, inc.

We love open source software! See our other projects. We are available for hire.

gitsh's People

Contributors

adrianheine avatar agentantelope avatar aldrik avatar andybalaam avatar benknoble avatar calleluks avatar charlietran avatar christoomey avatar croaky avatar eebs avatar georgebrock avatar gfontenot avatar jakirkham avatar jeffmueller avatar jferris avatar jjb avatar mike-burns avatar philoserf avatar salbertson avatar sgrif avatar sharplet avatar sidraval avatar srstevenson avatar teoljungberg avatar tomlea avatar tysongach avatar whmii avatar willium avatar xduugu avatar yasuoza avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gitsh's Issues

Erase duplicate sequential commands from history.

If the same command has been issued several times in a row, I have to up-arrow an equal number of times to get past it in the history. Would be nice if this could be compacted, like bash does with HISTCONTROL=ignoredups

Make it easier to release new versions

Currently releasing a version looks like this:

  1. make distcheck
  2. Add the tarball to the gh-pages branch and push it to GitHub
  3. Update the homebrew-gitsh repo with the new URL and SHA1, and pus it to GitHub
  4. (Do whatever the debian package requires)

It would be great if this was just make release

Support clear

I type clear habitually, is this something we should support?

Installation and distribution

We want a way of distributing this as an OS package instead of using Rubygems. It's a program, not a library, and non-Ruby users shouldn't need to understand the Ruby ecosystem to use it.

Hub integration

gitsh doesn't work with hub,

is there a simple fix for this?

Add tab completion for options

According to the README:

Tab completion for git commands, aliases, and branches without modifying your shell settings, and without any extra setup for aliases and third party git commands.

Tab completion works for commands/branches but not for options. For example, if I want to run rebase --continue I can tab-complete the rebase but not the --continue. ZSH allowed me to complete both. It would be nice to add this ability to gitsh.

Don't add blank lines to the history

Pressing return to get a git status is useful, but it does fill the history with blank lines.

We can probably get around this by manually pushing to Readline::HISTORY when the line isn't blank, instead of letting readline build the history for us.

Use hub when available

Hub's a pretty large part of my git workflow, should the script check for / use hub?

It could be smart about trying hub only on unrecognized commands.

Ruby 2.1 version (Ruby 2.0 or later is required to install gitsh)

Getting the error above, while ruby version is 2.1. Details:

dimitry@dimitry-ubuntu ~/gitsh-0.3 $ ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
...
checking for grep that handles long lines and -e... /bin/grep
checking for ruby version... ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
configure: error: Ruby 2.0 or later is required to install gitsh
dimitry@dimitry-ubuntu ~/gitsh-0.3 $ ruby -v
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]

Update README to articulate that "ctrl-d" quits

It might be more idiomatic to encourage users to use "ctrl-d" to quit gitsh - pretty much every shell command that accepts sub-commands interactively (psql, bc, dc, mysql) recognizes this sequence and exits properly (including gitsh).

Install problem on Ubuntu 13.10

I get an error from ./configure:

/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in require': cannot load such file -- bundler (LoadError) from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:inrequire'
from ./vendor/vendorize:3:in `

'
configure: error: Vendorizing gems failed

What do I need to do to fix this?

Thanks,
Lawrence

Completions wraps on the same line

When I tab complete a branch name that does not fit on the current line in a tmux pane the completed name wraps around on the same line, replacing the prompt:

screen shot 2014-02-11 at 09 56 15

This does not happen outside of tmux in a really small terminal window. Is this a bug or is it perhaps an issue with my tmux setup?

Stop passing commands as a string

Commands are currently prefixed with /usr/bin/env git and then given directly to the shell as a string. This means things like status ; echo Hello work when they really shouldn't.

Tab completion after punctuation

A colon or two dots should be considered a word separator for tab completion purposes. This would be useful when specifying local:remote pairs of refs or ranges of commits, for example:

@ push staging HEAD:master
@ push origin :some-feature-branch
@ log origin/master..master

Improve prompt colour support

Currently we add colour to certain parts of the prompt when the terminal supports it. This will work fine when the colours are added by gitsh, but it will break down if the user has put colours elsewhere in the prompt.

I suggest:

  1. Stop implicitly colouring the prompt sigil, and go back to something akin to Mike's prototype (where there are placeholders for the gitsh.prompt setting to start colouring and stop colouring).
  2. When we detect the terminal doesn't support colour, remove ANSI colour sequences (because it shouldn't matter if they were added by the program or by the user, the behaviour should be consistent).

Explain the intended usage more

Things to answer, taken directly from @croaky :

• What's expected usage? Do I change into gitsh when I cd into the project for the day? Or only when I need git commands on an ad-hoc basis, then exit?
• If I try to execute a non-gitsh command inside gitsh, does it delegate out to my regular shell?
• Would I want to just turn on gitsh shell-wide rather than having to enter and exit it? Sort of the shell alias equivalent to what we have now in thoughtbot/dotfiles.

Might be useful to make a video.

Ctrl-U shortcut pushes the cursor forward

On OS X, pressing Ctrl-U after typing a word with a space pushes the cursor several whitespaces beyond the prompt. It's as if some imaginary text exists between the cursor and the prompt. It's not possible to bring the cursor back, even by pressing the backspace key unless return is pressed.

screen shot 2014-02-10 at 11 37 46 am

Tab-completing filenames with spaces

Filenames with spaces don't appear to be handled correctly for tab completion.

They are completed, but the space is not escaped and the file path is not in quotes.

Failure to load manually installed gitsh

I'm on OS X Lion (10.7) and installed gitsh manually through the configure && make && make install dance, after exporting the ruby environment variable to point to my MacPorts-installed ruby 2.1 binary:

export RUBY=/opt/local/bin/ruby
./configure --prefix=/usr/local
make
sudo make install

This produces a gitsh installation in /usr/local (which gitsh --> /usr/local/bin/gitsh), but it fails to load with the following message:

/opt/local/lib/ruby2.1/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- /usr/local/share/gitsh/gems/setup.rb (LoadError)

Indeed, the gems/setup.rb file is nowhere to be found, neither in the resulting installation nor in the source distribution:

 -> ls  /usr/local/share/gitsh/
total 0
drwxr-xr-x  3 root  wheel   102B Feb 11 16:23 ruby/
 -> ls  /usr/local/share/gitsh/gems/setup.rb
ls: /usr/local/share/gitsh/gems/setup.rb: No such file or directory

 -> pwd
/Users/jmpp/Desktop/gitsh-0.3
 -> find . -iname "*setup*" (produces no results).

After configuring, the resulting gitsh script looks as following:

#!/opt/local/bin/ruby

$LOAD_PATH.unshift('/usr/local/share/gitsh/ruby')

require '/usr/local/share/gitsh/gems/setup.rb'
require 'gitsh/cli'

begin
  Gitsh::CLI.new.run
rescue => e
  $stderr.puts "gitsh: Error: #{e.message}"
end

Am I doing something wrong? Thanks for the help!

Add a non-interactive mode

gitsh should accept commands via STDIN or the path to a script as an argument. Scripting support will require additional features, like variables.

Support `--version`

The version number is passed from autoconf to Ruby, we just need a way of displaying it.

README wants examples

As a interested customer of your gem, I don't really know what you're selling.

Show me the money!

Installation fails on OSX Mountain Lion

gitsh tries to use system ruby which is 1.8.7 on OSX Mountain Lion, but gitsh requires 2.0 or greater.

checking for ruby version... 1.8.7
configure: error: Ruby 2.0 or later is required to install gitsh

Add a :echo command to read variables

I spiked this out as a debugging tool while implementing variables, and it was very useful.

Usage:

@ :set foo "Hello world"
@ :echo "foo is: $foo"
foo is: Hello world

Comments

Allow for comment lines that begin with #.

Tab completion doesn't work for temporary aliases

Temporary aliases can be created with the :set command, but they aren't tab completable (e.g. :set alias.foo "!echo this is the foo alias").

This could be fixed by making the Completer class depend on an Environment instance instead of a GitRepository instance. A similar refactoring of the Prompter class allowed the prompt to be customised using :set (see 83aedde951f0b397fbc1d65583868f78f6c1718c)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.