Git Product home page Git Product logo

git-gopher's Introduction

git-gopher

Improving the Git CLI experience with fzf

image

What is this?

Rather than needing to remember the exact name of the branch, tag or remote, or the exact syntax of the different git commands needed, git-gopher will provide a list to choose from.

By using fzf for these lists, finding and choosing which item can be done by fuzzy searching the text.

And unlike the git GUIs out there, git-gopher will say exactly what it's doing by displaying the command it will run before the selection is made.

What is this not?

At present, git-gopher is not meant as a comprehensive git solution to include everything you'd ever want to do. Rather, it looks to streamline typical use-cases in a friendly, convenient manner, and allow custom additions to suit personal edge-cases.

Requirements

The following must be installed

Installation

Make sure the basic build tools are installed

pip3 install setuptools wheel

Then we can install via pip

pip3 install git-gopher

Also, $PATH should contain the pip bin directory. That would look something like this in .bashrc, .zshrc or equivalent

PATH="$PATH:~/.local/bin"

Updating

Updating to the latest version is also done via pip

pip3 install --no-cache-dir --upgrade git-gopher

Usage

git-gopher is run from the command line, same as git. The commands will be standard git commands, as if running them directly in the current working directory.

Menu

The ggo command with no arguments will bring up a fzf list of all the commands that git-gopher provides, as well as additional standard git commands.

image

Custom commands can be added to menu by creating ~/ggo-options.dat with the options listed in it, one per line, with the command, shortcut, and description separated by |.

Note: Commands cannot contain 2 consecutive spaces (git log: good, git log: bad). The options are formatted into columns and the two spaces are how the command column is delimited.

git dosomething      | shortcut  | Description of my command
git dosomethingelse  | shortcut2 | Description of my other command

Individual commands

There are several commands added to make use of fzf and make interacting with basic git commands faster and easier.

Commands will list out the available branches or tags in fzf as a fuzzy searchable menu rather than requiring that they be provided up front.

Run any command or alias by passing it to the ggo command

For commands that support multiple selections, use SHIFT+TAB to mark each option.

ggo [command|alias]
command alias description
menu Open menu with these and other commands
checkout-branch c Checkout a local branch
checkout-branch-remote cr Checkout a local or remote branch
checkout-tag ct Checkout a tag
branch-branch bb Create and checkout a new branch from another branch
branch-tag bt Create and checkout a new branch from a tag
merge-branch m Merge a branch into the current branch
merge-tag mt Merge a tag into the current branch
merge-squash ms Merge and squash a branch into the current branch
add a Track and stage selected files
fetch f Retrieve repo information from selected remote
track-remote tr Change which remote upstream to track
upstream-push up Push the current branch to remote, setting the upstream
push-tag pt Push a tag to a remote
tag-increment-version tiv Create a new tag, incremented by major, minor or patch
delete-branch d Delete a branch
delete-branch-force df Force delete a branch
delete-tag dt Delete a tag locally
delete-tag-remote dtr Delete a tag both locally and on remote
reset rs Unstage changes after the selected commit
reset-hard rsh Revert to the selected commit, discarding changes
cherry-pick cp Merge specific commits into the current branch
diff-commits di Select two commits and show the changes between them
difftool-commits dit Select two commits and show the changes using difftool
difftool-commits-dir-diff dd Select two commits and show the changed files by directory
history h Show the history of commands run
history-dir hd Show the history of commands run in the current working directory
stash-apply sta Apply the selected stash to the current branch
stash-pop stp Apply the selected stash to the current branch and delete the stash
stash-message stm Stash changes with a message
stash-drop std Delete a stash

git-gopher's People

Contributors

elle-the-dev avatar

Stargazers

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

Watchers

 avatar

Forkers

vegaspunk

git-gopher's Issues

checkout-remote needs to conditionally track

Don't track unless a remote is selected and the local branch for it doesn't already exist

