Wednesday, December 2, 2009

Midnight Commander File Shortcuts

2009-11-21

In the Midnight Commander (MC) command line you can use the shortcuts %f for the file selected in the active tab and %F for the one in the opposite tab, e.g. echo %F.

Update 2009-12-02: of course, even more important might be the midnight commander shortcut of '%D' for the other tabs directory (and vice versa '%d' for the current directory).

Saturday, November 21, 2009

Bash 2.0 For Loop Counter

This is the syntax you can use for a simple for loop counter in bash version 2 (e.g. on Apple OS X version 10.4):
for ((i = 1; i <= 5; i++)); do echo $i; done
Otherwise for i in {1..5}; do ... is a simpler syntax that works in newer bash versions. More details can be seen at Vivek Gite's Bash For Loop Examples.

Sunday, November 15, 2009

Ruby Command Line Parsing

require "optiflag"
require "log"

module Options extend OptiFlagSet
optional_switch_flag "debug"
optional_flag "date"
usage_flag "help"

and_process!
end

if Options.flags.debug?
Log.on
Log.log "debug mode on"
end

if Options.flags.date != nil
puts "-date #{Options.flags.date}"
end
Here is the official documentation with an example.