リモートホストとの差分
リモートホストとの差分を見る場合、次のようにsshでcatした結果をdiffに流しこめば良い(元ネタ):
$ ssh {remote_host} cat {remote_file} | diff {local_file} -
リモートホストとローカルホストが同じ構成の場合(開発環境とステージング環境など)には、次のようなスクリプトを組むともっと便利になる。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
my $name = $ARGV[0]; | |
chomp $name; | |
my $remote = $ARGV[1]; | |
chomp $remote; | |
my $path; | |
if ($name =~ /^//) { | |
$path = $name; | |
} else { | |
my $pwd = `pwd`; | |
chomp $pwd; | |
$path = $pwd . "/" . $name; | |
} | |
my $cmd = "ssh $remote cat $path | diff -u - $name"; | |
print "$cmd \n"; | |
`$cmd`; |
上記のコードをパスの通る場所にrdとして保存して実行権限を付加して、次のように叩くとローカルホストとremote_hostとで/path/to/somewhere/foo/bar.rbの差分を比較できる。
$ cd /path/to/somewhere $ rd foo/bar.rb remote_host
個人的な好みにより-uオプションをつけてる。Usageとか書くべきなんだろうけど、とりあえず。
いやまぁ直接じゃなくてgitとかでバージョン管理して見ろよって話ではあるんだけど、そこはまぁほら。