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
CLI based Crunchyroll Account Checker Proxyless written in python from scratch.

A tool for checking Combolist of Crunchyroll accounts without proxies, It is written in Python from Scratch ,i.e, no external module is used rather than inbuilt Python modules.

Abhijeet 8 Dec 13, 2022
Double Pendulum visualised with fetching system information in Python.

Show off your terminal, in style. A nice relaxing double pendulum simulation using ASCII, able to simulate multiple pendulums at once, and provide tra

Nekurone 62 Dec 14, 2022
電通大のCLIツールです

uecli 電通大のCLIツールです。コマンドラインからシラバス検索、成績参照、図書館の貸出リストなどを見ることができます インストール pip install uecli 使い方 シラバスを検索 uecli syllabus search -s 'コンピュータサイエンス' シラバスを取得し、Mar

UEC World Dominators 2 Oct 31, 2021
An open-source CLI tool for backing up RDS(PostgreSQL) Locally or to Amazon S3 bucket

An open-source CLI tool for backing up RDS(PostgreSQL) Locally or to Amazon S3 bucket

1 Oct 30, 2021
Colab-xterm allows you to open a terminal in a cell

colab-xterm Colab-xterm allows you to open a terminal in a cell. Usage Install package and load the extension !pip install git+https://github.com/popc

InfuseAI 194 Dec 29, 2022
Display Images in your terminal with python

A python library to display images in the terminal

Pranav Baburaj 57 Dec 30, 2022
nbcommands bring the goodness of Unix commands to Jupyter notebooks.

nbcommands nbcommands bring the goodness of Unix commands to Jupyter notebooks. Installation You can simply use pip to install nbcommands: $ pip insta

Vinayak Mehta 181 Dec 23, 2022
Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.

Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.

i love my dog 2.8k Jan 05, 2023
Autosub - Command-line utility for auto-generating subtitles for any video file

Auto-generated subtitles for any video Autosub is a utility for automatic speech recognition and subtitle generation. It takes a video or an a

Anastasis Germanidis 3.9k Jan 05, 2023
Command line client for Audience Insights

Dynamics 365 Audience Insights CLI The AuI CLI is a command line tool for Dynamics 365 Audience Insights. It is based on the customerinsights Python l

Microsoft 8 Jan 09, 2023
A clone of the popular online game Wordle

wordle_clone A CLI application for wordle. Description A clone of the popular online game Wordle.

0 Jan 29, 2022
pls is a better ls for developers, pronounced /pliːz/ as in 'please'

pls is a better ls for developers. The "p" stands for ("pro" as in "professional"/"programmer") or "prettier". It works in a manner similar to ls, in

Dhruv Bhanushali 572 Dec 28, 2022
Simple script to download OTA packages from Realme's endpoint.

Realme OTA Downloader CLI tool (based on this C# program) to create requests to the Realme's endpoint. Requirements Python 3.9. pycryptodome. Installa

Roger Ortiz 64 Dec 28, 2022
CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that data.

CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that

Peter Baumgartner 29 Aug 09, 2022
Command line tool to automate transforming the effects of one color profile to another, possibly more standard one.

Finished rendering the frames of that animation, and now the colors look washed out and ugly? This terminal program will solve exactly that.

Eric Xue 1 Jan 26, 2022
Stephen's Obsessive Note-Storage Engine.

Latest Release · PyPi Package · Issues · Changelog · License # Get Sonse and tell it where your notes are... $ pip install sonse $ export SONSE="$HOME

Stephen Malone 23 Jun 10, 2022
Command Line (CLI) Application to automate creation of tasks in Redmine, issues on Github and the sync process of them.

Task Manager Automation Tool (TMAT) CLI Command Line (CLI) Application to automate creation of tasks in Redmine, issues on Github and the sync process

Tiamat 5 Apr 12, 2022
tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI.

Tox Server tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI. It responds to commands via ZeroMQ

Alexander Rudy 3 Jan 10, 2022
This is a CLI program which can help you generate your own QR Code.

Python-QR-code-generator This is a CLI program which can help you generate your own QR Code. Single.py This will allow you only to input a single mess

1 Dec 24, 2021
CLI client for RFC 4226's HOTP and RFC 6238's TOTP.

One Time Password (OTP, TOTP/HOTP) OTP serves as additional protection in case of password leaks. onetimepass allows you to manage OTP codes and gener

Apptension 4 Jan 05, 2022