A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands

Overview

PIGIT

Python 3 pypi_version Code style: black

A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands. For example: git status --short, this project can help you improve it. This project is written in Python. Now most UNIX like systems come with Python. So you can easily install and use it.

demo display

Installation

Pip

pip install -U pigit

Source

git clone https://github.com/zlj-zz/pigit.git --depth=1
cd pigit
make install
# or
python setup.py install  # On windows

Usage

You can run pigit in terminal, and you will see this intro:

 ____ ___ ____ ___ _____
|  _ \_ _/ ___|_ _|_   _|
| |_) | | |  _ | |  | |
|  __/| | |_| || |  | |
|_|  |___\____|___| |_| version: 1.3.3.dev

git version 2.30.1 (Apple Git-130)

Local path: /usr/local/lib/python3.9/site-packages/pigit-1.3.3.dev0-py3.9.egg/pigit/__init__.py

Description:
  Terminal tool, help you use git more simple. Support Linux, MacOS and Windows.
  It use short command to replace the original command, like:
  `pigit ws` -> `git status --short`, `pigit b` -> `git branch`.
  Also you use `pigit -s` to get the all short command, have fun and good lucky.
  The open source path on github: https://github.com/zlj-zz/pigit.git

You can use -h or --help to get help and more usage.

You can run pigit -h or pigit --help to get the help message. Like this:

usage: pigit [-h] [-v] [-C] [-s] [-p TYPE] [-t] [-d] [--out-log] [-f] [-i] [-c [PATH]]
             [--create-ignore TYPE] [--create-config] [--shell]
             [command] [args ...]

If you want to use some original git commands, please use -- to indicate.

positional arguments:
  command               Short git command or other.
  args                  Command parameter list.

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         Show version and exit.
  -C, --complete        Add shell prompt script and exit.(Supported bash, zsh, fish)
  -s, --show-commands   List all available short command and wealth and exit.
  -p TYPE, --show-part-command TYPE
                        According to given type [Branch, Commit, Conflict, Fetch, Index,
                        Log, Merge, Push, Remote, Stash, Tag, WorkingTree, Submodule,
                        Setting, Extra] list available short command and wealth and exit.
  -t, --types           List all command types and exit.
  -d, --debug           Current runtime in debug mode.
  --out-log             Print log to console.
  --create-config       Create a pre-configured file of PIGIT.(If a profile exists, the
                        values available in it are used)

tools arguments:
  Auxiliary type commands.

  -f, --config          Display the config of current git repository and exit.
  -i, --information     Show some information about the current git repository.
  -c [PATH], --count [PATH]
                        Count the number of codes and output them in tabular form.A given
                        path can be accepted, and the default is the current directory.
  --create-ignore TYPE  Create a demo .gitignore file. Need one argument, support:
                        [android, c++, cpp, c, dart, elisp, gitbook, go, java, kotlin,
                        lua, maven, node, python, qt, r, ros, ruby, rust, sass, swift,
                        unity]
  --shell               Go to the pigit shell mode.

For example

You can use pigit -s to check what short command it supported, it will display the corresponding help information and the original command, like this:

These are short commands that can replace git operations:
    b        lists, creates, renames, and deletes branches.
             git branch
    bc       creates a new branch.
             git checkout -b
    bl       lists branches and their commits.
             git branch -vv
    bL       lists local and remote branches and their commits.
             git branch --all -vv
    bs       lists branches and their commits with ancestry graphs.
             git show-branch
    bS       lists local and remote branches and their commits with ancestry graphs.
             git show-branch --all
    bm       renames a branch.
             git branch --move
    bM       renames a branch even if the new branch name already exists.
             git branch --move --force
    bd       delete a local branch by name.
             git branch -d
    c        records changes to the repository.
             git commit --verbose
......

Interaction

It support a simple interactive mode. You can use pigit ui into the interactive mode and it let control the working tree simpler. like this:

interaction demo

And in the interaction mode, you can use ? or h to see the help message.

Open remote

You can use pigit open to open your remote website (just support github). These are some other parameters this command supported:

  -i, --issue:
      open given issue of the repository.
      # pigit open -- -i 20
      # pigit open -- --issue=20
  -c, --commit:
      open the current commit in the repo website.
      # pigit open -- --commit
  -p, --print:
      only print the url at the terminal, but don't open it.
  
   
    :
   
      open the page for this branch on the repo website.

