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 selfbot made with DPY, doesn't have much commands but there's some useful commands to use.

Phantom Selfbot A selfbot made in DPY, made by Zenith. How to use Add your token in token = 'YOUR-MOMS-TOKEN-HERE' Change the prefix in prefix = > If

[Ͼ⁴] Ƶephyr 2 Dec 2, 2021
Output Analyzer for you terminal commands

Output analyzer (OZER) You can specify a few words inside config.yaml file and specify the color you want to be used. installing: Install command usin

Ehsan Shirzadi 1 Oct 21, 2021
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

null 56 Nov 10, 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
TerminalGV is a very simple client to display stats about your SNCF TGV/TER train in your terminal.

TerminalGV So I got bored in the train, TerminalGV is a very simple client to display stats about your SNCF TGV/TER train in your terminal. The "on-tr

Samuel 8 Dec 15, 2022
👻 Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal.

?? Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal. It c

Billy 11 Nov 10, 2021
Todo - You could use terminal to set your todo

Python Tutorial You can learn how to build a terminal application(CLI applicatio

null 29 Jun 29, 2022
Gamestonk Terminal is an awesome stock and crypto market terminal

Gamestonk Terminal is an awesome stock and crypto market terminal. A FOSS alternative to Bloomberg Terminal.

Gamestonk Terminal 18.6k Jan 3, 2023
AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

Rafael Torres 2 Dec 10, 2021
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 9, 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
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

null 439 Jan 2, 2023
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
Easy-to-use terminal program that can compile your code.

Description Easy-to-use terminal program that can compile your code. Installition 1. Cloning repository $ git clone https://github.com/DarkJoij/Compil

DarkJoij 1 Oct 21, 2021
Use case: quick JSON processing/restructuring with jq without terminal

alfred-jq Alfred workflow to conveniently process JQ on clipboard based on a jq query Also available at: packal/jq Use case: quick JSON processing/res

T on Meta Mode 5 Sep 30, 2022
A useful and easy to use Terminal Timer made with Python.

Terminal SpeedCubeTimer Installation ¡No requirements! Just Download and play Usage Starts timer.py and you will see this. python timer.py Scramble

Achalogy 5 Dec 22, 2022
CLTools provides various tools and command to use in the terminal.

CLTools provides various tools and command to use in the terminal. As of date, CLTools is only able to generate temporary email addresses and receive emails. There are plans to integrate more tools and options in the future.

Ashwin Chugh 2 Feb 14, 2022
GitFun - A Simplified Automated CLI tool for GIT😃

GitFun A Simplified Automated CLI tool for GIT, It's for Lazy Developers and Newbies ?? Table of contents GitFun Installation Usage Development Contri

Astaqc 8 Feb 22, 2022
Sink is a CLI tool that allows users to synchronize their local folders to their Google Drives. It is similar to the Git CLI and allows fast and reliable syncs with the drive.

Sink is a CLI synchronisation tool that enables a user to synchronise local system files and folders with their Google Drives. It follows a git C

Yash Thakre 16 May 29, 2022