Showing posts with label scripts. Show all posts
Showing posts with label scripts. Show all posts

Friday, September 24, 2010

Console2 and Altap Salamander: together at last!

Introduction

Not unlike Nuts and gum, I wanted Altap Salamander to play nice with Console2 by having the former launch the latter whenever I hit the / key above the numeric keypad. Console2 is awesome: it supports using Courier New as a font, has much more natural text selection, features copy & paste keyboard shortcuts, etc.

The problem

I used to connect the two together by launching Salamander with a batch file that would override the COMSPEC environment variable to point to Console2, which mostly worked, until a process launched by Salamander itself would try to use a shell. It turns out Console2 is NOT a shell and thus I would often get really weird behaviour out of those programs.

The solution, part 1

It turns out an Automation plug-in now exists for Salamander. Using it, I wrote the following quick script, adapted from the Launch Elevated Command Prompt.vbs sample script:

Set ShellApp = CreateObject("Shell.Application")
ShellApp.ShellExecute "E:\Program Files (x86)\Altap Salamander 2.54\Console2\Console.exe", "-d """ & Salamander.SourcePanel.Path & """", ""


The Plugins Manager allows me to bind keyboard shortcuts to individual scripts, so I selected Alt+- since just about everything else was taken and you can't use a shortcut key that Salamander itself already uses. A few dialog dismisses later and Alt+- indeed opens up Console2 to the current panel's path. Not bad, but my brain has fused the numpad / as the go-to key for opening a command prompt, so I need to fix that, too.



The solution, part 2



Another thread in the Salamander forums suggested using AutoHotKey to intercept NumpadDiv when Salamander has focus and using it to launch Console2. That kind of works, minus having Console2 launched at the current panel's folder. Well, remember the shortcut key I gave my automation script earlier? I can get AutoHotKey to intercept the numpad / and instead emit Alt+- when Salamander has focus:



#IfWinActive,ahk_class SalamanderMainWindowVer25
NumpadDiv::SendEvent !-
RETURN

Kazaam! Shazam!

Conclusion



All of this brouhaha could have been avoided if Salamander would simply let me configure what gets launched when I hit numpad /, hint, hint, nudge, nudge.

Wednesday, February 07, 2007

Backups of Subversion repositories

Here's the scenario: you are running a Subversion server and like all serious geeks, you want it backed up. This here post will show you how I do it for Windows and *nix _simultaneously_. I'm making the following assumptions:

Path typeWindows*nix
the subversion repositories are locatedd:\svnrepo/home/svn
the backup root folderd:\backups/home/backups
the subversion CLI(in the path)(in the path)


The first script performs not only a hotcopy backup of a repository (provided as the first parameter), but also first erases whatever backup might have been there (with a special provision for the very first time around) and creates a "dump" of the repository's contents, along with a final clean-up to save space. The reason we are keeping a dump over the contents of the db folder is that you can then "restore" your backup with a different version of Subversion. (trust me, I've lived through a catastrophic failure of a Subversion server and the dump format stays the same across versions while whatever's in the db folder doesn't necessarily)
Windows*nix
BackupAndDump.bat
@echo off
mkdir d:\backups\Subversion\%1\_backup
rmdir d:\backups\Subversion\%1 /s /q
svnadmin.exe hotcopy d:/SvnRepo/%1/ d:/backups/Subversion/%1/
svnadmin.exe dump d:/backups/Subversion/%1/ > d:/backups/Subversion/%1.svndump
rmdir d:\backups\Subversion\%1\db /s /q
backupanddump
#!/bin/sh
mkdir -p /home/backups/svn/$1/_backup
rm -rf /home/backups/svn/$1
svnadmin hotcopy /home/svn/$1/ /home/backups/svn/$1/
svnadmin dump /home/backups/svn/$1/ > /home/backups/svn/$1.svndump
rm -rf /home/backups/svn/$1/db



The second script iterates through all the repositories in a root folder and calls the first script (which, BTW, is located in the backup root folder) for each one.
Windows*nix
SubversionBackup.bat
@echo off
d:
cd \svnrepo
for /D %%d in (*) do d:\Backups\BackupAndDump %%d
svnbackup
#!/bin/sh
cd /home/svn
for d in *; do /home/backups/backupanddump $d; done


Well, that's enough for tonight. I'm sure all you Linux gurus out there are pointing and laughing at my noob-skills.