All notes tagged with git.

October 2, 2024

zed git

Zed as the default editor for commits

I started to use the Zed editor as my default editor, and with it I also use the terminal that comes with it. When using the Zed terminal, I would also like the git commit messages to open in Zed, but only if I’m actually in the Zed terminal. To do this, I first added this to my Zed configuration:

"terminal": {
  "env": {
    "TERM_PROGRAM": "zed"
  }
}

And then, in my Fish config, I added this:

# Zed editor
if test "$TERM_PROGRAM" = "zed"
    set -x EDITOR zed --wait
    set -x VISUAL zed --wait
end

Now, only when I’m in Zed terminal, git commits will also open in Zed. Any other terminal, it defaults back to Neovim.

December 27, 2022

git

A quick gitignore from a template

Often when I start a new project, I also need to have a .gitignore for the specific language that I’m working in.

To easily do this, I added the following alias to my git, which pulls a template from gitignore.io:

git config --global alias.ignore \
'!gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@ ;}; gi'

Now you can do git ignore zig and it will show you the default ignore file for a Zig project.

To automatically put it in your gitignore, just redirect the output:

git ignore zig >> .gitignore

November 20, 2022

git

Create a new repository with Github CLI

Github has their own CLI tool which enables you to interact with Github through the command line.

I often start new repositories and started using the following command to quickly create a accompanying, private repo on Github:

gh repo create <name> --private --source=. --remote=origin