Alias

Alias is recommended for faster use pigit. Open your shell profile and append:

alias g=pigit

Then, you can use g to call pigit.

Configuration

You can use pigit --create-config to create a template configuration at pigit home path.

On Linux or MacOS: ~/.config/pigit

On windows should be: C:\\User\\

here is a configuration template.

Extra cmds

You can setting your custom cmds. It need create a extra_cmds.py file at the pigit home. And writing like this:

import os

def print_user(args):
    print(os.system('whoami'))

extra_cmds = {
    'echo': {
        'command': 'echo 123',
    },
    'print-user': {
        'command': print_user,
        'type': 'func',
        'help': 'print system user name.'
    }
}

The extra_cmds dict is must. And the structure is command key and command info.

The command info has some options:

  • command: (Must have) Short life corresponds to the complete command or a method. If it is a method, it must receive a parameter tuple.
  • type: (Option) Mark the type of command, support ['func', 'command'], and the default is 'command'.
  • help: (Option) Command help message.
  • has_arguments: (Option, bool) Whether the command accepts parameters. Default is True.

Feature

  • Short command for quick use Git.
  • Support custom your short command.
  • Support command correction.
  • Support simple terminal TUI interaction.
  • Support generate and use shell completion script.
  • Support create .gitignore template from internet.
  • Support code counter and classification output.
  • Support quick open remote url (only support github).
  • Have log output and help message tips.
  • Support beautiful output.

LICENSE: MIT

