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 dashboard for your Terminal written in the Python 3 language,

termDash is a handy little program, written in the Python 3 language, and is a small little dashboard for your terminal, designed to be a utility to help people, as well as helping new users get used

Rebecca White 2 Dec 03, 2021
Command line interface for testing internet bandwidth using speedtest.net

speedtest-cli Command line interface for testing internet bandwidth using speedtest.net Versions speedtest-cli works with Python 2.4-3.7 Installation

Matt Martz 12.4k Jan 08, 2023
Helping you manage your data science projects sanely.

PyDS CLI Helping you manage your data science projects sanely. Requirements Anaconda/Miniconda/Miniforge/Mambaforge (Mambaforge recommended!) git on y

Eric Ma 16 Apr 25, 2022
cmsis-pack-manager is a python module, Rust crate and command line utility for managing current device information that is stored in many CMSIS PACKs

cmsis-pack-manager cmsis-pack-manager is a python module, Rust crate and command line utility for managing current device information that is stored i

pyocd 20 Dec 21, 2022
A command line connect 4 game against a minimax agent.

A command line connect 4 game against a minimax agent.

1 Oct 17, 2021
👻 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
A terminal UI dashboard to monitor requests for code review across Github and Gitlab repositories.

A terminal UI dashboard to monitor requests for code review across Github and Gitlab repositories.

Kyle Harrison 150 Dec 14, 2022
A minimalist Vim plugin manager.

A minimalist Vim plugin manager. Pros. Easy to set up: Single file. No boilerplate code required. Easy to use: Concise, intuitive syntax Super-fast pa

Junegunn Choi 30.2k Jan 08, 2023
Fylm is a wonderful automated command line app for organizing your film media.

Overview Fylm is a wonderful automated command line app for organizing your film media. You can pronounce it Film or File 'em, whichever you like! It

Brandon Shelley 30 Dec 05, 2022
A terminal written in Python.

PyDOS Read the title and then you'll figure out what this actually is. Running First, download or clone this repo. Next, run run.py. After this, you c

TechStudent10 2 Mar 01, 2022
A CLI for streaming, downloading anime shows. The shows data is indexed through GogoAnime.

Anime-cli A CLI for streaming, downloading anime shows. The shows data is indexed through GogoAnime. Please install mpv video-player for better experi

Chirag Singla 31 Oct 23, 2022
A simple reverse shell in python

RevShell A simple reverse shell in python Getting started First, start the server python server.py Finally, start the client (victim) python client.py

Lojacopsen 4 Apr 06, 2022
Commandline Python app to Autodownload mediafire folders and files.

Commandline Python app to Autodownload mediafire folders and files.

Tharuk Renuja 3 May 12, 2022
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

pre.empt.dev 305 Dec 17, 2022
Simple tool, to update linux kernel on ubuntu

Kerbswap Simple tool, to update linux kernel on ubuntu Information At the moment, this tool only supports "Ubuntu" distributions, but will be expanded

dword 1 Oct 31, 2021
Vsm - A manager for the under-utilized mksession command in vim

Vim Session Manager A manager for the under-utilized `mksession` command in vim

Matt Williams 3 Oct 12, 2022
CLI/library to control FNIRSI DC Power Supply (DC-6006L, etc)

dc6006l - CLI/library to control FNIRSI DC Power Supply (DC-6006L, etc) What is this? FNIRSI DC6006L is a programmable DC power supply that is quite c

Taisuke Yamada 7 Sep 25, 2022
🌍 Harness the power of whatsmydns from the command-line.

chkdns Harness the power of whatsmydns from the command-line. Installing with pip pip install chkdns Run chkdns --host github.com Alternatively you ca

Craig Gumbley 3 Oct 29, 2022
dcargs is a tool for generating portable, reusable, and strongly typed CLI interfaces from dataclass definitions.

dcargs is a tool for generating portable, reusable, and strongly typed CLI interfaces from dataclass definitions.

Brent Yi 119 Jan 09, 2023
spade is the next-generation networking command line tool.

spade is the next-generation networking command line tool. Say goodbye to the likes of dig, ping and traceroute with more accessible, more informative and prettier output.

Vivaan Verma 5 Jan 28, 2022