Skip to content

NorthIsUp/git-by-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Put some numbers on those git commands!

Git-by-id annotates the standard git output with "id annotations" (a.k.a. numbers) that make it easier to add, reset, checkout, rm, diff. Once you set the ids for the current index via git status or git branch the ids can be used instead of the file or branch names.

🔢 Example

$ git status -u
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	[1] +modified:   git-by-id

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	[2] .gitignore
	[3] README.md

no changes added to commit (use "git add" and/or "git commit -a")
$ git add 1,3
add 'git-by-id'
add '.gitignore'
add 'README.md'
$ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
	[1] +new file:   .gitignore
	[2] +new file:   README.md
	[3] +modified:   git-by-id

Untracked files not listed (use -u option to show untracked files)

💾 Configuration

All config will be held in the GIT_BY_ID config map. Once the setup is run for the first time GIT_BY_ID will be marked readonly for safety.

GIT_BY_ID[GIT]

Default: git

The command used to run all underlying git commands. The validity of this will be checked via $+commands[${GIT_BY_ID[GIT]}]. This check is skipped if GIT_BY_ID[GIT_CMD] is already configured.

GIT_BY_ID[GIT_CMD]

Default: $commands[$GIT_BY_ID[GIT]]

Setting this is only necessary if GIT_BY_ID[GIT] is not discoverable at the time of first run.

This is the full path to the git executable, this variable is what git-by-id uses internally to call git.

GIT_BY_ID[NO_COLOR] (not working yet)

Default: 0

Disable color output

GIT_BY_ID[VEBOSITY]

Default: 1

Enables info and debug output.

GIT_BY_ID[LOG_COMMANDS]

Default: 0

Enables a debug log of every git-by-id command run (with timestamps).

GIT_BY_ID[LOGFILE]

Default: /usr/local/var/log/git-bid.log

Location of debug logfile.

GIT_BY_ID[SET_ID_VARS]

Default: 1

should id variables (g23, etc.) be set when creating the ids

GIT_BY_ID[PREFIX_VAR]

Default: g

The git id variable prefix, defaults to "g"

GIT_BY_ID[ALIAS_*]

Git-by-id will attempt to unwrap aliases so it can do the right thing with respect to processing output and adding ids. If it isn't picking up on one of your aliases it can be manually added to the config.

For an alias of alias.st=status you could add GIT_BY_ID[ALIAS_st]=status to the config.

➡️ Install

Manual

Do some git cloning and put git-by-id on you fpath

And In your .zshrc or something put this

autoload git-by-id
alias git='git-by-id'

zinit

zinit load northisup/git-by-id

🛍 Other Features

▸ Fixing typos like gi tstatus and git git status

Git-by-id adds alias gi=git t. This checks for typos where you hit the spacebar a little early.

$ gi tstatus
+> [gi tstatus -> git status]
# ... regular git status output here

There is a similar alias for copypasta of "double git", or git git status.

git git clone https://github.com/NorthIsUp/git-by-id.git
+> [git git clone -> git clone] https://github.com/NorthIsUp/git-by-id.git
Cloning into 'git-by-id'
# ... snip ...

If you want this feature without installing git-by-id add the following alias to your git config. git config alias.t=!t() { : git ; echo "+ gi t${1#t} -> git ${1#t}" >&2 ; set -x ; git "${1#t}" "${@:2}" ; }; t

next branch

Git-by-id will substitute the word next for an incrementing number.

$ git checkout -b next
Switched to a new branch 'northisup/15'

$ git checkout -b cool-feature-name/next
Switched to a new branch 'cool-feature-name/15'

$ git checkout -b cool-feature-name/next-some-description
Switched to a new branch 'cool-feature-name/15-some-description'

▸ Alias Aware

Git-by-id will read your git config to make sure it act

+> [git st -> git status]
On branch reports/1-get-message-id
Your branch is up to date with 'origin/reports/1-get-message-id'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	[1] +modified:   discord_api/discord/lib/flask_content_cop.py

no changes added to commit (use "git add" and/or "git commit -a")

✅ TODOs

Some housekeeping up front

  • make debug output configurable
  • write a good usage/help function
  • make colors configurable and optional
  • disable colors when in a pipe
  • remove non-zsh code where possible (some work is done in ruby and awk)

About

🔢 Wraps git in a paint-by-numbers cli

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages