bin/diru in diru-0.0.6 vs bin/diru in diru-0.0.7

- old
+ new

@@ -227,11 +227,11 @@ # Options File. @opts_file = opts_file # Temporary storage (scratch pad). - @scratch = nil + @scratch = {} # Glob pattern for DB build. @glob = "**/*" @logging = false @@ -398,17 +398,29 @@ end end # Set scratch dir. - def settmp( dir ) - @scratch = dir + def settmp( dir, reg = nil ) + @scratch[ reg ] = dir end # Get scratch dir. - def gettmp + def gettmp( reg = nil ) + @scratch[ reg ] + end + + + # Reset scratch dir. + def rtmp + @scratch = {} + end + + + # Get all scratch regs. + def scratch @scratch end def abs2rel( path ) @@ -800,14 +812,14 @@ STDERR.puts %q{ Search commands: * "dr r" - change to Project root dir. * "dr r <dir>" - change to <dir> (somewhere) under Project root dir - (glob). + (glob). * "dr t <dir>" - change to <dir> (somewhere) under current dir (glob). * "dr e <dir>" - change to <dir> (somewhere) under Project root dir - (regexp). + (regexp). Bookmark commands: * "dr b" - display bookmarks. * "dr b ." - add current dir to bookmarks. @@ -820,18 +832,23 @@ History commands: * "dr h" - display history. * "dr h ." - add current dir to history. * "dr h !" - reset (clear) history. -* "dr h ," - reference last history item. +* "dr h 0" - reference latest history item. * "dr h <num>" - change dir to history <num>. Scratch Pad commands: -* "dr s ." - store current dir to Scratch Pad. -* "dr s <dir>" - store <dir> to Scratch Pad. -* "dr s" - change dir to Scratch Pad dir. +* "dr s ." - store current dir to Default Scratch Pad. +* "dr s . <reg>" - store current dir to <reg> in Scratch Pad. +* "dr s <dir>" - store <dir> to Default Scratch Pad. +* "dr s <d> <r>" - store <dir> to <reg> in Scratch Pad. +* "dr s" - change dir to Default Scratch Pad. +* "dr s <reg>" - change dir to <reg> from Scratch Pad. +* "dr s =" - display Scratch Pad content. +* "dr s !" - reset (clear) Scratch Pad. Misc commands: * "dr p" - jump to peer dir, i.e. the peer of current (from options). * "dr c <cmd>" - issue RPC command to server (reset etc., see below). @@ -1104,31 +1121,50 @@ disp @search.ghist( arg[0].to_i ) end when 's'; if arg[0] == nil + # Change: "dr s" disp @search.gettmp - elsif arg[0] + else if arg[0] == '.' + # Store: "dr s ." + # OR: "dr s . <reg>" + reg = nil dir = @pwd + if arg[1] && arg[1].length == 1 + reg = arg[1] + end + disp @search.settmp( dir, reg ) + no_cd + elsif arg[0] == '=' + lregs( @search.scratch ) + no_cd + elsif arg[0] == '!' + @search.rtmp + no_cd + elsif arg[0].length == 1 + # Change: "dr s <reg>" + disp @search.gettmp( arg[0] ) else - dir = arg[0] + # Store: "dr s <dir>" + # OR: "dr s <dir> <reg>" + reg = nil + reg = arg[1] if arg[1] + disp @search.settmp( arg[0], reg ) + no_cd end - disp @search.settmp( dir ) - no_cd - else - no_cd end when 'p'; disp peer when 'c'; rpc( arg ) when 'f'; if arg[0] == nil @search.fav.each do |k,v| - STDERR.puts format( "%-6s %s", k, v ) + STDERR.puts format( " %-6s %s", k, v ) end no_cd else fav_map( arg ) end @@ -1262,10 +1298,18 @@ STDERR.puts format( "%2d: %s", i, book[i] ) end end + # List registers (key,value). + def lregs( regs ) + regs.each do |k,v| + STDERR.puts format( " %-2s: %s", k, v ) + end + end + + # Remove Procedure Call towards server. # # Example: # shell> dr @ rbook # @@ -1274,11 +1318,12 @@ when 'reset'; @search.reset when 'abook'; @search.abook( @pwd ) when 'lbook'; lbook( @search.book ) when 'rbook'; @search.rbook when 'doc'; doc - when 'sync'; @search.update_opts_sync when 'dsync'; @search.update_data_sync + when 'sync'; @search.update_opts_sync + when 'lregs'; @search.update_data_sync else return no_cd end no_cd end