thefekete.net

$> :(){ :|:& };:

Pseudo git diff with gEDA gschem in bash

Not really a diff, but you can switch between two (or more) schematics from different commits and see what changed. Here’s how…

The ingredients

First of all, you can open multiple files with gschem by listing them after the command:

#!/bin/bash
gschem FILE1 FILE2 ...

… and you can retrieve old versions of files with git-show:

#!/bin/bash
git show HEAD^:SOME_FILE
git show ab05831:SOME_FILE

For more info on how to specify a file, see the git-show man page.

Putting it together

Unfortunately, you can’t pipe schematics to gschem’s stdin (that I know of). Even if you could, we want to compare two schematics, so how would you pipe two files to stdin? It all seemed pretty tough to me until I found a post on stack overflow showing exactly how to handle it… Using process substitution, it becomes an easy problem:

#!/bin/bash
# See the last committed and current versions of a file
gschem <(git show HEAD:SOME_FILE) SOME_FILE
# See any two files in history
gschem <(git show OBJECT) <(git show OBJECT)

Initialize a remote git repository from an existing local repo

#!/bin/bash
REMOTE_HOST='example.com'
REMOTE_PORT=22
REPO_NAME='my_repository'

# create the bare remote repo
ssh $REMOTE_HOST -p$REMOTE_PORT \
"mkdir -p /var/git/$REPO_NAME.git && \
cd /var/git/$REPO_NAME.git && git init --bare" &&

# configure the local repo
git remote add origin ssh://$REMOTE_HOST:$REMOTE_PORT/var/git/$REPO_NAME.git &&
git config branch.master.remote origin &&
git config branch.master.merge refs/heads/master &&

# see if it worked...
git push origin master

Remove a remote branch in git

To remove a branch on a remote repository in git, use:

git push <remote-repo> :<branch-to-delete>

Using commit messages more effectively

When committing with git, you have to include a message. The standard one-liners can be useful to you or anybody else trying to make heads or tails of a particular commit. But what if you need more room than 80 characters? You can do that.

Read the rest of this entry »

git auto-readme hook script

Here’s a handy little script for your .git/hooks folder…

I’ve been getting into git and along with that, I’ve been trying to be more standards minded. Part of that entails including a LICENSE and README file. The LICENSE file is as ease as:

wget -q -O - http://www.gnu.org/licenses/gpl.txt > LICENSE

Its the README that can be a real pain. But, I found a way to make it a little easier.

Read the rest of this entry »

Added GitWeb to the site!

Check it out at http://thefekete.net/gitweb