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
Text based command line webcam photobooth app

Skunkbooth Why See it in action Usage Installation Run Media location Contributing Install Poetry Clone the repo Activate poetry shell Install dev dep

David Yang 45 Dec 26, 2022
🪛 A simple pydantic to Form FastAPI model converter.

pyfa-converter Makes it pretty easy to create a model based on Field [pydantic] and use the model for www-form-data. How to install? pip install pyfa_

20 Dec 22, 2022
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

56 Nov 10, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 03, 2023
CLI utility for updating the EVE Online static data export in a postgres database

EVE SDE Postgres updater CLI utility for updating the EVE Online static data export postgres database. This has been tested with the Fuzzwork postgres

Markus Juopperi 1 Oct 29, 2021
:computer: tmux session manager. built on libtmux

tmuxp, tmux session manager. built on libtmux. We need help! tmuxp is a trusted session manager for tmux. If you could lend your time to helping answe

python utilities for tmux 3.6k Jan 01, 2023
TermPair lets developers securely share and control terminals in real time🔒

View and control terminals from your browser with end-to-end encryption 🔒

Chad Smith 1.5k Jan 05, 2023
Turdshovel is an interactive CLI tool that allows users to dump objects from .NET memory dumps

Turdshovel Description Turdshovel is an interactive CLI tool that allows users to dump objects from .NET memory dumps without having to fully understa

Leron Gray 41 Jul 27, 2022
Colors in Terminal - Python Lang

🎨 Colorate - Python 🎨 About Colorate is an Open Source project that makes it easy to use Python color coding in your projects. After downloading the

0110 Henrique 1 Dec 01, 2021
topalias - Linux alias generator from bash/zsh command history with statistics, written on Python.

topalias topalias - Linux alias generator from bash/zsh command history with statistics, written on Python. Features Generate short alias for popular

Sergey Chudakov 38 May 26, 2022
🏃 Python3 Solutions of All Problems in GCJ 2022 (In Progress)

GoogleCodeJam 2022 Python3 solutions of Google Code Jam 2022. Solution begins with * means it will get TLE in the largest data set. Total computation

kamyu 12 Dec 20, 2022
A Reverse Shell Python Packages

A Reverse Shell Python Packages

1 Nov 03, 2021
Spotify Offline is a command line tool that allows one to download Spotify playlists in MP3 format.

Spotify Offline v0.0.2 listen to your favorite spotify songs, offline Overview Spotify Offline (spotifyoffline) is a command line tool that allows one

Aarush Gupta 1 Nov 28, 2021
A next-generation CLI and TUI that aims to be your personal assistant for everything competitive programming related. 🚀

Competitive Programming Tool Kit The Competitive Programming Tool Kit (cptk for short), is a command line and terminal user interface (CLI and TUI) th

Alon 4 May 21, 2022
A simple and easy-to-use CLI parse tool.

A simple and easy-to-use CLI parse tool.

AbsentM 1 Mar 04, 2022
Python CLI vm manager for remote access of docker images via noVNC

vmman is a tool to quickly boot and view docker-based VMs running on a linux server through noVNC without ssh tunneling on another network.

UCSD Engineers for Exploration 1 Nov 29, 2021
Python implementation of SSH file transfer across servers.

SSH Transfer Python implementation of SSH file transfer across servers. Requirements paramiko=2.7.2 Usage Config Preparation Configure some informatio

Zhe Kong 1 Nov 23, 2021
Albert launcher extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecular substance, and more

unit-converter-albert-ext Extension for converting units of length, mass, speed, temperature, time, current, luminosity, printing measurements, molecu

Jonah Lawrence 2 Jan 13, 2022
Display Images in your terminal with python

A python library to display images in the terminal

Pranav Baburaj 57 Dec 30, 2022
slipit is a command line utility for creating archives with path traversal elements.

slipit is a command line utility for creating archives with path traversal elements. It is basically a successor of the famous evilarc utility with an extended feature set and improved base functiona

usd AG 35 Dec 23, 2022