hoge と言うツールをインストールするとき /usr パーティションが小さいので /opt/hoge にインストールしてから /usr にシンボリックリンクを貼っている。そのスクリプト。
#!/usr/bin/env ruby =begin script 名: rinstall =end files=Dir.glob("**/*") pwd=Dir.pwd target="/usr/" files.each {|f| begin puts "ln -fsv #{pwd}/#{f} #{target}#{f}" # File.delete(target+f) if FileTest.exist?(target+f) File.symlink(pwd+"/"+f, target+f) rescue end }paco を組み合わせて使用している。
cd /opt/hoge paco -lp hoge "rinstall"ただ時々 cd /opt/hoge を忘れることがあって、それをどうしようかと ちょっと悩みます。
ruby で宛名書きしてみました。と言っても svg を作るだけです。
#!/usr/bin/env ruby =begin ratenagaki - はがきの宛名を作成 =end atesaki_list="" open(ARGV.shift){|f| atesaki_list=f.read } #好きなフォントを font="monospace" def kansuji(x) x="一" if x=="1" x="二" if x=="2" x="三" if x=="3" x="四" if x=="4" x="五" if x=="5" x="六" if x=="6" x="七" if x=="7" x="八" if x=="8" x="九" if x=="9" x="〇" if x=="0" x="|" if x=="-" x end def textput(x,y,s,t) "<text x=\"#{x}mm\" y=\"#{y}mm\" font-size=\"#{s}mm\">#{t}</text>" end atesaki_list=atesaki_list.split(/\s*\n\s*/) i=0 while i < atesaki_list.length atesaki_list[i]=atesaki_list[i].split(/\s*\,\s*/) i=i+1 end svg_head=<<EOF <?xml version="1.0" encoding="utf-8"?> <svg xmlns="http://www.w3.org/2000/svg"> <style type="text/css"><![CDATA[ text{font-family: #{font}; } ]]></style> <title>宛名</title> <desc>宛先郵便番号</desc> EOF i=0 atesaki_list.each{|q| q[0]=q[0].split(//u) svg=svg_head+<<EOF <text x="44mm" y="20mm" font-size="4mm">#{q[0][0]}</text> <text x="52mm" y="20mm" font-size="4mm">#{q[0][1]}</text> <text x="59mm" y="20mm" font-size="4mm">#{q[0][2]}</text> <text x="67mm" y="20mm" font-size="4mm">#{q[0][3]}</text> <text x="74mm" y="20mm" font-size="4mm">#{q[0][4]}</text> <text x="81mm" y="20mm" font-size="4mm">#{q[0][5]}</text> <text x="87mm" y="20mm" font-size="4mm">#{q[0][6]}</text> <desc>宛先住所1</desc> EOF y=35 #書き始め座標y x=85 #書き初め座標x s=6 #フォントサイズ q[1].split(//u).each{|r| r=kansuji(r) svg=svg+<<EOF #{textput(x,y,s,r)} EOF y=y+s } svg=svg+<<EOL <desc>宛先住所2</desc> EOL x=78 y=41 s=6 q[2]=" " if q[2]==nil q[2].split(//u).each{|r| r=kansuji(r) svg=svg+<<EOF #{textput(x,y,s,r)} EOF y=y+s } svg=svg+<<EOL <desc>宛名1</desc> EOL x=55 y=45 s=10 q[3].split(//u).each{|r| svg=svg+<<EOF #{textput(x,y,s,r)} EOF y=y+s } svg=svg+<<EOF #{textput(x,y,s,"様")} EOF svg=svg+<<EOL <desc>宛名2</desc> EOL x=44 y=45 s=10 q[4]=" " if q[4]==nil q[4].split(//u).each{|r| svg=svg+<<EOF #{textput(x,y,s,r)} EOF y=y+s } svg=svg+<<EOL <desc>差出人住所1</desc> <text x="30mm" y="65mm" font-size="5mm">ほ</text> <text x="30mm" y="70mm" font-size="5mm">げ</text> <text x="30mm" y="75mm" font-size="5mm">県</text> <text x="30mm" y="80mm" font-size="5mm">ほ</text> <text x="30mm" y="85mm" font-size="5mm">げ</text> <text x="30mm" y="90mm" font-size="5mm">市</text> <text x="30mm" y="95mm" font-size="5mm">ほ</text> <text x="30mm" y="100mm" font-size="5mm">げ</text> <text x="30mm" y="105mm" font-size="5mm">町</text> <desc>差出人住所2</desc> <text x="24mm" y="70mm" font-size="5mm">ほ</text> <text x="24mm" y="75mm" font-size="5mm">|</text> <text x="24mm" y="80mm" font-size="5mm">げ</text> <text x="24mm" y="85mm" font-size="5mm">|</text> <text x="24mm" y="90mm" font-size="5mm">ほ</text> <text x="24mm" y="95mm" font-size="5mm">げ</text> <text x="24mm" y="100mm" font-size="5mm">|</text> <text x="24mm" y="105mm" font-size="5mm">げ</text> <text x="24mm" y="110mm" font-size="5mm">げ</text> <text x="24mm" y="115mm" font-size="5mm">げ</text> <desc>差出人1</desc> <text x="18mm" y="80mm" font-size="5mm">ほ</text> <text x="18mm" y="85mm" font-size="5mm">げ</text> <text x="18mm" y="90mm" font-size="5mm"> </text> <text x="18mm" y="95mm" font-size="5mm">ほ</text> <text x="18mm" y="100mm" font-size="5mm">ほ</text> <desc>差出人1</desc> <text x="12mm" y="80mm" font-size="5mm"> </text> <text x="12mm" y="85mm" font-size="5mm"> </text> <text x="12mm" y="90mm" font-size="5mm"> </text> <text x="12mm" y="95mm" font-size="5mm">げ</text> <text x="12mm" y="100mm" font-size="5mm">げ</text> <desc>差出人郵便番号</desc> <text x="6mm" y="129mm" font-size="3mm">1</text> <text x="10mm" y="129mm" font-size="3mm">2</text> <text x="14mm" y="129mm" font-size="3mm">3</text> <text x="19mm" y="129mm" font-size="3mm">4</text> <text x="23mm" y="129mm" font-size="3mm">5</text> <text x="27mm" y="129mm" font-size="3mm">6</text> <text x="31mm" y="129mm" font-size="3mm">7</text> </svg> EOL open("ratena.#{i}.svg","w"){|f| f.puts svg } #お好みで `inkscape -A ratena.#{i}.pdf ratena.#{i}.svg` `pdf2ps ratena.#{i}.pdf` i=i+1 }
1000014,東京都千代田区,永田町1-7-1,衆 議院,参 議院様 1020092,東京都千代田区,隼町4-2,最 高裁,
ratenagaki 入力ファイル