{
  "$type": "site.standard.document",
  "description": "My most-used git script is gs — an overloaded shell function that handles status, staging, and committing in a single command.",
  "path": "/the-git-script-i-use-everyday-all-the-time/",
  "publishedAt": "2024-03-07T10:54:00.000Z",
  "site": "at://did:plc:bryys25pc2fnagnyxqgsglhd/site.standard.publication/3mn26bjkkmh23",
  "tags": [
    "git",
    "Scripts"
  ],
  "textContent": "One of my most used Git script is gs. It's an overloaded function that does the following:\n\nRUNS GIT STATUS TO LOOK AT WORKING TREE STATUS:\n\ngs\n\nRUNS GIT STATUS <FILE NAME/PATH> TO ONLY LOOK AT A FILE:\n\ngs <file name/path>\n\nRUNS GIT SHOW <COMMIT> TO DISPLAY A COMMIT:\n\ngs <commit>\n\nI wrote it as a fish shell function, but it should be easy to convert to a shell script [^completion]:\n\nfunction gs\n    if not string length -q -- \"$argv\"\n        git status -s\n    else\n        if test -e \"$argv\"\n            git status -s $argv\n        else\n            #`--ext-diff` so external diff tool specified in `git config --get diff.external` is used (it's only automatically applied only for `git diff`)\n            git show --ext-diff $argv\n        end\n    end\nend\n\ncomplete -c gs  -a '(complete -C \"git show \")'\n\n[^completion]: Except maybe for autocompletion. That's why I use fish shell",
  "title": "The git Script I Use Everyday, All the Time"
}