Comments
  • Interation mode can't process file path right with space

    Interation mode can't process file path right with space

    Describe the bug

    Interation mode can't process file path right with space

    To Reproduce

    Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Or show your code:

        def switch_file_status(self, file: Union[File, str], path: Optional[str] = None):
            path = path or self.op_path
            file_name = self._get_file_str(file)
    
            if file.has_merged_conflicts or file.has_inline_merged_conflicts:
                pass
            elif file.has_unstaged_change:
                exec_cmd(f"git add -- {file_name}", cwd=path)
            elif file.has_staged_change:
                if file.tracked:
                    exec_cmd(f"git reset HEAD -- {file_name}", cwd=path)
                else:
                    exec_cmd(f"git rm --cached --force -- {file_name}", cwd=path)
    

    File path like this:

    图片

    And the below code can't process it right. Because:

    图片

    Expected behavior

    A clear and concise description of what you expected to happen.

    Screenshots

    If applicable, add screenshots to help explain your problem.

    Desktop (please complete the following information):

    • OS: MacOS
    • Version v1.5.2
    bug 
    opened by zlj-zz 1
  • Color strings do not support nesting.

    Color strings do not support nesting.

    Describe the bug

    A clear and concise description of what the bug is.

    To Reproduce

    Steps to reproduce the behavior:

    ...

    Or show your code:

    from pydantic import conset
    from pigit.render.console import Console
    
    console = Console()
    
    test_string = "`Hello World`<red>"
    console.echo(test_string)
    
    test_string = "`Hello `World`<yellow>`<red>"
    console.echo(test_string)
    
    

    Expected behavior

    The correct situation should be that hello is red and world is yellow.

    Screenshots

    图片

    Desktop (please complete the following information):

    • OS: masos
    • Version 1.5.2
    bug 
    opened by zlj-zz 1
  • `Table` can't wrap a too much long string without '\n'.

    `Table` can't wrap a too much long string without '\n'.

    Describe the bug

    Table can't wrap a too much long string without '\n'.

    To Reproduce

    code:

        def test_unittable(self):
            ut = UintTable(
                title="unit table",
                box=box.DOUBLE_EDGE,
                border_style="sky_blue",
            )
    
            unit1 = ut.add_unit(
                "Fruit true color", header_style="red bold", values_style="yellow"
            )
            unit1.add_kv("apple", "red, this is a length test.\n second line.")
            unit1.add_kv("grape", "purple")
    
            unit1 = ut.add_unit("Animal color")
            unit1.add_kv("cattle", "yellow")
            unit1.add_kv(
                "sheep", "white, this is a length test, get large length text." * 10
            )
    
            console = Console()
            console.echo(ut)
    

    Expected behavior

    A clear and concise description of what you expected to happen.

    Screenshots

    show:

    图片

    Desktop (please complete the following information):

    • OS: macos
    enhancement 
    opened by zlj-zz 1
  • Bump v1.6.0

    Bump v1.6.0

    • Using new dependent package plenty.
    • Show the file icon in TUI mode.

    The ability of rendering is separated, which is conducive to better maintenance, update and reuse.

    opened by zlj-zz 0
  • (fix): `repo ll` has erro when the repos include invalid path.

    (fix): `repo ll` has erro when the repos include invalid path.

    • The season is cannot get result of git when the path is invalid. The head will be None when path is invalid. So through adjust the value of head to select whether continue.
    • Follow the feature, add --revese for repo ll to display all invalid repo.
    opened by zlj-zz 0
  • Del last file has error.

    Del last file has error.

    Describe the bug

    Del last file has error.

    To Reproduce

    Steps to reproduce the behavior:

    1. Only two file has changed.
    2. Go to gt mode.
    3. Try use d to remove the change of file.
    4. Delete the below first and then the above.

    Expected behavior

    A clear and concise description of what you expected to happen.

    Screenshots

    If applicable, add screenshots to help explain your problem.

    图片

    Desktop (please complete the following information):

    • OS: macos
    bug 
    opened by zlj-zz 0
  • (feat): create gitignore from local.

    (feat): create gitignore from local.

    • Previously, I chose to grab templates from GitHub through the network. The fluctuation of the network may cause the creation speed to be too slow. Now choose to fix the template in the code and create it locally. This method increases the memory used by the runtime (acceptable range), but greatly improves the speed.
    opened by zlj-zz 0
  • Create `.gitignore` too slow.

    Create `.gitignore` too slow.

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement 
    opened by zlj-zz 0
  • May should merge `run_cmd` and `exec_cmd` to one.

    May should merge `run_cmd` and `exec_cmd` to one.

    def run_cmd(*args, cwd: Optional[str] = None) -> bool:
        """Run system command.
    
        Returns:
            (bool): Whether run successful.
    
        Docs test
            >>> run_cmd('pwd')
            True
            >>> run_cmd('which', 'python')
            True
        """
    
        try:
            # ? In python2, `subprocess` not support `with` sentence.
            proc = subprocess.Popen(" ".join(args), shell=True, cwd=cwd)
            proc.wait()
        except Exception:
            Log.error(traceback_info())
            return False
        else:
            return True
    
    
    def exec_cmd(*args, cwd: Optional[str] = None) -> Tuple[str, str]:
        """Run system command and get result.
    
        Returns:
            (str, str): Error string and result string.
        """
    
        try:
            # Take over the input stream and get the return information.
            with subprocess.Popen(
                " ".join(args),
                stderr=subprocess.PIPE,
                stdout=subprocess.PIPE,
                shell=True,
                cwd=cwd,
            ) as proc:
    
                output = proc.communicate()
                # Get normal output and error output.
                res = output[0].decode()
                err = output[1].decode()
        except Exception as e:
            Log.error(traceback_info())
            return str(e), ""
        else:
            return err, res
    

    Can use one parameter to contrl whether return result or ouput to shell.

    enhancement 
    opened by zlj-zz 0
  • `repo fetch` not get right command.

    `repo fetch` not get right command.

    Describe the bug

    repo fetch not get right command.

    Expected behavior

    A clear and concise description of what you expected to happen.

    Screenshots

    If applicable, add screenshots to help explain your problem.

    图片

    Desktop (please complete the following information):

    • OS: [e.g. iOS]
    • Version [e.g. 22]

    Additional context

    Add any other context about the problem here.

    opened by zlj-zz 0
  • (refactor): add new module cmdparse, merge shellcompletion.

    (refactor): add new module cmdparse, merge shellcompletion.

    1. Create new parser class according to ~ArgumentParser. Support new method about dict serialize, and support use decorator to construction command parameters.
    2. Merge shellcompletion to cmdparse, because the completion should be deepend on a parser.

    (enhance): support color with shell mode.

    opened by zlj-zz 0
  • Whether need support beautify print object, like list or dict

    Whether need support beautify print object, like list or dict

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Describe the solution you'd like A clear and concise description of what you want to happen.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    enhancement 
    opened by zlj-zz 0