Currently selecting a local branch with gud cr will create a new branch that tracks the local. Selecting a remote when the local already exists will give an error that the local already exists.

Allow shortcuts for custom commands

If using a custom .gud-options it should allow configuring shortcuts for each

This would require refactoring shortcuts to pull from the .gud-options list instead of an internally defined hash array.

branch-tag naming backspace fails

Using read raw doesn't let the user use backspace. For bash, read -e will fix this. This does not fix the issue for zsh.

Conditionally using vared for zsh may be an option

vared -p "test" -c tmp

Convert from multiple commands to single

Currently there are a host of different commands in the form of gg-* which allows calling them directly and sharing between scripts.

However, this both clutters things by creating a lot of commands, and means aliases need to be defined in .bashrc and upgrading means both updating that config, and re-running installation.

If commands were run via

gg [command or alias here]

Upgrading could be done simply by pulling the latest version.

This would also likely simplify the codebase, as currently there is the need to determine the source directory in every command file. If converted to functions imported into a single file that would not be necessary.

In that format, there would be some desire for autocomplete and you could no longer tab complete the commands. However if the expectation is to either use the menu or aliases, that shouldn't be necessary.

`gud add` command for adding untracked files

Given there'd often be a need to track multiple files, this wouldn't be a good option to fuzzy find a single file, so it may need to prompt after each selection to add more or another way of simply specifying multiple.

Command history

Keeping a history of commands run would be very useful for backtracking when someone makes a mess of their repository.

If would be best if the current repo could be determined somehow and have the history organized in that way, but at the least having just a file with every command run in sequence and when would be very useful.

Indicate if a file is untracked

gud add lists both untracked files and tracked files that have been modified but not staged. There should be an indication of one vs the other

git stash commands

Stashing, popping, applying etc could use helpers

Include the diff in the preview window

Autocreate semantic versioning tag

if tags have semantic versioning, incrementing major, minor, or patch can be done programmatically. Something along the lines of gg-tag-patch-increment would get the most recent tag (or high value sorted numerically?) and increment the last piece.

Convert codebase to python3

BASH is hardly the nicest language to work with, and reusing code is a pain as is, leading to some duplication in areas, and just not clear separation of concerns.

But it works. Converting to python creates additional dependencies and potentially impacts performance. There's a cost-benefit analysis here that I'm not decided on so it deserves some more consideration as to what it would take and if it would be worth it.

The biggest potential advantage would be tests. If this could translate to unit tests, then it'd be a big win, because it's not possible as is.

`gud branch-branch` command

Currently missing a command to simply create a new branch from an existing branch in the same way as gg-branch-tag

More color-coding and labelling

Colors could be used to improve clarity in some commands, but time has to be spent playing with formatting to make that happen.

Make `ggo add` smarter

Currently it lists each subdirectory of any file that can be added. For example,

./foo/bar/foobar/file

will result in listing

  • foo
  • foo/bar
  • foo/foobar
  • foo/bar/foobar

Which is intentional. Except that if there are no files directly under any of those directories, then they're redundant. if the file list is

  • ./foo/bar/foobar/file
  • ./foo/bar/anotherfile

The it should only list

  • ./foo/bar/foobar/file
  • ./foo/bar/anotherfile
  • ./foo/bar

Because ./foo would be redundant to ./foo/bar

This could be challenging for branching paths, but the current expansion quickly becomes unwieldy.

Support more syntax highlighters

Other highlighters listed in the fzf readme

# Try bat, highlight, coderay, rougify in turn, then fall back to cat
fzf --preview '[[ $(file --mime {}) =~ binary ]] &&
                 echo {} is a binary file ||
                 (bat --style=numbers --color=always {} ||
                  highlight -O ansi -l {} ||
                  coderay {} ||
                  rougify {} ||
                  cat {}) 2> /dev/null | head -500'

Custom install directory

Allow passing in a directory to install to instead of /usr/local/bin

This should save the directory to a .install-directory file so uninstall.sh can reference it.

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.