Tools

Tools

Power User Use your tools

Tools

git

RAD GIT TRIX

BUILD MORE TOOLS

BUILD MORE TOOLS

  1. project aliases
  2. global aliases
    • br
    • ci
    • co
  3. project commands (see smartcd)
    • dtag
    • stag
  4. global commands

Feedback vs Robustness

My tools

git amend-file-split

#!/usr/bin/env perl

use strict;
use warnings;

die 'changes in working directory!' if qx(git status -s);

chomp(my $msg = qx(git log --pretty=%s -1));
qx(git reset HEAD^);

my %changed_files = map { m/(..)\s+(.+)/; ($2, $1) }
   split /\0/, qx(git status -z);

for (keys %changed_files) {
   my $t = $changed_files{$_};

   my $action;

   $action = 'Added'    if $t eq '??';
   $action = 'Modified' if $t eq ' M';
   $action = 'Deleted'  if $t eq ' D';

   system(qw(git add), $_);
   system(qw(git commit -m), "$msg [$action $_]");
}

git log-file

#!/bin/bash

git show --stat $(git log --pretty=%h $1)

git hm

(short for handymerge)
#!/bin/bash

gitk $(cat .git/MERGE_HEAD) $(cat .git/ORIG_HEAD) $@ &

git revert-whitespace

#!/bin/bash

git diff -w > foo.patch && git co . && git apply foo.patch && rm foo.patch

wrap-git

#!/usr/bin/env perl

use strict;
use warnings;

my %aliases = map { split(/\n/, $_, 2) }
   split /\0/,
   `git config -z --get-regexp alias\\.`;

my %commit_aliases = (( commit => 1 ),
   map { s/alias\.//; $_ => 1 }
   grep $aliases{$_} =~ /^commit\b/,
   keys %aliases);

my ($command, @args) = @ARGV;

if ($commit_aliases{$command} >> $args[0] =~ /^-a|^--all/) {
   my @staged = grep /^M/, split /\0/, `git status -z`;
   if (@staged) {
      print "There are staged changes, are you sure you want to commit all? (y/N) ";
      chomp(my $answer = <STDIN>);
      if ($answer =~ /^y/i) {
         run_command()
      }
   } else {
      run_command()
   }
} else {
   run_command()
}

sub run_command {
   system 'git', $command, @args;
   exit $? >> 8;
}
#!/bin/zsh
alias git='noglob wrap-git'

gitk

#!/bin/zsh
alias gitk='noglob g_tk'
#!/bin/bash
function g_tk() {
   /usr/bin/env 'gitk' "$@" &
}

grr

#!/bin/bash
alias grr='g_tk ^origin/release HEAD'
#!/bin/zsh
alias grr='noglob g_tk ^origin/release HEAD'

gre

alias gre='git rebase --root --onto origin/release -i --autosquash'

gosu

alias gosu='git submodule update --init'

bash/zsh stuff

smartcd

In ~/.smartcd/home/code/lynx/bash_enter
autostash ACK_OPTIONS PERL5LIB LYNX_DEBUG
export ACK_OPTIONS='-i --ignore-dirs=cgi/lib'
export PERL5LIB="App/lib:cgi/My:cgi"
export LYNX_DEBUG=1

alias plackup='plackup -R App/lib,cgi/My'
   

ssh stuff

ssh keys

No password needed for remote connections

~/.ssh/config

firebug

Questions?

/

#