Releases(v1.6.0)
Owner
Zachary
Zachary
A python based command line tool to compare Github Users or Repositories

gitcomp A simple python package with a CLI to compare GitHub users and repositories by associating a git_score to each entry which is a weighted sum o

Anirudh Vaish 5 Mar 26, 2022
CLI/GUI Math commands based on python 3

PyMath Commands Syntax Installation Commands: pymath add: usage: pymath add 12.5 12.5 sub: usage: pymath sub 25 12.5 div: usage: pymath div 144 12 mul

eggsnham07 0 Nov 22, 2021
Tool for HackMyVM platform

HMV-cli It is a tool for the HackMyVM platform. With this tool you will be able to see the machines you have pending, filter by difficulty, download d

bitc0de 11 Sep 19, 2022
pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo

pyGinit pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo Requirements Requirements be

AlphaBeta 15 Feb 26, 2022
Tmux Based Dropdown Dashboard For Python

sextans It's a private configuration and an ongoing experiment while I use Archlinux. A simple drop down dashboard based on tmux. It includes followin

秋葉 4 Dec 22, 2021
A fantasy life simulator and role-playing game hybrid distributed as CLI, written in Python 3.

Life is Fantasy Epic (LIFE) A fantasy life simulator and role-playing game hybrid distributed as CLI, written in Python 3. This repository will be pro

Pawitchaya Chaloeijanya 2 Oct 24, 2021
Find your broken links, so users don't.

PyAnchor Dead links are an annoyance for websites with an extensive amount of content. A side from the negative impact on SEO, dead links are an annoy

Ricky White 61 Dec 14, 2022
A linux-like remote terminal for Micropython

A linux-like remote terminal for Micropython

Christian Köver - Draxl 2 Nov 14, 2021
Convert shellcode into :sparkles: different :sparkles: formats!

Bluffy Convert shellcode into ✨ different ✨ formats! Bluffy is a utility which was used in experiments to bypass Anti-Virus products (statically) by f

AD995 305 Dec 17, 2022
A command line tool to create a graph representing your Ansible playbook tasks and roles

Ansible Playbook Grapher ansible-playbook-grapher is a command line tool to create a graph representing your Ansible playbook plays, tasks and roles.

Mohamed El Mouctar Haidara 424 Dec 20, 2022
RSS reader client for CLI (Command Line Interface),

rReader is RSS reader client for CLI(Command Line Interface)

Lee JunHaeng 10 Dec 24, 2022
Basic python tools to generate shellcode runner in vba

vba_bin_runner Basic python tools to generate shellcode runner in vba. The stub use ZwAllocateVirtualMemory to allocate memory, RtlMoveMemory to write

4 Aug 24, 2021
Command-line parsing library for Python 3.

Command-line parsing library for Python 3.

36 Dec 15, 2022
A tool to manage the study of courses at the university.

todo-cli A tool to manage the study of courses at the university

Quentin 6 Aug 01, 2022
A Python-based Wordle solver and CLI player

Wordle A Python-based Wordle solver and CLI player This was created using Python 3.9.7. SPOILER ALERT: the data directory contains spoilers for upcomi

Will Fitzgerald 1 Jul 24, 2022
Hurry is a CLI tool to speed setting up MoniGoMani HyperStrategy & co. #freqtrade #hyperopting #trading #strategy

Hurry is a CLI tool to speed setting up MoniGoMani HyperStrategy & co. #freqtrade #hyperopting #trading #strategy

10 Dec 29, 2022
git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's partial clone and sparse checkout features.

Partial Submodules for Git git-partial-submodule is a command-line script for setting up and working with submodules while enabling them to use git's

Nathan Reed 15 Sep 22, 2022
Command line interface to watch your childhood shows in hindi and english, designed with python

Sweet dreams: Most of your childhood shows Command line interface to watch your

Not Your Surya 3 Feb 13, 2022
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

ImgReRite A command line tool to hide and reveal information inside images (work

Jigyasu 10 Jul 27, 2022
Simple CLI for managing Postgres databases in Flask.

Overview Simple CLI that provides the following commands: flask psql create flask psql init flask psql drop flask psql setup: create → init flask psql

Daniel Reeves 21 Oct 03, 2022